d7e5207317514b262988fda63c5165ecd0ecc526
[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 #include <epan/asn1.h>
103
104 #include "packet-bssap.h"
105 #include "packet-ber.h"
106 #include "packet-q931.h"
107 #include "packet-gsm_a.h"
108 #include "packet-ipv6.h"
109 #include "packet-sccp.h"
110
111 #include "packet-ppp.h"
112
113 /* PROTOTYPES/FORWARDS */
114
115 const value_string gsm_a_bssmap_msg_strings[] = {
116     { 0x01,     "Assignment Request" },
117     { 0x02,     "Assignment Complete" },
118     { 0x03,     "Assignment Failure" },
119     { 0x10,     "Handover Request" },
120     { 0x11,     "Handover Required" },
121     { 0x12,     "Handover Request Acknowledge" },
122     { 0x13,     "Handover Command" },
123     { 0x14,     "Handover Complete" },
124     { 0x15,     "Handover Succeeded" },
125     { 0x16,     "Handover Failure" },
126     { 0x17,     "Handover Performed" },
127     { 0x18,     "Handover Candidate Enquire" },
128     { 0x19,     "Handover Candidate Response" },
129     { 0x1a,     "Handover Required Reject" },
130     { 0x1b,     "Handover Detect" },
131     { 0x20,     "Clear Command" },
132     { 0x21,     "Clear Complete" },
133     { 0x22,     "Clear Request" },
134     { 0x23,     "Reserved" },
135     { 0x24,     "Reserved" },
136     { 0x25,     "SAPI 'n' Reject" },
137     { 0x26,     "Confusion" },
138     { 0x28,     "Suspend" },
139     { 0x29,     "Resume" },
140     { 0x2a,     "Connection Oriented Information" },
141     { 0x2b,     "Perform Location Request" },
142     { 0x2c,     "LSA Information" },
143     { 0x2d,     "Perform Location Response" },
144     { 0x2e,     "Perform Location Abort" },
145     { 0x2f,     "Common Id" },
146     { 0x30,     "Reset" },
147     { 0x31,     "Reset Acknowledge" },
148     { 0x32,     "Overload" },
149     { 0x33,     "Reserved" },
150     { 0x34,     "Reset Circuit" },
151     { 0x35,     "Reset Circuit Acknowledge" },
152     { 0x36,     "MSC Invoke Trace" },
153     { 0x37,     "BSS Invoke Trace" },
154     { 0x3a,     "Connectionless Information" },
155     { 0x40,     "Block" },
156     { 0x41,     "Blocking Acknowledge" },
157     { 0x42,     "Unblock" },
158     { 0x43,     "Unblocking Acknowledge" },
159     { 0x44,     "Circuit Group Block" },
160     { 0x45,     "Circuit Group Blocking Acknowledge" },
161     { 0x46,     "Circuit Group Unblock" },
162     { 0x47,     "Circuit Group Unblocking Acknowledge" },
163     { 0x48,     "Unequipped Circuit" },
164     { 0x4e,     "Change Circuit" },
165     { 0x4f,     "Change Circuit Acknowledge" },
166     { 0x50,     "Resource Request" },
167     { 0x51,     "Resource Indication" },
168     { 0x52,     "Paging" },
169     { 0x53,     "Cipher Mode Command" },
170     { 0x54,     "Classmark Update" },
171     { 0x55,     "Cipher Mode Complete" },
172     { 0x56,     "Queuing Indication" },
173     { 0x57,     "Complete Layer 3 Information" },
174     { 0x58,     "Classmark Request" },
175     { 0x59,     "Cipher Mode Reject" },
176     { 0x5a,     "Load Indication" },
177     { 0x04,     "VGCS/VBS Setup" },
178     { 0x05,     "VGCS/VBS Setup Ack" },
179     { 0x06,     "VGCS/VBS Setup Refuse" },
180     { 0x07,     "VGCS/VBS Assignment Request" },
181     { 0x1c,     "VGCS/VBS Assignment Result" },
182     { 0x1d,     "VGCS/VBS Assignment Failure" },
183     { 0x1e,     "VGCS/VBS Queuing Indication" },
184     { 0x1f,     "Uplink Request" },
185     { 0x27,     "Uplink Request Acknowledge" },
186     { 0x49,     "Uplink Request Confirmation" },
187     { 0x4a,     "Uplink Release Indication" },
188     { 0x4b,     "Uplink Reject Command" },
189     { 0x4c,     "Uplink Release Command" },
190     { 0x4d,     "Uplink Seized Command" },
191     { 0, NULL },
192 };
193
194 const value_string gsm_a_dtap_msg_mm_strings[] = {
195     { 0x01,     "IMSI Detach Indication" },
196     { 0x02,     "Location Updating Accept" },
197     { 0x04,     "Location Updating Reject" },
198     { 0x08,     "Location Updating Request" },
199     { 0x11,     "Authentication Reject" },
200     { 0x12,     "Authentication Request" },
201     { 0x14,     "Authentication Response" },
202     { 0x1c,     "Authentication Failure" },
203     { 0x18,     "Identity Request" },
204     { 0x19,     "Identity Response" },
205     { 0x1a,     "TMSI Reallocation Command" },
206     { 0x1b,     "TMSI Reallocation Complete" },
207     { 0x21,     "CM Service Accept" },
208     { 0x22,     "CM Service Reject" },
209     { 0x23,     "CM Service Abort" },
210     { 0x24,     "CM Service Request" },
211     { 0x25,     "CM Service Prompt" },
212     { 0x26,     "Reserved: was allocated in earlier phases of the protocol" },
213     { 0x28,     "CM Re-establishment Request" },
214     { 0x29,     "Abort" },
215     { 0x30,     "MM Null" },
216     { 0x31,     "MM Status" },
217     { 0x32,     "MM Information" },
218     { 0, NULL },
219 };
220
221 const value_string gsm_a_dtap_msg_rr_strings[] = {
222     { 0x3c,     "RR Initialisation Request" },
223     { 0x3b,     "Additional Assignment" },
224     { 0x3f,     "Immediate Assignment" },
225     { 0x39,     "Immediate Assignment Extended" },
226     { 0x3a,     "Immediate Assignment Reject" },
227
228     { 0x48,     "DTM Assignment Failure" },
229     { 0x49,     "DTM Reject" },
230     { 0x4a,     "DTM Request" },
231     { 0x4b,     "Main DCCH Assignment Command" },
232     { 0x4c,     "Packet Assignment Command" },
233
234     { 0x35,     "Ciphering Mode Command" },
235     { 0x32,     "Ciphering Mode Complete" },
236
237     { 0x30,     "Configuration Change Command" },
238     { 0x31,     "Configuration Change Ack." },
239     { 0x33,     "Configuration Change Reject" },
240
241     { 0x2e,     "Assignment Command" },
242     { 0x29,     "Assignment Complete" },
243     { 0x2f,     "Assignment Failure" },
244     { 0x2b,     "Handover Command" },
245     { 0x2c,     "Handover Complete" },
246     { 0x28,     "Handover Failure" },
247     { 0x2d,     "Physical Information" },
248     { 0x4d,     "DTM Assignment Command" },
249
250     { 0x08,     "RR-cell Change Order" },
251     { 0x23,     "PDCH Assignment Command" },
252
253     { 0x0d,     "Channel Release" },
254     { 0x0a,     "Partial Release" },
255     { 0x0f,     "Partial Release Complete" },
256
257     { 0x21,     "Paging Request Type 1" },
258     { 0x22,     "Paging Request Type 2" },
259     { 0x24,     "Paging Request Type 3" },
260     { 0x27,     "Paging Response" },
261     { 0x20,     "Notification/NCH" },
262     { 0x25,     "Reserved" },
263     { 0x26,     "Notification/Response" },
264
265     { 0x0b,     "Reserved" },
266
267 /*      ETSI TS 101 503 V8.5.0 Seems to give Other def for this Messages???
268     { 0xc0,     "Utran Classmark Change" }, CONFLICTS WITH Handover To UTRAN Command 
269     { 0xc1,     "UE RAB Preconfiguration" },
270     { 0xc2,     "cdma2000 Classmark Change" },*/
271
272         /* ETSI TS 101 503 V8.5.0 */
273     { 0x60,     "Utran Classmark Change" },  
274     { 0x61,     "UE RAB Preconfiguration" },
275     { 0x62,     "cdma2000 Classmark Change" },
276     { 0x63,     "Inter System to UTRAN Handover Command" },
277     { 0x64,     "Inter System to cdma2000 Handover Command" },
278     { 0x18,     "System Information Type 8" },
279     { 0x19,     "System Information Type 1" },
280     { 0x1a,     "System Information Type 2" },
281     { 0x1b,     "System Information Type 3" },
282     { 0x1c,     "System Information Type 4" },
283     { 0x1d,     "System Information Type 5" },
284     { 0x1e,     "System Information Type 6" },
285     { 0x1f,     "System Information Type 7" },
286
287     { 0x02,     "System Information Type 2bis" },
288     { 0x03,     "System Information Type 2ter" },
289     { 0x07,     "System Information Type 2quater" },
290     { 0x05,     "System Information Type 5bis" },
291     { 0x06,     "System Information Type 5ter" },
292     { 0x04,     "System Information Type 9" },
293     { 0x00,     "System Information Type 13" },
294
295     { 0x3d,     "System Information Type 16" },
296     { 0x3e,     "System Information Type 17" },
297
298     { 0x40,     "System Information Type 18" },
299     { 0x41,     "System Information Type 19" },
300     { 0x42,     "System Information Type 20" },
301
302     { 0x10,     "Channel Mode Modify" },
303     { 0x12,     "RR Status" },
304     { 0x17,     "Channel Mode Modify Acknowledge" },
305     { 0x14,     "Frequency Redefinition" },
306     { 0x15,     "Measurement Report" },
307     { 0x16,     "Classmark Change" },
308     { 0x13,     "Classmark Enquiry" },
309     { 0x36,     "Extended Measurement Report" },
310     { 0x37,     "Extended Measurement Order" },
311     { 0x34,     "GPRS Suspension Request" },
312
313     { 0x09,     "VGCS Uplink Grant" },
314     { 0x0e,     "Uplink Release" },
315     { 0x0c,     "Reserved" },
316     { 0x2a,     "Uplink Busy" },
317     { 0x11,     "Talker Indication" },
318
319     { 0xc0,     "UTRAN Classmark Change/Handover To UTRAN Command" },   /* spec conflict */
320
321     { 0x38,     "Application Information" },
322
323     { 0, NULL },
324 };
325
326 const value_string gsm_a_dtap_msg_cc_strings[] = {
327     { 0x01,     "Alerting" },
328     { 0x08,     "Call Confirmed" },
329     { 0x02,     "Call Proceeding" },
330     { 0x07,     "Connect" },
331     { 0x0f,     "Connect Acknowledge" },
332     { 0x0e,     "Emergency Setup" },
333     { 0x03,     "Progress" },
334     { 0x04,     "CC-Establishment" },
335     { 0x06,     "CC-Establishment Confirmed" },
336     { 0x0b,     "Recall" },
337     { 0x09,     "Start CC" },
338     { 0x05,     "Setup" },
339     { 0x17,     "Modify" },
340     { 0x1f,     "Modify Complete" },
341     { 0x13,     "Modify Reject" },
342     { 0x10,     "User Information" },
343     { 0x18,     "Hold" },
344     { 0x19,     "Hold Acknowledge" },
345     { 0x1a,     "Hold Reject" },
346     { 0x1c,     "Retrieve" },
347     { 0x1d,     "Retrieve Acknowledge" },
348     { 0x1e,     "Retrieve Reject" },
349     { 0x25,     "Disconnect" },
350     { 0x2d,     "Release" },
351     { 0x2a,     "Release Complete" },
352     { 0x39,     "Congestion Control" },
353     { 0x3e,     "Notify" },
354     { 0x3d,     "Status" },
355     { 0x34,     "Status Enquiry" },
356     { 0x35,     "Start DTMF" },
357     { 0x31,     "Stop DTMF" },
358     { 0x32,     "Stop DTMF Acknowledge" },
359     { 0x36,     "Start DTMF Acknowledge" },
360     { 0x37,     "Start DTMF Reject" },
361     { 0x3a,     "Facility" },
362     { 0, NULL },
363 };
364
365 const value_string gsm_a_dtap_msg_gmm_strings[] = {
366     { 0x01,     "Attach Request" },
367     { 0x02,     "Attach Accept" },
368     { 0x03,     "Attach Complete" },
369     { 0x04,     "Attach Reject" },
370     { 0x05,     "Detach Request" },
371     { 0x06,     "Detach Accept" },
372     { 0x08,     "Routing Area Update Request" },
373     { 0x09,     "Routing Area Update Accept" },
374     { 0x0a,     "Routing Area Update Complete" },
375     { 0x0b,     "Routing Area Update Reject" },
376     { 0x0c,     "Service Request" },
377     { 0x0d,     "Service Accept" },
378     { 0x0e,     "Service Reject" },
379     { 0x10,     "P-TMSI Reallocation Command" },
380     { 0x11,     "P-TMSI Reallocation Complete" },
381     { 0x12,     "Authentication and Ciphering Req" },
382     { 0x13,     "Authentication and Ciphering Resp" },
383     { 0x14,     "Authentication and Ciphering Rej" },
384     { 0x1c,     "Authentication and Ciphering Failure" },
385     { 0x15,     "Identity Request" },
386     { 0x16,     "Identity Response" },
387     { 0x20,     "GMM Status" },
388     { 0x21,     "GMM Information" },
389     { 0, NULL },
390 };
391
392 const value_string gsm_a_dtap_msg_sms_strings[] = {
393     { 0x01,     "CP-DATA" },
394     { 0x04,     "CP-ACK" },
395     { 0x10,     "CP-ERROR" },
396     { 0, NULL },
397 };
398
399 const value_string gsm_a_dtap_msg_sm_strings[] = {
400     { 0x41,     "Activate PDP Context Request" },
401     { 0x42,     "Activate PDP Context Accept" },
402     { 0x43,     "Activate PDP Context Reject" },
403     { 0x44,     "Request PDP Context Activation" },
404     { 0x45,     "Request PDP Context Activation rej." },
405     { 0x46,     "Deactivate PDP Context Request" },
406     { 0x47,     "Deactivate PDP Context Accept" },
407     { 0x48,     "Modify PDP Context Request(Network to MS direction)" },
408     { 0x49,     "Modify PDP Context Accept (MS to network direction)" },
409     { 0x4a,     "Modify PDP Context Request(MS to network direction)" },
410     { 0x4b,     "Modify PDP Context Accept (Network to MS direction)" },
411     { 0x4c,     "Modify PDP Context Reject" },
412     { 0x4d,     "Activate Secondary PDP Context Request" },
413     { 0x4e,     "Activate Secondary PDP Context Accept" },
414     { 0x4f,     "Activate Secondary PDP Context Reject" },
415     { 0x50,     "Reserved: was allocated in earlier phases of the protocol" },
416     { 0x51,     "Reserved: was allocated in earlier phases of the protocol" },
417     { 0x52,     "Reserved: was allocated in earlier phases of the protocol" },
418     { 0x53,     "Reserved: was allocated in earlier phases of the protocol" },
419     { 0x54,     "Reserved: was allocated in earlier phases of the protocol" },
420     { 0x55,     "SM Status" },
421     { 0x56,     "Activate MBMS Context Request" },
422     { 0x57,     "Activate MBMS Context Accept" },
423     { 0x58,     "Activate MBMS Context Reject" },
424     { 0x59,     "Request MBMS Context Activation" },
425     { 0x5a,     "Request MBMS Context Activation Reject" },
426     { 0, NULL },
427 };
428
429 const value_string gsm_a_dtap_msg_ss_strings[] = {
430     { 0x2a,     "Release Complete" },
431     { 0x3a,     "Facility" },
432     { 0x3b,     "Register" },
433     { 0, NULL },
434 };
435
436 static const value_string gsm_rp_msg_strings[] = {
437     { 0x00,     "RP-DATA (MS to Network)" },
438     { 0x01,     "RP-DATA (Network to MS)" },
439     { 0x02,     "RP-ACK (MS to Network)" },
440     { 0x03,     "RP-ACK (Network to MS)" },
441     { 0x04,     "RP-ERROR (MS to Network)" },
442     { 0x05,     "RP-ERROR (Network to MS)" },
443     { 0x06,     "RP-SMMA (MS to Network)" },
444     { 0, NULL },
445 };
446
447 static const value_string gsm_bssmap_elem_strings[] = {
448     { 0x01,     "Circuit Identity Code" },
449     { 0x02,     "Reserved" },
450     { 0x03,     "Resource Available" },
451     { 0x04,     "Cause" },
452     { 0x05,     "Cell Identifier" },
453     { 0x06,     "Priority" },
454     { 0x07,     "Layer 3 Header Information" },
455     { 0x08,     "IMSI" },
456     { 0x09,     "TMSI" },
457     { 0x0a,     "Encryption Information" },
458     { 0x0b,     "Channel Type" },
459     { 0x0c,     "Periodicity" },
460     { 0x0d,     "Extended Resource Indicator" },
461     { 0x0e,     "Number Of MSs" },
462     { 0x0f,     "Reserved" },
463     { 0x10,     "Reserved" },
464     { 0x11,     "Reserved" },
465     { 0x12,     "Classmark Information Type 2" },
466     { 0x13,     "Classmark Information Type 3" },
467     { 0x14,     "Interference Band To Be Used" },
468     { 0x15,     "RR Cause" },
469     { 0x16,     "Reserved" },
470     { 0x17,     "Layer 3 Information" },
471     { 0x18,     "DLCI" },
472     { 0x19,     "Downlink DTX Flag" },
473     { 0x1a,     "Cell Identifier List" },
474     { 0x1b,     "Response Request" },
475     { 0x1c,     "Resource Indication Method" },
476     { 0x1d,     "Classmark Information Type 1" },
477     { 0x1e,     "Circuit Identity Code List" },
478     { 0x1f,     "Diagnostic" },
479     { 0x20,     "Layer 3 Message Contents" },
480     { 0x21,     "Chosen Channel" },
481     { 0x22,     "Total Resource Accessible" },
482     { 0x23,     "Cipher Response Mode" },
483     { 0x24,     "Channel Needed" },
484     { 0x25,     "Trace Type" },
485     { 0x26,     "TriggerID" },
486     { 0x27,     "Trace Reference" },
487     { 0x28,     "TransactionID" },
488     { 0x29,     "Mobile Identity" },
489     { 0x2a,     "OMCID" },
490     { 0x2b,     "Forward Indicator" },
491     { 0x2c,     "Chosen Encryption Algorithm" },
492     { 0x2d,     "Circuit Pool" },
493     { 0x2e,     "Circuit Pool List" },
494     { 0x2f,     "Time Indication" },
495     { 0x30,     "Resource Situation" },
496     { 0x31,     "Current Channel Type 1" },
497     { 0x32,     "Queuing Indicator" },
498     { 0x40,     "Speech Version" },
499     { 0x33,     "Assignment Requirement" },
500     { 0x35,     "Talker Flag" },
501     { 0x36,     "Connection Release Requested" },
502     { 0x37,     "Group Call Reference" },
503     { 0x38,     "eMLPP Priority" },
504     { 0x39,     "Configuration Evolution Indication" },
505     { 0x3a,     "Old BSS to New BSS Information" },
506     { 0x3b,     "LSA Identifier" },
507     { 0x3c,     "LSA Identifier List" },
508     { 0x3d,     "LSA Information" },
509     { 0x3e,     "LCS QoS" },
510     { 0x3f,     "LSA access control suppression" },
511     { 0x43,     "LCS Priority" },
512     { 0x44,     "Location Type" },
513     { 0x45,     "Location Estimate" },
514     { 0x46,     "Positioning Data" },
515     { 0x47,     "LCS Cause" },
516     { 0x48,     "LCS Client Type" },
517     { 0x49,     "APDU" },
518     { 0x4a,     "Network Element Identity" },
519     { 0x4b,     "GPS Assistance Data" },
520     { 0x4c,     "Deciphering Keys" },
521     { 0x4d,     "Return Error Request" },
522     { 0x4e,     "Return Error Cause" },
523     { 0x4f,     "Segmentation" },
524     { 0, NULL },
525 };
526
527 static const value_string gsm_dtap_elem_strings[] = {
528     /* Common Information Elements 10.5.1 */
529     { 0x00,     "Cell Identity" },
530     { 0x00,     "Ciphering Key Sequence Number" },
531     { 0x00,     "Location Area Identification" },
532     { 0x00,     "Mobile Identity" },
533     { 0x00,     "Mobile Station Classmark 1" },
534     { 0x00,     "Mobile Station Classmark 2" },
535     { 0x00,     "Mobile Station Classmark 3" },
536     { 0x00,     "Descriptive group or broadcast call reference" },
537     { 0x00,     "Group Cipher Key Number" },
538     { 0x00,     "PD and SAPI $(CCBS)$" },
539         /* Pos 10 */
540     { 0x00,     "Priority Level" },
541     { 0x00,     "PLMN List" },
542     /* Radio Resource Management Information Elements 10.5.2, most are from 10.5.1 */
543 /*
544  * [3]  10.5.2.1a       BA Range
545  */
546     { 0x00,     "Cell Channel Description" },           /* [3]  10.5.2.1b       */      
547 /* [3]  10.5.2.1c       BA List Pref
548  * [3]  10.5.2.1d       UTRAN Frequency List
549  * [3]  10.5.2.1e       Cell selection indicator after release of all TCH and SDCCH IE
550  */
551         { 0x00, "Cell Description" },                           /* 10.5.2.2  */
552 /*
553  * [3]  10.5.2.3        Cell Options (BCCH)     
554  * [3]  10.5.2.3a       Cell Options (SACCH)
555  * [3]  10.5.2.4        Cell Selection Parameters
556  * [3]  10.5.2.4a       (void) */
557         { 0x00, "Channel Description" },                        /* 10.5.2.5      */
558         { 0x00, "Channel Description 2" },                      /* 10.5.2.5a */
559
560         { 0x00, "Channel Mode" },                                       /* [3]  10.5.2.6 */     
561         { 0x00, "Channel Mode 2" },                                     /* [3]  10.5.2.7 */     
562 /* [3]  10.5.2.7a       UTRAN predefined configuration status information / START-CS / UE CapabilityUTRAN Classmark information element 218
563  * [3]  10.5.2.7b       (void) */
564         { 0x00, "Classmark Enquiry Mask" },                     /* [3]  10.5.2.7c */
565 /* [3]  10.5.2.7d       GERAN Iu Mode Classmark information element */
566         { 0x00, "Channel Needed"},                                      /* [3]  10.5.2.8        */
567  /* [3]  10.5.2.8a      (void) */
568  /* [3]  10.5.2.8b      Channel Request Description 2 */
569                 /* Pos 20 */
570         { 0x00, "Cipher Mode Setting" },                                /* [3]  10.5.2.9        */
571 /* [3]  10.5.2.10       Cipher Response
572  * [3]  10.5.2.11       Control Channel Description
573  * [3]  10.5.2.11a      DTM Information Details */
574         { 0x00, "Dynamic ARFCN Mapping" },                      /* [3]  10.5.2.11b      */
575         { 0x00, "Frequency Channel Sequence" },         /* [3]  10.5.2.12       */
576     { 0x00,     "Frequency List" },                                     /* 10.5.2.13            */
577         { 0x00, "Frequency Short List" },                       /* 10.5.2.14            */
578         { 0x00, "Frequency Short List2" },                      /* 10.5.2.14a           */
579 /* [3]  10.5.2.14b      Group Channel Description
580  * [3]  10.5.2.14c      GPRS Resumption
581  * [3]  10.5.2.14d      GPRS broadcast information
582  * [3]  10.5.2.14e      Enhanced DTM CS Release Indication
583  */
584         { 0x00, "Handover Reference" },                         /* 10.5.2.15 */
585 /*
586  * [3] 10.5.2.16 IA Rest Octets
587  * [3] 10.5.2.17 IAR Rest Octets
588  * [3] 10.5.2.18 IAX Rest Octets
589  * [3] 10.5.2.19 L2 Pseudo Length
590  * [3] 10.5.2.20 Measurement Results
591  * [3] 10.5.2.20a GPRS Measurement Results
592  */
593         { 0x00, "Mobile Allocation" },                          /* [3] 10.5.2.21        */ 
594         { 0x00, "Mobile Time Difference" },                     /* [3] 10.5.2.21a       */
595         { 0x00, "MultiRate configuration" },            /* [3] 10.5.2.21aa      */
596         /* Pos 30 */
597         { 0x00, "Multislot Allocation" },                       /* [3] 10.5.2.21b       */ 
598  /*
599  * [3] 10.5.2.21c NC mode
600  * [3] 10.5.2.22 Neighbour Cell Description
601  * [3] 10.5.2.22a Neighbour Cell Description 2
602  * [3] 10.5.2.22b (void)
603  * [3] 10.5.2.22c NT/N Rest Octets
604  * [3] 10.5.2.23 P1 Rest Octets
605  * [3] 10.5.2.24 P2 Rest Octets
606  * [3] 10.5.2.25 P3 Rest Octets
607  * [3] 10.5.2.25a Packet Channel Description
608  * [3] 10.5.2.25b Dedicated mode or TBF
609  * [3] 10.5.2.25c RR Packet Uplink Assignment
610  * [3] 10.5.2.25d RR Packet Downlink Assignment
611  * [3] 10.5.2.26 Page Mode
612  * [3] 10.5.2.26a (void)
613  * [3] 10.5.2.26b (void)
614  * [3] 10.5.2.26c (void)
615  * [3] 10.5.2.26d (void)
616  * [3] 10.5.2.27 NCC Permitted
617  */
618         { 0x00, "Power Command" },                                      /* 10.5.2.28 */
619         { 0x00, "Power Command and access type" },      /* 10.5.2.28a */
620 /*
621  * [3] 10.5.2.29 RACH Control Parameters
622  * [3] 10.5.2.30 Request Reference
623  */
624     { 0x00,     "RR Cause" },                                           /* 10.5.2.31 */
625         { 0x00, "Synchronization Indication" },         /* 10.5.2.39 */
626 /* [3] 10.5.2.32 SI 1 Rest Octets
627  * [3] 10.5.2.33 SI 2bis Rest Octets 
628  * [3] 10.5.2.33a SI 2ter Rest Octets
629  * [3] 10.5.2.33b SI 2quater Rest Octets
630  * [3] 10.5.2.34 SI 3 Rest Octets
631  * [3] 10.5.2.35 SI 4 Rest Octets
632  * [3] 10.5.2.35a SI 6 Rest Octets
633  * [3] 10.5.2.36 SI 7 Rest Octets
634  * [3] 10.5.2.37 SI 8 Rest Octets
635  * [3] 10.5.2.37a SI 9 Rest Octets
636  * [3] 10.5.2.37b SI 13 Rest Octets
637  * [3] 10.5.2.37c (void)
638  * [3] 10.5.2.37d (void)
639  * [3] 10.5.2.37e SI 16 Rest Octets
640  * [3] 10.5.2.37f SI 17 Rest Octets
641  * [3] 10.5.2.37g SI 19 Rest Octets
642  * [3] 10.5.2.37h SI 18 Rest Octets
643  * [3] 10.5.2.37i SI 20 Rest Octets */
644     { 0x00,     "Starting Time" },                                      /* [3] 10.5.2.38 Starting Time  */
645     { 0x00,     "Timing Advance" },                                     /* [3] 10.5.2.40 Timing Advance */ 
646         { 0x00, "Time Difference" },                            /* [3] 10.5.2.41 Time Difference                                */
647         { 0x00, "TLLI" },                                                       /* [3] 10.5.2.41a TLLI                                                  */
648 /*
649  * [3] 10.5.2.42 TMSI/P-TMSI */
650         { 0x00, "VGCS target mode Indication" },        /* [3] 10.5.2.42a                                                               */ 
651         /* Pos 40 */
652         { 0x00, "VGCS Ciphering Parameters" },          /* [3] 10.5.2.42b                                                               */
653 /* [3] 10.5.2.43 Wait Indication
654  * [3] 10.5.2.44 SI10 rest octets $(ASCI)$
655  * [3] 10.5.2.45 EXTENDED MEASUREMENT RESULTS
656  * [3] 10.5.2.46 Extended Measurement Frequency List */
657         { 0x00, "Suspension Cause" },                           /* [3] 10.5.2.47                                                                */ 
658 /* [3] 10.5.2.48 APDU ID 
659  * [3] 10.5.2.49 APDU Flags
660  * [3] 10.5.2.50 APDU Data
661  * [3] 10.5.2.51 Handover To UTRAN Command
662  * [3] 10.5.2.52 Handover To cdma2000 Command 
663  * [3] 10.5.2.53 (void)
664  * [3] 10.5.2.54 (void)
665  * [3] 10.5.2.55 (void)
666  * [3] 10.5.2.56 3G Target Cell */
667         { 0x00, "Dedicated Service Information" },              /* [3] 10.5.2.59        */
668
669
670     /* Mobility Management Information Elements 10.5.3 */
671     { 0x00,     "Authentication Parameter RAND" },
672     { 0x00,     "Authentication Parameter AUTN (UMTS authentication challenge only)" },
673     { 0x00,     "Authentication Response Parameter" },
674     { 0x00,     "Authentication Response Parameter (extension) (UMTS authentication challenge only)" },
675     { 0x00,     "Authentication Failure Parameter (UMTS authentication challenge only)" },
676     { 0x00,     "CM Service Type" },
677     { 0x00,     "Identity Type" },
678         /* Pos 50 */
679     { 0x00,     "Location Updating Type" },
680     { 0x00,     "Network Name" },
681     { 0x00,     "Reject Cause" },
682     { 0x00,     "Follow-on Proceed" },
683     { 0x00,     "Time Zone" },
684     { 0x00,     "Time Zone and Time" },
685     { 0x00,     "CTS Permission" },
686     { 0x00,     "LSA Identifier" },
687     { 0x00,     "Daylight Saving Time" },
688     { 0x00, "Emergency Number List" },
689     /* Call Control Information Elements 10.5.4 */
690         /* Pos 60 */
691     { 0x00,     "Auxiliary States" },                                   /* 10.5.4.4 Auxiliary states */
692     { 0x00,     "Bearer Capability" },                                  /* 10.5.4.4a Backup bearer capability */
693     { 0x00,     "Call Control Capabilities" },
694     { 0x00,     "Call State" },
695     { 0x00,     "Called Party BCD Number" },
696     { 0x00,     "Called Party Subaddress" },
697     { 0x00,     "Calling Party BCD Number" },
698     { 0x00,     "Calling Party Subaddress" },
699     { 0x00,     "Cause" },
700     { 0x00,     "CLIR Suppression" },
701     { 0x00,     "CLIR Invocation" },
702     { 0x00,     "Congestion Level" },
703     { 0x00,     "Connected Number" },
704     { 0x00,     "Connected Subaddress" },
705     { 0x00,     "Facility" },
706     { 0x00,     "High Layer Compatibility" },
707     { 0x00,     "Keypad Facility" },
708     { 0x00,     "Low Layer Compatibility" },
709     { 0x00,     "More Data" },
710     { 0x00,     "Notification Indicator" },
711     { 0x00,     "Progress Indicator" },
712     { 0x00,     "Recall type $(CCBS)$" },
713     { 0x00,     "Redirecting Party BCD Number" },
714     { 0x00,     "Redirecting Party Subaddress" },
715     { 0x00,     "Repeat Indicator" },
716     { 0x00,     "Reverse Call Setup Direction" },
717     { 0x00,     "SETUP Container $(CCBS)$" },
718     { 0x00,     "Signal" },
719     { 0x00,     "SS Version Indicator" },
720     { 0x00,     "User-user" },
721     { 0x00,     "Alerting Pattern $(NIA)$" },                   /* 10.5.4.26 Alerting Pattern $(NIA)$ */
722     { 0x00,     "Allowed Actions $(CCBS)$" },
723     { 0x00,     "Stream Identifier" },
724     { 0x00,     "Network Call Control Capabilities" },
725     { 0x00,     "Cause of No CLI" },
726     { 0x00,     "Immediate Modification Indicator" },   /* 10.5.4.30 Cause of No CLI */
727         /* 10.5.4.31 Void */
728     { 0x00,     "Supported Codec List" },                               /* 10.5.4.32 Supported codec list */
729     { 0x00,     "Service Category" },                                   /* 10.5.4.33 Service category */
730         /* 10.5.4.34 Redial */
731         /* 10.5.4.35 Network-initiated Service Upgrade indicator */
732     /* GPRS Mobility Management Information Elements 10.5.5 */
733     { 0x00,     "Attach Result" },
734     { 0x00,     "Attach Type" },
735     { 0x00,     "Cipher Algorithm" },
736     { 0x00,     "TMSI Status" },
737     { 0x00,     "Detach Type" },
738     { 0x00,     "DRX Parameter" },
739     { 0x00,     "Force to Standby" },
740     { 0x00, "Force to Standby" },
741     { 0x00,     "P-TMSI Signature" },
742     { 0x00,     "P-TMSI Signature 2" },
743     { 0x00,     "Identity Type 2" },
744     { 0x00,     "IMEISV Request" },
745     { 0x00,     "Receive N-PDU Numbers List" },
746     { 0x00,     "MS Network Capability" },
747     { 0x00,     "MS Radio Access Capability" },
748     { 0x00,     "GMM Cause" },
749     { 0x00,     "Routing Area Identification" },
750     { 0x00,     "Update Result" },
751     { 0x00, "Update Type" },
752     { 0x00,     "A&C Reference Number" },
753     { 0x00, "A&C Reference Number" },
754     { 0x00,     "Service Type" },
755     { 0x00,     "Cell Notification" },
756     { 0x00, "PS LCS Capability" },
757     { 0x00,     "Network Feature Support" },
758         { 0x00, "Inter RAT information container" },
759     /* Short Message Service Information Elements [5] 8.1.4 */
760     { 0x00,     "CP-User Data" },
761     { 0x00,     "CP-Cause" },
762     /* Short Message Service Information Elements [5] 8.2 */
763     { 0x00,     "RP-Message Reference" },
764     { 0x00,     "RP-Origination Address" },
765     { 0x00,     "RP-Destination Address" },
766     { 0x00,     "RP-User Data" },
767     { 0x00,     "RP-Cause" },
768     /* Session Management Information Elements 10.5.6 */
769     { 0x00,     "Access Point Name" },
770     { 0x00,     "Network Service Access Point Identifier" },
771     { 0x00,     "Protocol Configuration Options" },
772     { 0x00,     "Packet Data Protocol Address" },
773     { 0x00,     "Quality Of Service" },
774     { 0x00,     "SM Cause" },
775     { 0x00,     "Linked TI" },
776     { 0x00,     "LLC Service Access Point Identifier" },
777     { 0x00,     "Tear Down Indicator" },
778     { 0x00,     "Packet Flow Identifier" },
779     { 0x00,     "Traffic Flow Template" },
780     /* GPRS Common Information Elements 10.5.7 */
781     { 0x00,     "PDP Context Status" },
782     { 0x00,     "Radio Priority" },
783     { 0x00,     "GPRS Timer" },
784     { 0x00,     "GPRS Timer 2" },
785     { 0x00, "Radio Priority 2"},
786         { 0x00, "MBMS context status"},
787     { 0x00, "Spare Nibble"},
788     { 0, NULL },
789 };
790
791 const gchar *gsm_a_pd_str[] = {
792     "Group Call Control",
793     "Broadcast Call Control",
794     "Reserved: was allocated in earlier phases of the protocol",
795     "Call Control; call related SS messages",
796     "GPRS Transparent Transport Protocol (GTTP)",
797     "Mobility Management messages",
798     "Radio Resources Management messages",
799     "Unknown",
800     "GPRS Mobility Management messages",
801     "SMS messages",
802     "GPRS Session Management messages",
803     "Non call related SS messages",
804     "Location Services",
805     "Unknown",
806     "Reserved for extension of the PD to one octet length",
807     "Reserved for tests procedures"
808 };
809 /* L3 Protocol discriminator values according to TS 24 007 (6.4.0)  */
810 static const value_string protocol_discriminator_vals[] = {
811         {0x0,           "Group call control"},
812         {0x1,           "Broadcast call control"},
813         {0x2,           "Reserved: was allocated in earlier phases of the protocol"},
814         {0x3,           "Call Control; call related SS messages"},
815         {0x4,           "GPRS Transparent Transport Protocol (GTTP)"},
816         {0x5,           "Mobility Management messages"},
817         {0x6,           "Radio Resources Management messages"},
818         {0x7,           "Unknown"},
819         {0x8,           "GPRS mobility management messages"},
820         {0x9,           "SMS messages"},
821         {0xa,           "GPRS session management messages"},
822         {0xb,           "Non call related SS messages"},
823         {0xc,           "Location services specified in 3GPP TS 44.071 [8a]"},
824         {0xd,           "Unknown"},
825         {0xe,           "Reserved for extension of the PD to one octet length "},
826         {0xf,           "Reserved for tests procedures described in 3GPP TS 44.014 [5a] and 3GPP TS 34.109 [17a]."},
827         { 0,    NULL }
828 };
829
830 static const value_string gsm_a_pd_short_str_vals[] = {
831         {0x0,           "GCC"},                         /* Group Call Control */
832         {0x1,           "BCC"},                         /* Broadcast Call Control */
833         {0x2,           "Reserved"},            /* : was allocated in earlier phases of the protocol */
834         {0x3,           "CC"},                          /* Call Control; call related SS messages */
835         {0x4,           "GTTP"},                        /* GPRS Transparent Transport Protocol (GTTP) */
836         {0x5,           "MM"},                          /* Mobility Management messages */
837         {0x6,           "RR"},                          /* Radio Resources Management messages */
838         {0x7,           "Unknown"},
839         {0x8,           "GMM"},                         /* GPRS Session Management messages */
840         {0x9,           "SMS"},
841         {0xa,           "SM"},                          /* GPRS Session Management messages */
842         {0xb,           "SS"},
843         {0xc,           "LS"},                          /* Location Services */
844         {0xd,           "Unknown"},
845         {0xe,           "Reserved"},            /*  for extension of the PD to one octet length  */
846         {0xf,           "Reserved"},            /*  for tests procedures described in 3GPP TS 44.014 [5a] and 3GPP TS 34.109 [17a].*/
847         { 0,    NULL }
848 };
849 static const value_string bssap_cc_values[] = {
850     { 0x00,             "not further specified" },
851     { 0x80,             "FACCH or SDCCH" },
852     { 0xc0,             "SACCH" },
853     { 0,                NULL } };
854
855 static const value_string bssap_sapi_values[] = {
856     { 0x00,             "RR/MM/CC" },
857     { 0x03,             "SMS" },
858     { 0,                NULL } };
859
860 /* Mobile Station Classmark Value strings
861  */
862
863 /* Mobile Station Classmark  
864  * Revision level 
865  */
866 const value_string gsm_a_msc_rev_vals[] = {
867         { 0,            "Reserved for GSM phase 1"},
868         { 1,            "Used by GSM phase 2 mobile stations"},
869         { 2,            "Used by mobile stations supporting R99 or later versions of the protocol"},
870         { 3,            "Reserved for future use"},
871         { 0,    NULL }
872 };
873
874 /* ES IND (octet 3, bit 5) "Controlled Early Classmark Sending" option implementation */
875 static const value_string ES_IND_vals[] = {
876         { 0,            "Controlled Early Classmark Sending option is not implemented in the MS"},
877         { 1,            "Controlled Early Classmark Sending option is implemented in the MS"},
878         { 0,    NULL }
879 };
880 /* A5/1 algorithm supported (octet 3, bit 4 */
881 static const value_string A5_1_algorithm_sup_vals[] = {
882         { 0,            "encryption algorithm A5/1 available"},
883         { 1,            "encryption algorithm A5/1 not available"},
884         { 0,    NULL }
885 };
886 /* RF Power Capability (Octet 3) */
887 static const value_string RF_power_capability_vals[] = {
888         { 0,            "class 1"},
889         { 1,            "class 2"},
890         { 2,            "class 3"},
891         { 3,            "class 4"},
892         { 4,            "class 5"},
893         { 7,            "RF Power capability is irrelevant in this information element"},
894         { 0,    NULL }
895 };
896 /* PS capability (pseudo-synchronization capability) (octet 4) */
897 static const value_string ps_sup_cap_vals[] = {
898         { 0,            "PS capability not present"},
899         { 1,            "PS capability present"},
900         { 0,    NULL }
901 };
902 /* SS Screening Indicator (octet 4)defined in 3GPP TS 24.080 */
903 static const value_string SS_screening_indicator_vals[] = {
904         { 0,            "Default value of phase 1"},
905         { 1,            "Capability of handling of ellipsis notation and phase 2 error handling "},
906         { 2,            "For future use"},
907         { 3,            "For future use"},
908         { 0,    NULL }
909 };
910 /* SM capability (MT SMS pt to pt capability) (octet 4)*/
911 static const value_string SM_capability_vals[] = {
912         { 0,            "Mobile station does not support mobile terminated point to point SMS"},
913         { 1,            "Mobile station supports mobile terminated point to point SMS"},
914         { 0,    NULL }
915 };
916 /* VBS notification reception (octet 4) */
917 static const value_string VBS_notification_rec_vals[] = {
918         { 0,            "no VBS capability or no notifications wanted"},
919         { 1,            "VBS capability and notifications wanted"},
920         { 0,    NULL }
921 };
922 /* VGCS notification reception (octet 4) */
923 static const value_string VGCS_notification_rec_vals[] = {
924         { 0,            "no VGCS capability or no notifications wanted"},
925         { 1,            "VGCS capability and notifications wanted"},
926         { 0,    NULL }
927 };
928 /* FC Frequency Capability (octet 4 ) */
929 static const value_string FC_frequency_cap_vals[] = {
930         { 0,            "The MS does not support the E-GSM or R-GSM band"},
931         { 1,            "The MS does support the E-GSM or R-GSM "},
932         { 0,    NULL }
933 };
934 /* CM3 (octet 5, bit 8) */
935 static const value_string CM3_vals[] = {
936         { 0,            "The MS does not support any options that are indicated in CM3"},
937         { 1,            "The MS supports options that are indicated in classmark 3 IE"},
938         { 0,    NULL }
939 };
940 /* LCS VA capability (LCS value added location request notification capability) (octet 5,bit 6) */
941 static const value_string LCS_VA_cap_vals[] = {
942         { 0,            "LCS value added location request notification capability not supported"},
943         { 1,            "LCS value added location request notification capability supported"},
944         { 0,    NULL }
945 };
946 /* UCS2 treatment (octet 5, bit 5) */
947 static const value_string UCS2_treatment_vals[] = {
948         { 0,            "the ME has a preference for the default alphabet"},
949         { 1,            "the ME has no preference between the use of the default alphabet and the use of UCS2"},
950         { 0,    NULL }
951 };
952 /* SoLSA (octet 5, bit 4) */
953 static const value_string SoLSA_vals[] = {
954         { 0,            "The ME does not support SoLSA"},
955         { 1,            "The ME supports SoLSA"},
956         { 0,    NULL }
957 };
958 /* CMSP: CM Service Prompt (octet 5, bit 3) */
959 static const value_string CMSP_vals[] = {
960         { 0,            "Network initiated MO CM connection request not supported"},
961         { 1,            "Network initiated MO CM connection request supported for at least one CM protocol"},
962         { 0,    NULL }
963 };
964 /* A5/3 algorithm supported (octet 5, bit 2) */
965 static const value_string A5_3_algorithm_sup_vals[] = {
966         { 0,            "encryption algorithm A5/3 not available"},
967         { 1,            "encryption algorithm A5/3 available"},
968         { 0,    NULL }
969 };
970
971 /* A5/2 algorithm supported (octet 5, bit 1) */
972 static const value_string A5_2_algorithm_sup_vals[] = {
973         { 0,            "encryption algorithm A5/2 not available"},
974         { 1,            "encryption algorithm A5/2 available"},
975         { 0,    NULL }
976 };
977
978  static const value_string gsm_a_algorithm_identifier_vals[] = {
979         { 0,            "Cipher with algorithm A5/1"},
980         { 1,            "Cipher with algorithm A5/2"},
981         { 2,            "Cipher with algorithm A5/3"},
982         { 3,            "Cipher with algorithm A5/4"},
983         { 4,            "Cipher with algorithm A5/5"},
984         { 5,            "Cipher with algorithm A5/6"},
985         { 6,            "Cipher with algorithm A5/7"},
986         { 7,            "Reserved"},
987         { 0,    NULL }
988 };
989
990  static const value_string mobile_identity_type_vals[] = {
991         { 1,            "IMSI"},
992         { 2,            "IMEI"},
993         { 3,            "IMEISV"},
994         { 4,            "TMSI/P-TMSI"},
995         { 5,            "TMGI and optional MBMS Session Identity"}, /* ETSI TS 124 008 V6.8.0 (2005-03) p326 */
996         { 0,            "No Identity"},
997         { 0,    NULL }
998 };
999
1000 static const value_string oddevenind_vals[] = {
1001         { 0,            "Even number of identity digits"},
1002         { 1,            "Odd number of identity digits"},
1003         { 0,    NULL }
1004 };
1005
1006 /* RR cause value (octet 2) TS 44.018 6.11.0*/
1007 static const value_string gsm_a_rr_RR_cause_vals[] = {
1008         { 0,            "Normal event"},
1009         { 1,            "Abnormal release, unspecified"},
1010         { 2,            "Abnormal release, channel unacceptable"},
1011         { 3,            "Abnormal release, timer expired"},
1012         { 4,            "Abnormal release, no activity on the radio path"},
1013         { 5,            "Preemptive release"},
1014         { 6,            "UTRAN configuration unknown"},
1015         { 8,            "Handover impossible, timing advance out of range"},
1016         { 9,            "Channel mode unacceptable"},
1017         { 10,           "Frequency not implemented"},
1018         { 13,           "Originator or talker leaving group call area"},
1019         { 12,           "Lower layer failure"},
1020         { 0x41,         "Call already cleared"},
1021         { 0x5f,         "Semantically incorrect message"},
1022         { 0x60,         "Invalid mandatory information"},
1023         { 0x61,         "Message type non-existent or not implemented"},
1024         { 0x62,         "Message type not compatible with protocol state"},
1025         { 0x64,         "Conditional IE error"},
1026         { 0x65,         "No cell allocation available"},
1027         { 0x6f,         "Protocol error unspecified"},
1028         { 0,    NULL }
1029 };
1030 /* Cell identification discriminator */
1031 static const value_string gsm_a_rr_cell_id_disc_vals[] = {
1032         { 0,            "The whole Cell Global Identification, CGI, is used to identify the cells."},
1033         { 1,            "Location Area Code, LAC, and Cell Identify, CI, is used to identify the cells."},
1034         { 2,            "Cell Identity, CI, is used to identify the cells."},
1035         { 3,            "No cell is associated with the transaction."},
1036         { 4,            "Location Area Identification, LAI, is used to identify all cells within a Location Area."},
1037         { 5,            "Location Area Code, LAC, is used to identify all cells within a location area."},
1038         { 6,            "All cells on the BSS are identified."},
1039         { 8,            "Intersystem Handover to UTRAN or cdma2000. PLMN-ID, LAC, and RNC-ID, are encoded to identify the target RNC."},
1040         { 9,            "Intersystem Handover to UTRAN or cdma2000. The RNC-ID is coded to identify the target RNC."},
1041         { 10,           "Intersystem Handover to UTRAN or cdma2000. LAC and RNC-ID are encoded to identify the target RNC."},
1042         { 0,    NULL }
1043 };
1044
1045
1046 #define DTAP_PD_MASK            0x0f
1047 #define DTAP_SKIP_MASK          0xf0
1048 #define DTAP_TI_MASK            DTAP_SKIP_MASK
1049 #define DTAP_TIE_PRES_MASK      0x07                    /* after TI shifted to right */
1050 #define DTAP_TIE_MASK           0x7f
1051
1052 #define DTAP_MM_IEI_MASK        0x3f
1053 #define DTAP_RR_IEI_MASK        0xff
1054 #define DTAP_CC_IEI_MASK        0x3f
1055 #define DTAP_GMM_IEI_MASK       0xff
1056 #define DTAP_SMS_IEI_MASK       0xff
1057 #define DTAP_SM_IEI_MASK        0xff
1058 #define DTAP_SS_IEI_MASK        0x3f
1059
1060 /* Initialize the protocol and registered fields */
1061 static int proto_a_bssmap = -1;
1062 static int proto_a_dtap = -1;
1063 static int proto_a_rp = -1;
1064
1065 static int gsm_a_tap = -1;
1066
1067 static int hf_gsm_a_none = -1;
1068 static int hf_gsm_a_bssmap_msg_type = -1;
1069 static int hf_gsm_a_dtap_msg_mm_type = -1;
1070 static int hf_gsm_a_dtap_msg_rr_type = -1;
1071 static int hf_gsm_a_dtap_msg_cc_type = -1;
1072 static int hf_gsm_a_dtap_msg_gmm_type = -1;
1073 static int hf_gsm_a_dtap_msg_sms_type = -1;
1074 static int hf_gsm_a_dtap_msg_sm_type = -1;
1075 static int hf_gsm_a_dtap_msg_ss_type = -1;
1076 static int hf_gsm_a_rp_msg_type = -1;
1077 static int hf_gsm_a_length = -1;
1078 static int hf_gsm_a_bssmap_elem_id = -1;
1079 static int hf_gsm_a_dtap_elem_id = -1;
1080 static int hf_gsm_a_imsi = -1;
1081 static int hf_gsm_a_tmsi = -1;
1082 static int hf_gsm_a_imei = -1;
1083 static int hf_gsm_a_imeisv = -1;
1084 static int hf_gsm_a_cld_party_bcd_num = -1;
1085 static int hf_gsm_a_clg_party_bcd_num = -1;
1086 static int hf_gsm_a_cell_ci = -1;
1087 static int hf_gsm_a_cell_lac = -1;
1088 static int hf_gsm_a_dlci_cc = -1;
1089 static int hf_gsm_a_dlci_spare = -1;
1090 static int hf_gsm_a_dlci_sapi = -1;
1091 static int hf_gsm_a_bssmap_cause = -1;
1092 static int hf_gsm_a_dtap_cause = -1;
1093
1094 static int hf_gsm_a_MSC_rev = -1;
1095 static int hf_gsm_a_ES_IND                      = -1;
1096 static int hf_gsm_a_qos_traffic_cls = -1;
1097 static int hf_gsm_a_qos_del_order = -1;
1098 static int hf_gsm_a_qos_del_of_err_sdu = -1;
1099 static int hf_gsm_a_qos_ber = -1;
1100 static int hf_gsm_a_qos_sdu_err_rat = -1;
1101 static int hf_gsm_a_qos_traff_hdl_pri = -1;
1102 static int hf_gsm_a_A5_1_algorithm_sup = -1;
1103 static int hf_gsm_a_RF_power_capability = -1;
1104 static int hf_gsm_a_ps_sup_cap          = -1;
1105 static int hf_gsm_a_SS_screening_indicator = -1;
1106 static int hf_gsm_a_SM_capability                = -1;
1107 static int hf_gsm_a_VBS_notification_rec = -1;
1108 static int hf_gsm_a_VGCS_notification_rec = -1;
1109 static int hf_gsm_a_FC_frequency_cap    = -1;
1110 static int hf_gsm_a_CM3                         = -1;
1111 static int hf_gsm_a_LCS_VA_cap          = -1;
1112 static int hf_gsm_a_UCS2_treatment      = -1;
1113 static int hf_gsm_a_SoLSA                               = -1;
1114 static int hf_gsm_a_CMSP                                = -1;
1115 static int hf_gsm_a_A5_3_algorithm_sup= -1;
1116 static int hf_gsm_a_A5_2_algorithm_sup = -1;
1117
1118 static int hf_gsm_a_odd_even_ind = -1;
1119 static int hf_gsm_a_mobile_identity_type = -1;
1120 static int hf_gsm_a_L3_protocol_discriminator = -1; 
1121 static int hf_gsm_a_skip_ind = -1; 
1122
1123 static int hf_gsm_a_bcc                         = -1;
1124 static int hf_gsm_a_ncc                         = -1;
1125 static int hf_gsm_a_bcch_arfcn          = -1;
1126 static int hf_gsm_a_rr_ho_ref_val = -1;
1127 static int hf_gsm_a_b7spare = -1;
1128 static int hf_gsm_a_b8spare = -1;
1129 static int hf_gsm_a_rr_pow_cmd_atc = -1;
1130 static int hf_gsm_a_rr_pow_cmd_epc = -1;
1131 static int hf_gsm_a_rr_pow_cmd_fpcepc = -1;
1132 static int hf_gsm_a_rr_pow_cmd_powlev = -1;
1133 static int hf_gsm_a_rr_sync_ind_nci = -1;
1134 static int hf_gsm_a_rr_sync_ind_rot = -1;
1135 static int hf_gsm_a_rr_sync_ind_si = -1;
1136 static int hf_gsm_a_rr_format_id = -1;
1137 static int hf_gsm_a_rr_channel_mode = -1;
1138 static int hf_gsm_a_rr_channel_mode2 = -1;
1139 static int hf_gsm_a_rr_sc = -1;
1140 static int hf_gsm_a_algorithm_id = -1;
1141 static int hf_gsm_a_rr_multirate_speech_ver = -1;
1142 static int hf_gsm_a_rr_NCSB                             = -1;
1143 static int hf_gsm_a_rr_ICMI                             = -1;
1144 static int hf_gsm_a_rr_start_mode               = -1;
1145 static int hf_gsm_a_rr_timing_adv = -1;
1146 static int hf_gsm_a_rr_time_diff = -1;
1147 static int hf_gsm_a_rr_tlli = -1;
1148 static int hf_gsm_a_rr_target_mode = -1;
1149 static int hf_gsm_a_rr_group_cipher_key_number = -1;
1150 static int hf_gsm_a_rr_last_segment = -1;
1151 static int hf_gsm_a_gmm_split_on_ccch = -1;
1152 static int hf_gsm_a_gmm_non_drx_timer = -1;
1153 static int hf_gsm_a_gmm_cn_spec_drs_cycle_len_coef = -1;
1154 static int hf_gsm_a_rr_RR_cause = -1;
1155 static int hf_gsm_a_be_cell_id_disc = -1;
1156 static int hf_gsm_a_be_rnc_id = -1;
1157 static int hf_gsm_a_rr_cm_cng_msg_req = -1;
1158 static int hf_gsm_a_rr_utran_cm_cng_msg_req = -1;
1159 static int hf_gsm_a_rr_cdma200_cm_cng_msg_req = -1;
1160 static int hf_gsm_a_rr_geran_iu_cm_cng_msg_req = -1;
1161 static int hf_gsm_a_rr_chnl_needed_ch1 = -1;
1162 static int hf_gsm_a_rr_chnl_needed_ch2 = -1;
1163 static int hf_gsm_a_rr_suspension_cause = -1;
1164 static int hf_gsm_a_rr_set_of_amr_codec_modes_v1_b8 = -1;
1165 static int hf_gsm_a_rr_set_of_amr_codec_modes_v1_b7 = -1;
1166 static int hf_gsm_a_rr_set_of_amr_codec_modes_v1_b6 = -1;
1167 static int hf_gsm_a_rr_set_of_amr_codec_modes_v1_b5 = -1;
1168 static int hf_gsm_a_rr_set_of_amr_codec_modes_v1_b4 = -1;
1169 static int hf_gsm_a_rr_set_of_amr_codec_modes_v1_b3 = -1;
1170 static int hf_gsm_a_rr_set_of_amr_codec_modes_v1_b2 = -1;
1171 static int hf_gsm_a_rr_set_of_amr_codec_modes_v1_b1 = -1;
1172 static int hf_gsm_a_rr_set_of_amr_codec_modes_v2_b5 = -1;
1173 static int hf_gsm_a_rr_set_of_amr_codec_modes_v2_b4 = -1;
1174 static int hf_gsm_a_rr_set_of_amr_codec_modes_v2_b3 = -1;
1175 static int hf_gsm_a_rr_set_of_amr_codec_modes_v2_b2 = -1;
1176 static int hf_gsm_a_rr_set_of_amr_codec_modes_v2_b1 = -1;
1177
1178 static int hf_gsm_a_extension = -1;
1179 static int hf_gsm_a_type_of_number = -1;
1180 static int hf_gsm_a_numbering_plan_id = -1;
1181
1182 static int hf_gsm_a_ptmsi_sig =-1;
1183 static int hf_gsm_a_ptmsi_sig2 =-1;
1184
1185 static int hf_gsm_a_tft_op_code = -1;
1186 static int hf_gsm_a_tft_e_bit = -1;
1187 static int hf_gsm_a_tft_pkt_flt = -1;
1188 static int hf_gsm_a_tft_ip4_address = -1;
1189 static int hf_gsm_a_tft_ip4_mask = -1;
1190 static int hf_gsm_a_tft_ip6_address = -1;
1191 static int hf_gsm_a_tft_ip6_mask = -1;
1192 static int hf_gsm_a_tft_protocol_header = -1;
1193 static int hf_gsm_a_tft_port = -1;
1194 static int hf_gsm_a_tft_port_low = -1;
1195 static int hf_gsm_a_tft_port_high = -1;
1196 static int hf_gsm_a_tft_security = -1;
1197 static int hf_gsm_a_tft_traffic_mask = -1;
1198 static int hf_gsm_a_tft_flow = -1;
1199
1200 static int hf_gsm_a_apdu_protocol_id = -1;
1201 static int hf_gsm_a_lsa_id = -1;
1202
1203 /* Initialize the subtree pointers */
1204 static gint ett_bssmap_msg = -1;
1205 static gint ett_dtap_msg = -1;
1206 static gint ett_rp_msg = -1;
1207 static gint ett_elems = -1;
1208 static gint ett_elem = -1;
1209 static gint ett_dtap_oct_1 = -1;
1210 static gint ett_cm_srvc_type = -1;
1211 static gint ett_gsm_enc_info = -1;
1212 static gint ett_cell_list = -1;
1213 static gint ett_dlci = -1;
1214 static gint ett_bc_oct_3a = -1;
1215 static gint ett_bc_oct_4 = -1;
1216 static gint ett_bc_oct_5 = -1;
1217 static gint ett_bc_oct_5a = -1;
1218 static gint ett_bc_oct_5b = -1;
1219 static gint ett_bc_oct_6 = -1;
1220 static gint ett_bc_oct_6a = -1;
1221 static gint ett_bc_oct_6b = -1;
1222 static gint ett_bc_oct_6c = -1;
1223 static gint ett_bc_oct_6d = -1;
1224 static gint ett_bc_oct_6e = -1;
1225 static gint ett_bc_oct_6f = -1;
1226 static gint ett_bc_oct_6g = -1;
1227 static gint ett_bc_oct_7 = -1;
1228
1229 static gint ett_tc_component = -1;
1230 static gint ett_tc_invoke_id = -1;
1231 static gint ett_tc_linked_id = -1;
1232 static gint ett_tc_opr_code = -1;
1233 static gint ett_tc_err_code = -1;
1234 static gint ett_tc_prob_code = -1;
1235 static gint ett_tc_sequence = -1;
1236
1237 static gint ett_gmm_drx = -1;
1238 static gint ett_gmm_detach_type = -1;
1239 static gint ett_gmm_attach_type = -1;
1240 static gint ett_gmm_context_stat = -1;
1241 static gint ett_gmm_update_type = -1;
1242 static gint ett_gmm_radio_cap = -1;
1243
1244
1245 static gint ett_sm_tft = -1;
1246
1247 static char a_bigbuf[1024];
1248
1249 static dissector_handle_t data_handle;
1250 static dissector_handle_t gsm_map_handle;
1251 static dissector_handle_t bssmap_handle;
1252 static dissector_handle_t dtap_handle;
1253 static dissector_handle_t rp_handle;
1254 static dissector_table_t sms_dissector_table;   /* SMS TPDU */
1255 static dissector_table_t gprs_sm_pco_subdissector_table; /* GPRS SM PCO PPP Protocols */
1256
1257 static packet_info *g_pinfo;
1258 static proto_tree *g_tree;
1259 static gint comp_type_tag;
1260
1261 static sccp_msg_info_t* sccp_msg;
1262 static sccp_assoc_info_t* sccp_assoc;
1263
1264 /*
1265  * this should be set on a per message basis, if possible
1266  */
1267 #define IS_UPLINK_FALSE         0
1268 #define IS_UPLINK_TRUE          1
1269 #define IS_UPLINK_UNKNOWN       2
1270 static gint is_uplink;
1271
1272
1273 typedef struct dgt_set_t
1274 {
1275     unsigned char out[15];
1276 }
1277 dgt_set_t;
1278
1279 static dgt_set_t Dgt_mbcd = {
1280     {
1281   /*  0   1   2   3   4   5   6   7   8   9   a   b   c   d   e */
1282      '0','1','2','3','4','5','6','7','8','9','*','#','a','b','c'
1283     }
1284 };
1285
1286 static dgt_set_t Dgt_tbcd = {
1287     {
1288   /*  0   1   2   3   4   5   6   7   8   9   a   b   c   d   e */
1289      '0','1','2','3','4','5','6','7','8','9','?','B','C','*','#'
1290     }
1291 };
1292
1293 static dgt_set_t Dgt1_9_bcd = {
1294     {
1295   /*  0   1   2   3   4   5   6   7   8   9   a   b   c   d   e */
1296      '0','1','2','3','4','5','6','7','8','9','?','?','?','?','?'
1297     }
1298 };
1299
1300 /* FUNCTIONS */
1301
1302 /*
1303  * Unpack BCD input pattern into output ASCII pattern
1304  *
1305  * Input Pattern is supplied using the same format as the digits
1306  *
1307  * Returns: length of unpacked pattern
1308  */
1309 static int
1310 my_dgt_tbcd_unpack(
1311     char        *out,           /* ASCII pattern out */
1312     guchar      *in,            /* packed pattern in */
1313     int         num_octs,       /* Number of octets to unpack */
1314     dgt_set_t   *dgt            /* Digit definitions */
1315     )
1316 {
1317     int cnt = 0;
1318     unsigned char i;
1319
1320     while (num_octs)
1321     {
1322         /*
1323          * unpack first value in byte
1324          */
1325         i = *in++;
1326         *out++ = dgt->out[i & 0x0f];
1327         cnt++;
1328
1329         /*
1330          * unpack second value in byte
1331          */
1332         i >>= 4;
1333
1334         if (i == 0x0f)  /* odd number bytes - hit filler */
1335             break;
1336
1337         *out++ = dgt->out[i];
1338         cnt++;
1339         num_octs--;
1340     }
1341
1342     *out = '\0';
1343
1344     return(cnt);
1345 }
1346
1347
1348 /* ELEMENT FUNCTIONS */
1349
1350 #define EXTRANEOUS_DATA_CHECK(edc_len, edc_max_len) \
1351     if ((edc_len) > (edc_max_len)) \
1352     { \
1353         proto_tree_add_text(tree, tvb, \
1354             curr_offset, (edc_len) - (edc_max_len), "Extraneous Data"); \
1355         curr_offset += ((edc_len) - (edc_max_len)); \
1356     }
1357
1358 #define SHORT_DATA_CHECK(sdc_len, sdc_min_len) \
1359     if ((sdc_len) < (sdc_min_len)) \
1360     { \
1361         proto_tree_add_text(tree, tvb, \
1362             curr_offset, (sdc_len), "Short Data (?)"); \
1363         curr_offset += (sdc_len); \
1364         return(curr_offset - offset); \
1365     }
1366
1367 #define EXACT_DATA_CHECK(edc_len, edc_eq_len) \
1368     if ((edc_len) != (edc_eq_len)) \
1369     { \
1370         proto_tree_add_text(tree, tvb, \
1371             curr_offset, (edc_len), "Unexpected Data Length"); \
1372         curr_offset += (edc_len); \
1373         return(curr_offset - offset); \
1374     }
1375
1376 #define NO_MORE_DATA_CHECK(nmdc_len) \
1377     if ((nmdc_len) == (curr_offset - offset)) return(nmdc_len);
1378
1379 /*
1380  * Decode the MCC/MNC from 3 octets in 'octs'
1381  */
1382 static void
1383 mcc_mnc_aux(guint8 *octs, gchar *mcc, gchar *mnc)
1384 {
1385     if ((octs[0] & 0x0f) <= 9)
1386     {
1387         mcc[0] = Dgt_tbcd.out[octs[0] & 0x0f];
1388     }
1389     else
1390     {
1391         mcc[0] = (octs[0] & 0x0f) + 55;
1392     }
1393
1394     if (((octs[0] & 0xf0) >> 4) <= 9)
1395     {
1396         mcc[1] = Dgt_tbcd.out[(octs[0] & 0xf0) >> 4];
1397     }
1398     else
1399     {
1400         mcc[1] = ((octs[0] & 0xf0) >> 4) + 55;
1401     }
1402
1403     if ((octs[1] & 0x0f) <= 9)
1404     {
1405         mcc[2] = Dgt_tbcd.out[octs[1] & 0x0f];
1406     }
1407     else
1408     {
1409         mcc[2] = (octs[1] & 0x0f) + 55;
1410     }
1411
1412     mcc[3] = '\0';
1413
1414     if (((octs[1] & 0xf0) >> 4) <= 9)
1415     {
1416         mnc[2] = Dgt_tbcd.out[(octs[1] & 0xf0) >> 4];
1417     }
1418     else
1419     {
1420         mnc[2] = ((octs[1] & 0xf0) >> 4) + 55;
1421     }
1422
1423     if ((octs[2] & 0x0f) <= 9)
1424     {
1425         mnc[0] = Dgt_tbcd.out[octs[2] & 0x0f];
1426     }
1427     else
1428     {
1429         mnc[0] = (octs[2] & 0x0f) + 55;
1430     }
1431
1432     if (((octs[2] & 0xf0) >> 4) <= 9)
1433     {
1434         mnc[1] = Dgt_tbcd.out[(octs[2] & 0xf0) >> 4];
1435     }
1436     else
1437     {
1438         mnc[1] = ((octs[2] & 0xf0) >> 4) + 55;
1439     }
1440
1441     if (mnc[1] == 'F')
1442     {
1443         /*
1444          * only a 1 digit MNC (very old)
1445          */
1446         mnc[1] = '\0';
1447     }
1448     else if (mnc[2] == 'F')
1449     {
1450         /*
1451          * only a 2 digit MNC
1452          */
1453         mnc[2] = '\0';
1454     }
1455     else
1456     {
1457         mnc[3] = '\0';
1458     }
1459 }
1460
1461 typedef enum
1462 {
1463     BE_CIC,      /* Circuit Identity Code */
1464     BE_RSVD_1,   /* Reserved */
1465     BE_RES_AVAIL,        /* Resource Available */
1466     BE_CAUSE,    /* Cause */
1467     BE_CELL_ID,  /* Cell Identifier */
1468     BE_PRIO,     /* Priority */
1469     BE_L3_HEADER_INFO,   /* Layer 3 Header Information */
1470     BE_IMSI,     /* IMSI */
1471     BE_TMSI,     /* TMSI */
1472     BE_ENC_INFO,         /* Encryption Information */
1473     BE_CHAN_TYPE,        /* Channel Type */
1474     BE_PERIODICITY,      /* Periodicity */
1475     BE_EXT_RES_IND,      /* Extended Resource Indicator */
1476     BE_NUM_MS,   /* Number Of MSs */
1477     BE_RSVD_2,   /* Reserved */
1478     BE_RSVD_3,   /* Reserved */
1479     BE_RSVD_4,   /* Reserved */
1480     BE_CM_INFO_2,        /* Classmark Information Type 2 */
1481     BE_CM_INFO_3,        /* Classmark Information Type 3 */
1482     BE_INT_BAND,         /* Interference Band To Be Used */
1483     BE_RR_CAUSE,         /* RR Cause */
1484     BE_RSVD_5,   /* Reserved */
1485     BE_L3_INFO,  /* Layer 3 Information */
1486     BE_DLCI,     /* DLCI */
1487     BE_DOWN_DTX_FLAG,    /* Downlink DTX Flag */
1488     BE_CELL_ID_LIST,     /* Cell Identifier List */
1489     BE_RESP_REQ,         /* Response Request */
1490     BE_RES_IND_METHOD,   /* Resource Indication Method */
1491     BE_CM_INFO_1,        /* Classmark Information Type 1 */
1492     BE_CIC_LIST,         /* Circuit Identity Code List */
1493     BE_DIAG,     /* Diagnostic */
1494     BE_L3_MSG,   /* Layer 3 Message Contents */
1495     BE_CHOSEN_CHAN,      /* Chosen Channel */
1496     BE_TOT_RES_ACC,      /* Total Resource Accessible */
1497     BE_CIPH_RESP_MODE,   /* Cipher Response Mode */
1498     BE_CHAN_NEEDED,      /* Channel Needed */
1499     BE_TRACE_TYPE,       /* Trace Type */
1500     BE_TRIGGERID,        /* TriggerID */
1501     BE_TRACE_REF,        /* Trace Reference */
1502     BE_TRANSID,  /* TransactionID */
1503     BE_MID,      /* Mobile Identity */
1504     BE_OMCID,    /* OMCID */
1505     BE_FOR_IND,  /* Forward Indicator */
1506     BE_CHOSEN_ENC_ALG,   /* Chosen Encryption Algorithm */
1507     BE_CCT_POOL,         /* Circuit Pool */
1508     BE_CCT_POOL_LIST,    /* Circuit Pool List */
1509     BE_TIME_IND,         /* Time Indication */
1510     BE_RES_SIT,  /* Resource Situation */
1511     BE_CURR_CHAN_1,      /* Current Channel Type 1 */
1512     BE_QUE_IND,  /* Queueing Indicator */
1513     BE_SPEECH_VER,       /* Speech Version */
1514     BE_ASS_REQ,  /* Assignment Requirement */
1515     BE_TALKER_FLAG,      /* Talker Flag */
1516     BE_CONN_REL_REQ,     /* Connection Release Requested */
1517     BE_GROUP_CALL_REF,   /* Group Call Reference */
1518     BE_EMLPP_PRIO,       /* eMLPP Priority */
1519     BE_CONF_EVO_IND,     /* Configuration Evolution Indication */
1520     BE_OLD2NEW_INFO,     /* Old BSS to New BSS Information */
1521     BE_LSA_ID,   /* LSA Identifier */
1522     BE_LSA_ID_LIST,      /* LSA Identifier List */
1523     BE_LSA_INFO,         /* LSA Information */
1524     BE_LCS_QOS,  /* LCS QoS */
1525     BE_LSA_ACC_CTRL,     /* LSA access control suppression */
1526     BE_LCS_PRIO,         /* LCS Priority */
1527     BE_LOC_TYPE,         /* Location Type */
1528     BE_LOC_EST,  /* Location Estimate */
1529     BE_POS_DATA,         /* Positioning Data */
1530     BE_LCS_CAUSE,        /* LCS Cause */
1531     BE_LCS_CLIENT,       /* LCS Client Type */
1532     BE_APDU,     /* APDU */
1533     BE_NE_ID,    /* Network Element Identity */
1534     BE_GSP_ASSIST_DATA,  /* GPS Assistance Data */
1535     BE_DECIPH_KEYS,      /* Deciphering Keys */
1536     BE_RET_ERR_REQ,      /* Return Error Request */
1537     BE_RET_ERR_CAUSE,    /* Return Error Cause */
1538     BE_SEG,      /* Segmentation */
1539     BE_NONE     /* NONE */
1540 }
1541 bssmap_elem_idx_t;
1542
1543 #define NUM_GSM_BSSMAP_ELEM (sizeof(gsm_bssmap_elem_strings)/sizeof(value_string))
1544 static gint ett_gsm_bssmap_elem[NUM_GSM_BSSMAP_ELEM];
1545
1546 /*
1547  * [2] 3.2.2.2
1548  */
1549 static guint8
1550 be_cic(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
1551 {
1552     guint32     curr_offset;
1553     guint32     value;
1554
1555     len = len;
1556     curr_offset = offset;
1557
1558     value = tvb_get_ntohs(tvb, curr_offset);
1559
1560     other_decode_bitfield_value(a_bigbuf, value, 0xffe0, 16);
1561     proto_tree_add_text(tree,
1562         tvb, curr_offset, 2,
1563         "%s :  PCM Multiplexer: %u",
1564         a_bigbuf,
1565         (value & 0xffe0) >> 5);
1566
1567     other_decode_bitfield_value(a_bigbuf, value, 0x001f, 16);
1568     proto_tree_add_text(tree,
1569         tvb, curr_offset, 2,
1570         "%s :  Timeslot: %u",
1571         a_bigbuf,
1572         value & 0x001f);
1573
1574     curr_offset += 2;
1575
1576     if (add_string)
1577         g_snprintf(add_string, string_len, " - (%u) (0x%04x)", value, value);
1578
1579     /* no length check possible */
1580
1581     return(curr_offset - offset);
1582 }
1583
1584 /*
1585  * [2] 3.2.2.5
1586  */
1587 static guint8
1588 be_cause(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
1589 {
1590     guint8      oct;
1591     guint32     value;
1592     guint32     curr_offset;
1593     const gchar *str = NULL;
1594
1595     curr_offset = offset;
1596
1597     oct = tvb_get_guint8(tvb, curr_offset);
1598
1599     other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
1600     proto_tree_add_text(tree,
1601         tvb, curr_offset, 1,
1602         "%s :  Extension: %s",
1603         a_bigbuf,
1604         (oct & 0x80) ? "extended" : "not extended");
1605
1606     if (oct & 0x80)
1607     {
1608         /* 2 octet cause */
1609
1610         if ((oct & 0x0f) == 0x00)
1611         {
1612             /* national cause */
1613             switch ((oct & 0x70) >> 4)
1614             {
1615             case 0: str = "Normal Event"; break;
1616             case 1: str = "Normal Event"; break;
1617             case 2: str = "Resource Unavailable"; break;
1618             case 3: str = "Service or option not available"; break;
1619             case 4: str = "Service or option not implemented"; break;
1620             case 5: str = "Invalid message (e.g., parameter out of range)"; break;
1621             case 6: str = "Protocol error"; break;
1622             default:
1623                 str = "Interworking";
1624                 break;
1625             }
1626
1627             other_decode_bitfield_value(a_bigbuf, oct, 0x70, 8);
1628             proto_tree_add_text(tree,
1629                 tvb, curr_offset, 1,
1630                 "%s :  Cause Class: %s",
1631                 a_bigbuf,
1632                 str);
1633
1634             other_decode_bitfield_value(a_bigbuf, oct, 0x0f, 8);
1635             proto_tree_add_text(tree,
1636                 tvb, curr_offset, 1,
1637                 "%s :  National Cause",
1638                 a_bigbuf);
1639
1640             curr_offset++;
1641
1642             proto_tree_add_text(tree, tvb, curr_offset, 1,
1643                 "Cause Value");
1644
1645             curr_offset++;
1646
1647             if (add_string)
1648                 g_snprintf(add_string, string_len, " - (National Cause)");
1649         }
1650         else
1651         {
1652             value = tvb_get_guint8(tvb, curr_offset + 1);
1653
1654             other_decode_bitfield_value(a_bigbuf, oct, 0x7f, 8);
1655             proto_tree_add_text(tree,
1656                 tvb, curr_offset, 1,
1657                 "%s :  Cause (MSB): %u",
1658                 a_bigbuf,
1659                 ((oct & 0x7f) << 8) | value);
1660
1661             curr_offset++;
1662
1663             other_decode_bitfield_value(a_bigbuf, value, 0xff, 8);
1664             proto_tree_add_text(tree, tvb, curr_offset, 1,
1665                 "%s :  Cause (LSB)",
1666                 a_bigbuf);
1667
1668             curr_offset++;
1669         }
1670     }
1671     else
1672     {
1673         switch (oct)
1674         {
1675         case 0x00: str = "Radio interface message failure"; break;
1676         case 0x01: str = "Radio interface failure"; break;
1677         case 0x02: str = "Uplink quality"; break;
1678         case 0x03: str = "Uplink strength"; break;
1679         case 0x04: str = "Downlink quality"; break;
1680         case 0x05: str = "Downlink strength"; break;
1681         case 0x06: str = "Distance"; break;
1682         case 0x07: str = "O and M intervention"; break;
1683         case 0x08: str = "Response to MSC invocation"; break;
1684         case 0x09: str = "Call control"; break;
1685         case 0x0a: str = "Radio interface failure, reversion to old channel"; break;
1686         case 0x0b: str = "Handover successful"; break;
1687         case 0x0c: str = "Better Cell"; break;
1688         case 0x0d: str = "Directed Retry"; break;
1689         case 0x0e: str = "Joined group call channel"; break;
1690         case 0x0f: str = "Traffic"; break;
1691
1692         case 0x20: str = "Equipment failure"; break;
1693         case 0x21: str = "No radio resource available"; break;
1694         case 0x22: str = "Requested terrestrial resource unavailable"; break;
1695         case 0x23: str = "CCCH overload"; break;
1696         case 0x24: str = "Processor overload"; break;
1697         case 0x25: str = "BSS not equipped"; break;
1698         case 0x26: str = "MS not equipped"; break;
1699         case 0x27: str = "Invalid cell"; break;
1700         case 0x28: str = "Traffic Load"; break;
1701         case 0x29: str = "Preemption"; break;
1702
1703         case 0x30: str = "Requested transcoding/rate adaption unavailable"; break;
1704         case 0x31: str = "Circuit pool mismatch"; break;
1705         case 0x32: str = "Switch circuit pool"; break;
1706         case 0x33: str = "Requested speech version unavailable"; break;
1707         case 0x34: str = "LSA not allowed"; break;
1708
1709         case 0x40: str = "Ciphering algorithm not supported"; break;
1710
1711         case 0x50: str = "Terrestrial circuit already allocated"; break;
1712         case 0x51: str = "Invalid message contents"; break;
1713         case 0x52: str = "Information element or field missing"; break;
1714         case 0x53: str = "Incorrect value"; break;
1715         case 0x54: str = "Unknown Message type"; break;
1716         case 0x55: str = "Unknown Information Element"; break;
1717
1718         case 0x60: str = "Protocol Error between BSS and MSC"; break;
1719         case 0x61: str = "VGCS/VBS call non existent"; break;
1720
1721         default:
1722             if ((oct >= 0x10) && (oct <= 0x17)) { str = "Reserved for international use"; }
1723             else if ((oct >= 0x18) && (oct <= 0x1f)) { str = "Reserved for national use"; }
1724             else if ((oct >= 0x2a) && (oct <= 0x2f)) { str = "Reserved for national use"; }
1725             else if ((oct >= 0x35) && (oct <= 0x3f)) { str = "Reserved for international use"; }
1726             else if ((oct >= 0x41) && (oct <= 0x47)) { str = "Reserved for international use"; }
1727             else if ((oct >= 0x48) && (oct <= 0x4f)) { str = "Reserved for national use"; }
1728             else if ((oct >= 0x56) && (oct <= 0x57)) { str = "Reserved for international use"; }
1729             else if ((oct >= 0x58) && (oct <= 0x5f)) { str = "Reserved for national use"; }
1730             else if ((oct >= 0x62) && (oct <= 0x67)) { str = "Reserved for international use"; }
1731             else if ((oct >= 0x68) && (oct <= 0x6f)) { str = "Reserved for national use"; }
1732             else if ((oct >= 0x70) && (oct <= 0x77)) { str = "Reserved for international use"; }
1733             else if ((oct >= 0x78) && (oct <= 0x7f)) { str = "Reserved for national use"; }
1734             break;
1735         }
1736
1737         other_decode_bitfield_value(a_bigbuf, oct, 0x7f, 8);
1738         proto_tree_add_uint_format(tree, hf_gsm_a_bssmap_cause,
1739             tvb, curr_offset, 1, oct & 0x7f,
1740             "%s :  Cause: (%u) %s",
1741             a_bigbuf,
1742             oct & 0x7f,
1743             str);
1744
1745         curr_offset++;
1746
1747         if (add_string)
1748             g_snprintf(add_string, string_len, " - (%u) %s", oct & 0x7f, str);
1749     }
1750
1751     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
1752
1753     return(curr_offset - offset);
1754 }
1755
1756 /*
1757  * [2] 3.2.2.7
1758  */
1759 static guint8
1760 be_tmsi(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
1761 {
1762     guint32     curr_offset;
1763     guint32     value;
1764
1765     curr_offset = offset;
1766
1767     value = tvb_get_ntohl(tvb, curr_offset);
1768
1769     proto_tree_add_uint(tree, hf_gsm_a_tmsi,
1770         tvb, curr_offset, 4,
1771         value);
1772
1773     if (add_string)
1774         g_snprintf(add_string, string_len, " - (0x%04x)", value);
1775
1776     curr_offset += 4;
1777
1778     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
1779
1780     return(curr_offset - offset);
1781 }
1782
1783 /*
1784  * [2] 3.2.2.9
1785  */
1786 static guint8
1787 be_l3_header_info(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
1788 {
1789     guint8      oct;
1790     guint32     curr_offset;
1791
1792     curr_offset = offset;
1793
1794     oct = tvb_get_guint8(tvb, curr_offset);
1795
1796     other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
1797     proto_tree_add_text(tree,
1798         tvb, curr_offset, 1,
1799         "%s :  Spare",
1800         a_bigbuf);
1801
1802         proto_tree_add_item(tree, hf_gsm_a_L3_protocol_discriminator, tvb, curr_offset, 1, FALSE);
1803
1804
1805     curr_offset++;
1806
1807     NO_MORE_DATA_CHECK(len);
1808
1809     oct = tvb_get_guint8(tvb, curr_offset);
1810
1811     other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
1812     proto_tree_add_text(tree,
1813         tvb, curr_offset, 1,
1814         "%s :  Spare",
1815         a_bigbuf);
1816
1817     other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
1818     proto_tree_add_text(tree,
1819         tvb, curr_offset, 1,
1820         "%s :  TI flag: %s",
1821         a_bigbuf,
1822         ((oct & 0x08) ?  "allocated by receiver" : "allocated by sender"));
1823
1824     other_decode_bitfield_value(a_bigbuf, oct, 0x07, 8);
1825     proto_tree_add_text(tree,
1826         tvb, curr_offset, 1,
1827         "%s :  TIO: %u",
1828         a_bigbuf,
1829         oct & 0x07);
1830
1831     curr_offset++;
1832
1833     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
1834
1835     return(curr_offset - offset);
1836 }
1837
1838 /*
1839  * [2] 3.2.2.10
1840  */
1841 static guint8
1842 be_enc_info(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
1843 {
1844     guint8      oct;
1845     guint8      mask;
1846     guint8      alg_id;
1847     guint32     curr_offset;
1848
1849     curr_offset = offset;
1850
1851     oct = tvb_get_guint8(tvb, curr_offset);
1852
1853     mask = 0x80;
1854     alg_id = 7;
1855
1856     do
1857     {
1858         other_decode_bitfield_value(a_bigbuf, oct, mask, 8);
1859         proto_tree_add_text(tree,
1860             tvb, curr_offset, 1,
1861             "%s :  GSM A5/%u: %spermitted",
1862             a_bigbuf,
1863             alg_id,
1864             (mask & oct) ? "" : "not ");
1865
1866         mask >>= 1;
1867         alg_id--;
1868     }
1869     while (mask != 0x01);
1870
1871     other_decode_bitfield_value(a_bigbuf, oct, mask, 8);
1872     proto_tree_add_text(tree,
1873         tvb, curr_offset, 1,
1874         "%s :  No encryption: %spermitted",
1875         a_bigbuf,
1876         (mask & oct) ? "" : "not ");
1877
1878     curr_offset++;
1879
1880     NO_MORE_DATA_CHECK(len);
1881
1882     proto_tree_add_text(tree,
1883         tvb, curr_offset, len - (curr_offset - offset),
1884                         "Key: %s",
1885                         tvb_bytes_to_str(tvb, curr_offset, len-(curr_offset-offset) ));
1886
1887     curr_offset += len - (curr_offset - offset);
1888
1889     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
1890
1891     return(curr_offset - offset);
1892 }
1893
1894 /*
1895  * [2] 3.2.2.11
1896  */
1897 guint8
1898 be_chan_type(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
1899 {
1900     guint8      oct;
1901     guint8      sdi;
1902     guint8      num_chan;
1903     guint32     curr_offset;
1904     const gchar *str;
1905
1906     curr_offset = offset;
1907
1908     oct = tvb_get_guint8(tvb, curr_offset);
1909
1910     other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
1911     proto_tree_add_text(tree,
1912         tvb, curr_offset, 1,
1913         "%s :  Spare",
1914         a_bigbuf);
1915
1916     sdi = oct & 0x0f;
1917     switch (sdi)
1918     {
1919     case 1: str = "Speech"; break;
1920     case 2: str = "Data"; break;
1921     case 3: str = "Signalling"; break;
1922     default:
1923         str = "Reserved";
1924         break;
1925     }
1926
1927     other_decode_bitfield_value(a_bigbuf, oct, 0x0f, 8);
1928     proto_tree_add_text(tree,
1929         tvb, curr_offset, 1,
1930         "%s :  Speech/Data Indicator: %s",
1931         a_bigbuf,
1932         str);
1933
1934     if (add_string)
1935         g_snprintf(add_string, string_len, " - (%s)", str);
1936
1937     curr_offset++;
1938
1939     NO_MORE_DATA_CHECK(len);
1940
1941     oct = tvb_get_guint8(tvb, curr_offset);
1942
1943     if (sdi == 0x01)
1944     {
1945         /* speech */
1946
1947         switch (oct)
1948         {
1949         case 0x08: str = "Full rate TCH channel Bm.  Prefer full rate TCH"; break;
1950         case 0x09: str = "Half rate TCH channel Lm.  Prefer half rate TCH"; break;
1951         case 0x0a: str = "Full or Half rate channel, Full rate preferred changes allowed after first allocation"; break;
1952         case 0x0b: str = "Full or Half rate channel, Half rate preferred changes allowed after first allocation"; break;
1953         case 0x1a: str = "Full or Half rate channel, Full rate preferred changes between full and half rate not allowed after first allocation"; break;
1954         case 0x1b: str = "Full or Half rate channel, Half rate preferred changes between full and half rate not allowed after first allocation"; break;
1955         case 0x0f: str = "Full or Half rate channel, changes allowed after first allocation"; break;
1956         case 0x1f: str = "Full or Half rate channel, changes between full and half rate not allowed after first allocation"; break;
1957         default:
1958             str = "Reserved";
1959             break;
1960         }
1961
1962         proto_tree_add_text(tree,
1963             tvb, curr_offset, 1,
1964             "Channel Rate and Type: %s",
1965             str);
1966
1967         curr_offset++;
1968
1969         NO_MORE_DATA_CHECK(len);
1970
1971         do
1972         {
1973             oct = tvb_get_guint8(tvb, curr_offset);
1974
1975             other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
1976             proto_tree_add_text(tree,
1977                 tvb, curr_offset, 1,
1978                 "%s :  Extension: %s",
1979                 a_bigbuf,
1980                 (oct & 0x80) ? "extended" : "not extended");
1981
1982             switch (oct & 0x7f)
1983             {
1984             case 0x01: str = "GSM speech full rate version 1"; break;
1985             case 0x11: str = "GSM speech full rate version 2"; break;
1986             case 0x21: str = "GSM speech full rate version 3 (AMR)"; break;
1987
1988             case 0x05: str = "GSM speech half rate version 1"; break;
1989             case 0x15: str = "GSM speech half rate version 2"; break;
1990             case 0x25: str = "GSM speech half rate version 3 (AMR)"; break;
1991
1992             default:
1993                 str = "Reserved";
1994                 break;
1995             }
1996
1997             other_decode_bitfield_value(a_bigbuf, oct, 0x7f, 8);
1998             proto_tree_add_text(tree,
1999                 tvb, curr_offset, 1,
2000                 "%s :  Speech version identifier: %s",
2001                 a_bigbuf,
2002                 str);
2003
2004             curr_offset++;
2005         }
2006         while ((len - (curr_offset - offset)) > 0);
2007     }
2008     else if (sdi == 0x02)
2009     {
2010         /* data */
2011
2012         num_chan = 0;
2013
2014         switch (oct)
2015         {
2016         case 0x08: str = "Full rate TCH channel Bm"; break;
2017         case 0x09: str = "Half rate TCH channel Lm"; break;
2018         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;
2019         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;
2020         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;
2021         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;
2022         default:
2023             if ((oct >= 0x20) && (oct <= 0x27))
2024             {
2025                 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";
2026
2027                 num_chan = (oct - 0x20) + 1;
2028             }
2029             else if ((oct >= 0x30) && (oct <= 0x37))
2030             {
2031                 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";
2032
2033                 num_chan = (oct - 0x30) + 1;
2034             }
2035             else
2036             {
2037                 str = "Reserved";
2038             }
2039             break;
2040         }
2041
2042         if (num_chan > 0)
2043         {
2044             proto_tree_add_text(tree,
2045                 tvb, curr_offset, 1,
2046                 "Channel Rate and Type: Max channels %u, %s",
2047                 num_chan,
2048                 str);
2049         }
2050         else
2051         {
2052             proto_tree_add_text(tree,
2053                 tvb, curr_offset, 1,
2054                 "Channel Rate and Type: %s",
2055                 str);
2056         }
2057
2058         curr_offset++;
2059
2060         NO_MORE_DATA_CHECK(len);
2061
2062         oct = tvb_get_guint8(tvb, curr_offset);
2063
2064         other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
2065         proto_tree_add_text(tree,
2066             tvb, curr_offset, 1,
2067             "%s :  Extension: %s",
2068             a_bigbuf,
2069             (oct & 0x80) ? "extended" : "not extended");
2070
2071         other_decode_bitfield_value(a_bigbuf, oct, 0x40, 8);
2072         proto_tree_add_text(tree,
2073             tvb, curr_offset, 1,
2074             "%s :  %sTransparent service",
2075             a_bigbuf,
2076             (oct & 0x40) ? "Non-" : "");
2077
2078         if (num_chan == 0)
2079         {
2080             if (oct & 0x40)
2081             {
2082                 /* non-transparent */
2083
2084                 switch (oct & 0x3f)
2085                 {
2086                 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;
2087                 case 0x18: str = "14.5 kbit/s"; break;
2088                 case 0x10: str = "12 kbits/s"; break;
2089                 case 0x11: str = "6 kbits/s"; break;
2090                 default:
2091                     str = "Reserved";
2092                     break;
2093                 }
2094             }
2095             else
2096             {
2097                 switch (oct & 0x3f)
2098                 {
2099                 case 0x18: str = "14.4 kbit/s"; break;
2100                 case 0x10: str = "9.6kbit/s"; break;
2101                 case 0x11: str = "4.8kbit/s"; break;
2102                 case 0x12: str = "2.4kbit/s"; break;
2103                 case 0x13: str = "1.2Kbit/s"; break;
2104                 case 0x14: str = "600 bit/s"; break;
2105                 case 0x15: str = "1200/75 bit/s (1200 network-to-MS / 75 MS-to-network)"; break;
2106                 default:
2107                     str = "Reserved";
2108                     break;
2109                 }
2110             }
2111         }
2112         else
2113         {
2114             if (oct & 0x40)
2115             {
2116                 /* non-transparent */
2117
2118                 switch (oct & 0x3f)
2119                 {
2120                 case 0x16: str = "58 kbit/s (4x14.5 kbit/s)"; break;
2121                 case 0x14: str = "48.0 / 43.5 kbit/s (4x12 kbit/s or 3x14.5 kbit/s)"; break;
2122                 case 0x13: str = "36.0 / 29.0 kbit/s (3x12 kbit/s or 2x14.5 kbit/s)"; break;
2123                 case 0x12: str = "24.0 / 24.0 (4x6 kbit/s or 2x12 kbit/s)"; break;
2124                 case 0x11: str = "18.0 / 14.5 kbit/s (3x6 kbit/s or 1x14.5 kbit/s)"; break;
2125                 case 0x10: str = "12.0 / 12.0 kbit/s (2x6 kbit/s or 1x12 kbit/s)"; break;
2126                 default:
2127                     str = "Reserved";
2128                     break;
2129                 }
2130             }
2131             else
2132             {
2133                 switch (oct & 0x3f)
2134                 {
2135                 case 0x1f: str = "64 kbit/s, bit transparent"; break;
2136                 case 0x1e: str = "56 kbit/s, bit transparent"; break;
2137                 case 0x1d: str = "56 kbit/s"; break;
2138                 case 0x1c: str = "48 kbit/s"; break;
2139                 case 0x1b: str = "38.4 kbit/s"; break;
2140                 case 0x1a: str = "28.8 kbit/s"; break;
2141                 case 0x19: str = "19.2 kbit/s"; break;
2142                 case 0x18: str = "14.4 kbit/s"; break;
2143                 case 0x10: str = "9.6 kbit/s"; break;
2144                 default:
2145                     str = "Reserved";
2146                     break;
2147                 }
2148             }
2149         }
2150
2151         other_decode_bitfield_value(a_bigbuf, oct, 0x3f, 8);
2152         proto_tree_add_text(tree,
2153             tvb, curr_offset, 1,
2154             "%s :  Rate: %s",
2155             a_bigbuf,
2156             str);
2157
2158         curr_offset++;
2159
2160         NO_MORE_DATA_CHECK(len);
2161
2162         oct = tvb_get_guint8(tvb, curr_offset);
2163
2164         other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
2165         proto_tree_add_text(tree,
2166             tvb, curr_offset, 1,
2167             "%s :  Extension: %s",
2168             a_bigbuf,
2169             (oct & 0x80) ? "extended" : "not extended");
2170
2171         other_decode_bitfield_value(a_bigbuf, oct, 0x70, 8);
2172         proto_tree_add_text(tree,
2173             tvb, curr_offset, 1,
2174             "%s :  Spare",
2175             a_bigbuf);
2176
2177         if (num_chan == 0)
2178         {
2179             other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
2180             proto_tree_add_text(tree,
2181                 tvb, curr_offset, 1,
2182                 "%s :  14.5 kbit/s (TCH/F14.4) %sallowed",
2183                 a_bigbuf,
2184                 (oct & 0x08) ? "" : "not ");
2185
2186             other_decode_bitfield_value(a_bigbuf, oct, 0x04, 8);
2187             proto_tree_add_text(tree,
2188                 tvb, curr_offset, 1,
2189                 "%s :  Spare",
2190                 a_bigbuf);
2191
2192             other_decode_bitfield_value(a_bigbuf, oct, 0x02, 8);
2193             proto_tree_add_text(tree,
2194                 tvb, curr_offset, 1,
2195                 "%s :  12.0 kbit/s (TCH F/9.6) %sallowed",
2196                 a_bigbuf,
2197                 (oct & 0x02) ? "" : "not ");
2198
2199             other_decode_bitfield_value(a_bigbuf, oct, 0x01, 8);
2200             proto_tree_add_text(tree,
2201                 tvb, curr_offset, 1,
2202                 "%s :  6.0 kbit/s (TCH F/4.8) %sallowed",
2203                 a_bigbuf,
2204                 (oct & 0x01) ? "" : "not ");
2205         }
2206         else
2207         {
2208             other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
2209             proto_tree_add_text(tree,
2210                 tvb, curr_offset, 1,
2211                 "%s :  14.5/14.4 kbit/s (TCH/F14.4) %sallowed",
2212                 a_bigbuf,
2213                 (oct & 0x08) ? "" : "not ");
2214
2215             other_decode_bitfield_value(a_bigbuf, oct, 0x04, 8);
2216             proto_tree_add_text(tree,
2217                 tvb, curr_offset, 1,
2218                 "%s :  Spare",
2219                 a_bigbuf);
2220
2221             other_decode_bitfield_value(a_bigbuf, oct, 0x02, 8);
2222             proto_tree_add_text(tree,
2223                 tvb, curr_offset, 1,
2224                 "%s :  12.0/9.6 kbit/s (TCH F/9.6) %sallowed",
2225                 a_bigbuf,
2226                 (oct & 0x02) ? "" : "not ");
2227
2228             other_decode_bitfield_value(a_bigbuf, oct, 0x01, 8);
2229             proto_tree_add_text(tree,
2230                 tvb, curr_offset, 1,
2231                 "%s :  6.0/4.8 kbit/s (TCH F/4.8) %sallowed",
2232                 a_bigbuf,
2233                 (oct & 0x01) ? "" : "not ");
2234         }
2235
2236         curr_offset++;
2237     }
2238     else if (sdi == 0x03)
2239     {
2240         /* signalling */
2241
2242         switch (oct)
2243         {
2244         case 0x00: str = "SDCCH or Full rate TCH channel Bm or Half rate TCH channel Lm"; break;
2245         case 0x01: str = "SDCCH"; break;
2246         case 0x02: str = "SDCCH or Full rate TCH channel Bm"; break;
2247         case 0x03: str = "SDCCH or Half rate TCH channel Lm"; break;
2248         case 0x08: str = "Full rate TCH channel Bm"; break;
2249         case 0x09: str = "Half rate TCH channel Lm"; break;
2250         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;
2251         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;
2252         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;
2253         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;
2254         default:
2255             str = "Reserved";
2256             break;
2257         }
2258
2259         proto_tree_add_text(tree,
2260             tvb, curr_offset, 1,
2261             "Channel Rate and Type: %s",
2262             str);
2263
2264         curr_offset++;
2265
2266         NO_MORE_DATA_CHECK(len);
2267
2268         proto_tree_add_text(tree,
2269             tvb, curr_offset, len - (curr_offset - offset),
2270             "Spare");
2271
2272         curr_offset += len - (curr_offset - offset);
2273     }
2274     else
2275     {
2276         /* unknown format */
2277
2278         proto_tree_add_text(tree,
2279             tvb, curr_offset, len - (curr_offset - offset),
2280             "Unknown format");
2281
2282         curr_offset += len - (curr_offset - offset);
2283     }
2284
2285     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
2286
2287     return(curr_offset - offset);
2288 }
2289
2290 /*
2291  * [2] 3.2.2.17
2292  * Formats everything after the discriminator, shared function
2293  */
2294 guint8
2295 be_cell_id_aux(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len, guint8 disc)
2296 {
2297     guint8      octs[3];
2298     guint32     value;
2299     guint32     curr_offset;
2300     gchar       mcc[4];
2301     gchar       mnc[4];
2302
2303     if (add_string)
2304         add_string[0] = '\0';
2305     curr_offset = offset;
2306
2307     switch (disc)
2308     {
2309     case 0x00:
2310         /* FALLTHRU */
2311
2312     case 0x04:
2313         /* FALLTHRU */
2314
2315     case 0x08:  /* For intersystem handover from GSM to UMTS or cdma2000: */
2316         octs[0] = tvb_get_guint8(tvb, curr_offset);
2317         octs[1] = tvb_get_guint8(tvb, curr_offset + 1);
2318         octs[2] = tvb_get_guint8(tvb, curr_offset + 2);
2319
2320         mcc_mnc_aux(octs, mcc, mnc);
2321
2322         proto_tree_add_text(tree,
2323             tvb, curr_offset, 3,
2324             "Mobile Country Code (MCC): %s, Mobile Network Code (MNC): %s",
2325             mcc,
2326             mnc);
2327
2328         curr_offset += 3;
2329
2330         /* FALLTHRU */
2331
2332     case 0x01:
2333     case 0x05:
2334     case 0x0a: /*For intersystem handover from GSM to UMTS or cdma2000: */
2335
2336         /* LAC */
2337
2338         value = tvb_get_ntohs(tvb, curr_offset);
2339
2340         proto_tree_add_item(tree, hf_gsm_a_cell_lac, tvb, curr_offset, 2, FALSE);
2341                 
2342         curr_offset += 2;
2343
2344         if (add_string)
2345             g_snprintf(add_string, string_len, " - LAC (0x%04x)", value);
2346
2347         /* FALLTHRU */
2348
2349     case 0x09: /* For intersystem handover from GSM to UMTS or cdma2000: */
2350
2351         if ((disc == 0x08) ||(disc == 0x09) || (disc == 0x0a)){ 
2352                 /* RNC-ID */
2353                 value = tvb_get_ntohs(tvb, curr_offset);
2354                 proto_tree_add_item(tree, hf_gsm_a_be_rnc_id, tvb, curr_offset, 2, FALSE);
2355
2356                 if (add_string)
2357                 {
2358                     if (add_string[0] == '\0')
2359                     {
2360                         g_snprintf(add_string, string_len, " - RNC-ID (%u)", value);
2361                     }
2362                     else
2363                     {
2364                         g_snprintf(add_string, string_len, "%s/RNC-ID (%u)", add_string, value);
2365                     }
2366                 }
2367                 break;
2368         }
2369
2370         if ((disc == 0x04) || (disc == 0x05) || (disc == 0x08)) break;
2371
2372         /* FALLTHRU */
2373
2374     case 0x02:
2375
2376         /* CI */
2377
2378         value = tvb_get_ntohs(tvb, curr_offset);
2379
2380         proto_tree_add_uint(tree, hf_gsm_a_cell_ci, tvb,
2381             curr_offset, 2, value);
2382
2383         curr_offset += 2;
2384
2385         if (add_string)
2386         {
2387             if (add_string[0] == '\0')
2388             {
2389                 g_snprintf(add_string, string_len, " - CI (%u)", value);
2390             }
2391             else
2392             {
2393                 g_snprintf(add_string, string_len, "%s/CI (%u)", add_string, value);
2394             }
2395         }
2396         break;
2397
2398     default:
2399         proto_tree_add_text(tree, tvb, curr_offset, len,
2400             "Cell ID - Unknown format");
2401
2402         curr_offset += (len);
2403         break;
2404     }
2405
2406     return(curr_offset - offset);
2407 }
2408
2409 static guint8
2410 be_cell_id(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
2411 {
2412     guint8      oct;
2413     guint8      disc;
2414     guint32     curr_offset;
2415
2416     len = len;
2417     curr_offset = offset;
2418
2419     oct = tvb_get_guint8(tvb, curr_offset);
2420
2421     other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
2422     proto_tree_add_text(tree,
2423         tvb, curr_offset, 1,
2424         "%s :  Spare",
2425         a_bigbuf);
2426
2427     proto_tree_add_item(tree, hf_gsm_a_be_cell_id_disc, tvb, curr_offset, 1, FALSE);
2428         disc = oct&0x0f;
2429     curr_offset++;
2430
2431     NO_MORE_DATA_CHECK(len);
2432
2433     curr_offset +=
2434         be_cell_id_aux(tvb, tree, curr_offset, len - (curr_offset - offset), add_string, string_len, disc);
2435
2436     /* no length check possible */
2437
2438     return(curr_offset - offset);
2439 }
2440
2441 /*
2442  * [2] 3.2.2.18
2443  */
2444 static guint8
2445 be_prio(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
2446 {
2447     guint8      oct;
2448     guint32     curr_offset;
2449     const gchar *str;
2450
2451     len = len;
2452     curr_offset = offset;
2453
2454     oct = tvb_get_guint8(tvb, curr_offset);
2455
2456     proto_tree_add_item(tree, hf_gsm_a_b8spare, tvb, curr_offset, 1, FALSE);
2457
2458     other_decode_bitfield_value(a_bigbuf, oct, 0x40, 8);
2459     proto_tree_add_text(tree,
2460         tvb, curr_offset, 1,
2461         "%s :  Preemption Capability Indicator (PCI): this allocation request %s preempt an existing connection",
2462         a_bigbuf,
2463         (oct & 0x40) ? "may" : "shall not");
2464
2465     switch ((oct & 0x3c) >> 2)
2466     {
2467     case 0x00: str = "Spare"; break;
2468     case 0x0f: str = "priority not used"; break;
2469     default:
2470         str = "1 is highest";
2471         break;
2472     }
2473
2474     other_decode_bitfield_value(a_bigbuf, oct, 0x3c, 8);
2475     proto_tree_add_text(tree,
2476         tvb, curr_offset, 1,
2477         "%s :  Priority Level: (%u) %s",
2478         a_bigbuf,
2479         (oct & 0x3c) >> 2,
2480         str);
2481
2482     if (add_string)
2483         g_snprintf(add_string, string_len, " - (%u)", (oct & 0x3c) >> 2);
2484
2485     other_decode_bitfield_value(a_bigbuf, oct, 0x02, 8);
2486     proto_tree_add_text(tree,
2487         tvb, curr_offset, 1,
2488         "%s :  Queuing Allowed Indicator (QA): queuing %sallowed",
2489         a_bigbuf,
2490         (oct & 0x02) ? "" : "not ");
2491
2492     other_decode_bitfield_value(a_bigbuf, oct, 0x01, 8);
2493     proto_tree_add_text(tree,
2494         tvb, curr_offset, 1,
2495         "%s :  Preemption Vulnerability Indicator (PVI): this connection %s be preempted by another allocation request",
2496         a_bigbuf,
2497         (oct & 0x01) ? "might" : "shall not");
2498
2499     curr_offset++;
2500
2501     /* no length check possible */
2502
2503     return(curr_offset - offset);
2504 }
2505
2506 /*
2507  * [2] 3.2.2.24
2508  */
2509 static guint8
2510 be_l3_info(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
2511 {
2512     guint32     curr_offset;
2513     tvbuff_t    *l3_tvb;
2514
2515     curr_offset = offset;
2516
2517     proto_tree_add_text(tree, tvb, curr_offset, len,
2518         "Layer 3 Information value");
2519
2520     /*
2521      * dissect the embedded DTAP message
2522      */
2523     l3_tvb = tvb_new_subset(tvb, curr_offset, len, len);
2524
2525     call_dissector(dtap_handle, l3_tvb, g_pinfo, g_tree);
2526
2527     curr_offset += len;
2528
2529     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
2530
2531     return(curr_offset - offset);
2532 }
2533
2534 /*
2535  * [2] 3.2.2.25
2536  */
2537 static guint8
2538 be_dlci(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
2539 {
2540     guint8      oct;
2541     guint32     curr_offset;
2542     proto_item  *item = NULL;
2543     proto_tree  *subtree = NULL;
2544
2545     len = len;
2546     curr_offset = offset;
2547
2548     item =
2549         proto_tree_add_text(tree, tvb, curr_offset, 1,
2550             "Data Link Connection Identifier");
2551
2552     subtree = proto_item_add_subtree(item, ett_dlci);
2553
2554     oct = tvb_get_guint8(tvb, curr_offset);
2555
2556     proto_tree_add_uint(subtree, hf_gsm_a_dlci_cc, tvb, curr_offset, 1, oct);
2557     proto_tree_add_uint(subtree, hf_gsm_a_dlci_spare, tvb, curr_offset, 1, oct);
2558     proto_tree_add_uint(subtree, hf_gsm_a_dlci_sapi, tvb, curr_offset, 1, oct);
2559
2560     curr_offset++;
2561
2562     /* no length check possible */
2563
2564     return(curr_offset - offset);
2565 }
2566
2567 /*
2568  * [2] 3.2.2.26
2569  */
2570 static guint8
2571 be_down_dtx_flag(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
2572 {
2573     guint       oct;
2574     guint32     curr_offset;
2575
2576     len = len;
2577     curr_offset = offset;
2578
2579     oct = tvb_get_guint8(tvb, curr_offset);
2580
2581     other_decode_bitfield_value(a_bigbuf, oct, 0xfe, 8);
2582     proto_tree_add_text(tree,
2583         tvb, curr_offset, 1,
2584         "%s :  Spare",
2585         a_bigbuf);
2586
2587     other_decode_bitfield_value(a_bigbuf, oct, 0x01, 8);
2588     proto_tree_add_text(tree,
2589         tvb, curr_offset, 1,
2590         "%s :  BSS is %s to activate DTX in the downlink direction",
2591         a_bigbuf,
2592         (oct & 0x01) ? "forbidden" : "allowed");
2593
2594     curr_offset++;
2595
2596     /* no length check possible */
2597
2598     return(curr_offset - offset);
2599 }
2600
2601 /*
2602  * [2] 3.2.2.27
2603  */
2604 guint8
2605 be_cell_id_list(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
2606 {
2607     guint8      oct;
2608     guint8      consumed;
2609     guint8      disc;
2610     guint8      num_cells;
2611     guint32     curr_offset;
2612     proto_item  *item = NULL;
2613     proto_tree  *subtree = NULL;
2614
2615     curr_offset = offset;
2616
2617     oct = tvb_get_guint8(tvb, curr_offset);
2618
2619     other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
2620     proto_tree_add_text(tree,
2621         tvb, curr_offset, 1,
2622         "%s :  Spare",
2623         a_bigbuf);
2624
2625         disc = oct & 0x0f;
2626         proto_tree_add_item(tree, hf_gsm_a_be_cell_id_disc, tvb, curr_offset, 1, FALSE);
2627     curr_offset++;
2628
2629     NO_MORE_DATA_CHECK(len);
2630
2631     num_cells = 0;
2632     do
2633     {
2634         item =
2635             proto_tree_add_text(tree,
2636                 tvb, curr_offset, -1,
2637                 "Cell %u",
2638                 num_cells + 1);
2639
2640         subtree = proto_item_add_subtree(item, ett_cell_list);
2641
2642         if (add_string)
2643             add_string[0] = '\0';
2644         consumed =
2645             be_cell_id_aux(tvb, subtree, curr_offset, len - (curr_offset - offset), add_string, string_len, disc);
2646
2647         if (add_string && add_string[0] != '\0')
2648         {
2649             proto_item_append_text(item, "%s", add_string ? add_string : "");
2650         }
2651
2652         proto_item_set_len(item, consumed);
2653
2654         curr_offset += consumed;
2655
2656         num_cells++;
2657     }
2658     while ((len - (curr_offset - offset)) > 0 && consumed > 0);
2659
2660     if (add_string) {
2661         g_snprintf(add_string, string_len, " - %u cell%s",
2662             num_cells, plurality(num_cells, "", "s"));
2663     }
2664
2665     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
2666
2667     return(curr_offset - offset);
2668 }
2669
2670 /*
2671  * [2] 3.2.2.33
2672  */
2673 static guint8
2674 be_chosen_chan(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
2675 {
2676     guint8      oct;
2677     guint32     curr_offset;
2678     const gchar *str = NULL;
2679
2680     len = len;
2681     curr_offset = offset;
2682
2683     oct = tvb_get_guint8(tvb, curr_offset);
2684
2685     switch ((oct & 0xf0) >> 4)
2686     {
2687     case 0: str = "No channel mode indication"; break;
2688     case 9: str = "Speech (full rate or half rate)"; break;
2689     case 14: str = "Data, 14.5 kbit/s radio interface rate"; break;
2690     case 11: str = "Data, 12.0 kbit/s radio interface rate"; break;
2691     case 12: str = "Data, 6.0 kbit/s radio interface rate"; break;
2692     case 13: str = "Data, 3.6 kbit/s radio interface rate"; break;
2693     case 8: str = "Signalling only"; break;
2694     default:
2695         str = "Reserved";
2696         break;
2697     }
2698
2699     other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
2700     proto_tree_add_text(tree,
2701         tvb, curr_offset, 1,
2702         "%s :  Channel mode: %s",
2703         a_bigbuf,
2704         str);
2705
2706     switch (oct & 0x0f)
2707     {
2708     case 0: str = "None"; break;
2709     case 1: str = "SDCCH"; break;
2710     case 8: str = "1 Full rate TCH"; break;
2711     case 9: str = "1 Half rate TCH"; break;
2712     case 10: str = "2 Full Rate TCHs"; break;
2713     case 11: str = "3 Full Rate TCHs"; break;
2714     case 12: str = "4 Full Rate TCHs"; break;
2715     case 13: str = "5 Full Rate TCHs"; break;
2716     case 14: str = "6 Full Rate TCHs"; break;
2717     case 15: str = "7 Full Rate TCHs"; break;
2718     case 4: str = "8 Full Rate TCHs"; break;
2719     default:
2720         str = "Reserved";
2721         break;
2722     }
2723
2724     other_decode_bitfield_value(a_bigbuf, oct, 0x0f, 8);
2725     proto_tree_add_text(tree,
2726         tvb, curr_offset, 1,
2727         "%s :  Channel: %s",
2728         a_bigbuf,
2729         str);
2730
2731     curr_offset++;
2732
2733     /* no length check possible */
2734
2735     return(curr_offset - offset);
2736 }
2737
2738 /*
2739  * [2] 3.2.2.34
2740  */
2741 static guint8
2742 be_ciph_resp_mode(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
2743 {
2744     guint8      oct;
2745     guint32     curr_offset;
2746
2747     len = len;
2748     curr_offset = offset;
2749
2750     oct = tvb_get_guint8(tvb, curr_offset);
2751
2752     other_decode_bitfield_value(a_bigbuf, oct, 0xfe, 8);
2753     proto_tree_add_text(tree,
2754         tvb, curr_offset, 1,
2755         "%s :  Spare",
2756         a_bigbuf);
2757
2758     other_decode_bitfield_value(a_bigbuf, oct, 0x01, 8);
2759     proto_tree_add_text(tree,
2760         tvb, curr_offset, 1,
2761         "%s :  IMEISV must %sbe included by the mobile station",
2762         a_bigbuf,
2763         (oct & 0x01) ? "" : "not ");
2764
2765     curr_offset++;
2766
2767     /* no length check possible */
2768
2769     return(curr_offset - offset);
2770 }
2771
2772
2773 /*
2774  * [2] 3.2.2.35
2775  */
2776 static guint8
2777 be_l3_msg(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
2778 {
2779     guint32     curr_offset;
2780     tvbuff_t    *l3_tvb;
2781
2782     curr_offset = offset;
2783
2784     proto_tree_add_text(tree, tvb, curr_offset, len,
2785         "Layer 3 Message Contents");
2786
2787     /*
2788      * dissect the embedded DTAP message
2789      */
2790     l3_tvb = tvb_new_subset(tvb, curr_offset, len, len);
2791
2792     call_dissector(dtap_handle, l3_tvb, g_pinfo, g_tree);
2793
2794     curr_offset += len;
2795
2796     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
2797
2798     return(curr_offset - offset);
2799 }
2800
2801 /*
2802  * [2] 3.2.2.36 Channel Needed
2803  */static guint8 
2804 be_cha_needed(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
2805 {
2806     guint32     curr_offset;
2807     
2808     len = len;
2809     curr_offset = offset;
2810     
2811     /* no length check possible */
2812         proto_tree_add_item(tree, hf_gsm_a_rr_chnl_needed_ch1, tvb, curr_offset, 1, FALSE);
2813         curr_offset++;  
2814     return(curr_offset - offset);
2815 }
2816
2817
2818 /*
2819  * [2] 3.2.2.43
2820  */
2821 static guint8
2822 be_for_ind(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
2823 {
2824     guint8      oct;
2825     guint32     curr_offset;
2826     const gchar *str = NULL;
2827
2828     len = len;
2829     curr_offset = offset;
2830
2831     oct = tvb_get_guint8(tvb, curr_offset);
2832
2833     other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
2834     proto_tree_add_text(tree,
2835         tvb, curr_offset, 1,
2836         "%s :  Spare",
2837         a_bigbuf);
2838
2839     switch (oct & 0x0f)
2840     {
2841     case 1: str = "forward to subsequent BSS, no trace at MSC"; break;
2842     case 2: str = "forward to subsequent BSS, and trace at MSC"; break;
2843     default:
2844         str = "Reserved";
2845         break;
2846     }
2847
2848     other_decode_bitfield_value(a_bigbuf, oct, 0x0f, 8);
2849     proto_tree_add_text(tree,
2850         tvb, curr_offset, 1,
2851         "%s :  %s",
2852         a_bigbuf,
2853         str);
2854
2855     curr_offset++;
2856
2857     /* no length check possible */
2858
2859     return(curr_offset - offset);
2860 }
2861
2862 /*
2863  * [2] 3.2.2.44
2864  */
2865 static guint8
2866 be_chosen_enc_alg(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
2867 {
2868     guint8      oct;
2869     guint32     curr_offset;
2870     const gchar *str = NULL;
2871
2872     len = len;
2873     curr_offset = offset;
2874
2875     oct = tvb_get_guint8(tvb, curr_offset);
2876
2877     switch (oct)
2878     {
2879     case 0x01: str = "No encryption used"; break;
2880     case 0x02: str = "GSM A5/1"; break;
2881     case 0x03: str = "GSM A5/2"; break;
2882     case 0x04: str = "GSM A5/3"; break;
2883     case 0x05: str = "GSM A5/4"; break;
2884     case 0x06: str = "GSM A5/5"; break;
2885     case 0x07: str = "GSM A5/6"; break;
2886     case 0x08: str = "GSM A5/7"; break;
2887     default:
2888         str = "Reserved";
2889         break;
2890     }
2891
2892     proto_tree_add_text(tree,
2893         tvb, curr_offset, 1,
2894         "Algorithm Identifier: %s",
2895         str);
2896
2897     curr_offset++;
2898
2899     if (add_string)
2900         g_snprintf(add_string, string_len, " - %s", str);
2901
2902     /* no length check possible */
2903
2904     return(curr_offset - offset);
2905 }
2906
2907 /*
2908  * [2] 3.2.2.45
2909  */
2910 static guint8
2911 be_cct_pool(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
2912 {
2913     guint8      oct;
2914     guint32     curr_offset;
2915     const gchar *str = NULL;
2916
2917     len = len;
2918     curr_offset = offset;
2919
2920     oct = tvb_get_guint8(tvb, curr_offset);
2921
2922     if (oct <= 32)
2923     {
2924         str = "";
2925     }
2926     else if ((oct >= 0x80) && (oct <= 0x8f))
2927     {
2928         str = ", for national/local use";
2929     }
2930     else
2931     {
2932         str = ", reserved for future international use";
2933     }
2934
2935     proto_tree_add_text(tree,
2936         tvb, curr_offset, 1,
2937         "Circuit pool number: %u%s",
2938         oct,
2939         str);
2940
2941     curr_offset++;
2942
2943     if (add_string)
2944         g_snprintf(add_string, string_len, " - (%u)", oct);
2945
2946     /* no length check possible */
2947
2948     return(curr_offset - offset);
2949 }
2950
2951 /*
2952  * [2] 3.2.2.49
2953  */
2954 static guint8
2955 be_curr_chan_1(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
2956 {
2957     guint8      oct;
2958     guint32     curr_offset;
2959     const gchar *str;
2960
2961     len = len;
2962     curr_offset = offset;
2963
2964     oct = tvb_get_guint8(tvb, curr_offset);
2965
2966     switch ((oct & 0xf0) >> 4)
2967     {
2968     case 0x00: str = "Signalling only"; break;
2969     case 0x01: str = "Speech (full rate or half rate)"; break;
2970     case 0x06: str = "Data, 14.5 kbit/s radio interface rate"; break;
2971     case 0x03: str = "Data, 12.0 kbit/s radio interface rate"; break;
2972     case 0x04: str = "Data, 6.0 kbit/s radio interface rate"; break;
2973     case 0x05: str = "Data, 3.6 kbit/s radio interface rate"; break;
2974     default:
2975         str = "Reserved";
2976         break;
2977     }
2978
2979     other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
2980     proto_tree_add_text(tree,
2981         tvb, curr_offset, 1,
2982         "%s :  Channel Mode: %s",
2983         a_bigbuf,
2984         str);
2985
2986     switch (oct & 0x0f)
2987     {
2988     case 0x01: str = "SDCCH"; break;
2989     case 0x08: str = "1 Full rate TCH"; break;
2990     case 0x09: str = "1 Half rate TCH"; break;
2991     case 0x0a: str = "2 Full Rate TCHs"; break;
2992     case 0x0b: str = "3 Full Rate TCHs"; break;
2993     case 0x0c: str = "4 Full Rate TCHs"; break;
2994     case 0x0d: str = "5 Full Rate TCHs"; break;
2995     case 0x0e: str = "6 Full Rate TCHs"; break;
2996     case 0x0f: str = "7 Full Rate TCHs"; break;
2997     case 0x04: str = "8 Full Rate TCHs"; break;
2998     default:
2999         str = "Reserved";
3000         break;
3001     }
3002
3003     other_decode_bitfield_value(a_bigbuf, oct, 0x0f, 8);
3004     proto_tree_add_text(tree,
3005         tvb, curr_offset, 1,
3006         "%s :  Channel: (%u) %s",
3007         a_bigbuf,
3008         oct & 0x0f,
3009         str);
3010
3011     curr_offset++;
3012
3013     /* no length check possible */
3014
3015     return(curr_offset - offset);
3016 }
3017
3018 /*
3019  * [2] 3.2.2.50
3020  */
3021 static guint8
3022 be_que_ind(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
3023 {
3024     guint8      oct;
3025     guint32     curr_offset;
3026
3027     len = len;
3028     curr_offset = offset;
3029
3030     oct = tvb_get_guint8(tvb, curr_offset);
3031
3032     other_decode_bitfield_value(a_bigbuf, oct, 0xfc, 8);
3033     proto_tree_add_text(tree,
3034         tvb, curr_offset, 1,
3035         "%s :  Spare",
3036         a_bigbuf);
3037
3038     other_decode_bitfield_value(a_bigbuf, oct, 0x02, 8);
3039     proto_tree_add_text(tree,
3040         tvb, curr_offset, 1,
3041         "%s :  qri: it is recommended %sto allow queuing",
3042         a_bigbuf,
3043         (oct & 0x02) ? "" : "not ");
3044
3045     other_decode_bitfield_value(a_bigbuf, oct, 0x01, 8);
3046     proto_tree_add_text(tree,
3047         tvb, curr_offset, 1,
3048         "%s :  Spare",
3049         a_bigbuf);
3050
3051     curr_offset++;
3052
3053     /* no length check possible */
3054
3055     return(curr_offset - offset);
3056 }
3057
3058 /*
3059  * [2] 3.2.2.51
3060  */
3061 static guint8
3062 be_speech_ver(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
3063 {
3064     guint8      oct;
3065     guint32     curr_offset;
3066     const gchar *str = NULL;
3067     const gchar *short_str = NULL;
3068
3069     len = len;
3070     curr_offset = offset;
3071
3072     oct = tvb_get_guint8(tvb, curr_offset);
3073
3074     proto_tree_add_item(tree, hf_gsm_a_b8spare, tvb, curr_offset, 1, FALSE);
3075
3076     switch (oct & 0x7f)
3077     {
3078     case 0x01: str = "GSM speech full rate version 1"; short_str = "FR1"; break;
3079     case 0x11: str = "GSM speech full rate version 2"; short_str = "FR2"; break;
3080     case 0x21: str = "GSM speech full rate version 3 (AMR)"; short_str = "FR3 (AMR)"; break;
3081
3082     case 0x05: str = "GSM speech half rate version 1"; short_str = "HR1"; break;
3083     case 0x15: str = "GSM speech half rate version 2"; short_str = "HR2"; break;
3084     case 0x25: str = "GSM speech half rate version 3 (AMR)"; short_str = "HR3 (AMR)"; break;
3085
3086     default:
3087         str = "Reserved";
3088         short_str = str;
3089         break;
3090     }
3091
3092     other_decode_bitfield_value(a_bigbuf, oct, 0x7f, 8);
3093     proto_tree_add_text(tree,
3094         tvb, curr_offset, 1,
3095         "%s :  Speech version identifier: %s",
3096         a_bigbuf,
3097         str);
3098
3099     curr_offset++;
3100
3101     if (add_string)
3102         g_snprintf(add_string, string_len, " - (%s)", short_str);
3103
3104     /* no length check possible */
3105
3106     return(curr_offset - offset);
3107 }
3108
3109 /*
3110  * 3.2.2.68 3GPP TS 48.008 version 6.9.0 Release 6
3111  */
3112
3113 /* BSSLAP the embedded message is as defined in 3GPP TS 48.071
3114  * LLP the embedded message contains a Facility Information Element as defined in 3GPP TS 44.071
3115  *              excluding the Facility IEI and length of Facility IEI octets defined in 3GPP TS 44.071.
3116  * SMLCPP the embedded message is as defined in 3GPP TS 48.031
3117  */
3118 static const value_string gsm_a_apdu_protocol_id_strings[] = {
3119     { 0,        "reserved" },
3120     { 1,        "BSSLAP" },
3121     { 2,        "LLP" },
3122     { 3,        "SMLCPP" },
3123     { 0, NULL },
3124 };
3125
3126 static guint8
3127 be_apdu(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
3128 {
3129     guint32     curr_offset;
3130
3131     curr_offset = offset;
3132
3133     proto_tree_add_text(tree, tvb, curr_offset, len,
3134         "APDU (not displayed)");
3135
3136     /*
3137      * dissect the embedded APDU message
3138      * if someone writes a TS 09.31 dissector
3139          *
3140          * The APDU octets 4 to n are coded in the same way as the 
3141          * equivalent octet in the APDU element of 3GPP TS 49.031.
3142      */
3143
3144         proto_tree_add_item(tree, hf_gsm_a_apdu_protocol_id, tvb, curr_offset, 1, FALSE);
3145
3146     curr_offset += len;
3147
3148     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
3149
3150     return(curr_offset - offset);
3151 }
3152
3153 typedef enum
3154 {
3155     /* Common Information Elements 10.5.1 */
3156         /* Pos 0 */
3157     DE_CELL_ID,                         /* Cell Identity */
3158     DE_CIPH_KEY_SEQ_NUM,        /* Ciphering Key Sequence Number */
3159     DE_LAI,                                     /* Location Area Identification */
3160     DE_MID,                                     /* Mobile Identity */
3161     DE_MS_CM_1,                         /* Mobile Station Classmark 1 */
3162     DE_MS_CM_2,                         /* Mobile Station Classmark 2 */
3163     DE_MS_CM_3,                         /* Mobile Station Classmark 3 */
3164     DE_D_GB_CALL_REF,           /* Descriptive group or broadcast call reference */
3165     DE_G_CIPH_KEY_NUM,          /* Group Cipher Key Number */
3166     DE_PD_SAPI,                         /* PD and SAPI $(CCBS)$ */
3167         /* Pos 10 */
3168     DE_PRIO,                            /* Priority Level */
3169     DE_PLMN_LIST,                       /* PLMN List */
3170
3171     /* Radio Resource Management Information Elements 10.5.2, most are from 10.5.1      */
3172 /*
3173  * [3]  10.5.2.1a       BA Range
3174  */
3175         DE_RR_CELL_CH_DSC,                              /* [3]  10.5.2.1b       Cell Channel Description        */
3176
3177 /* [3]  10.5.2.1c       BA List Pref
3178  * [3]  10.5.2.1d       UTRAN Frequency List
3179  * [3]  10.5.2.1e       Cell selection indicator after release of all TCH and SDCCH IE
3180  */
3181         DE_RR_CELL_DSC,                                 /* 10.5.2.2   RR Cell Description                               */
3182 /*
3183  * [3]  10.5.2.3        Cell Options (BCCH)     
3184  * [3]  10.5.2.3a       Cell Options (SACCH)
3185  * [3]  10.5.2.4        Cell Selection Parameters
3186  * [3]  10.5.2.4a       (void)
3187  */
3188         DE_RR_CH_DSC,                                   /* [3]  10.5.2.5        Channel Description                     */
3189         DE_RR_CH_DSC2,                                  /* [3]  10.5.2.5a   Channel Description 2               */
3190         DE_RR_CH_MODE,                                  /* [3]  10.5.2.6        Channel Mode                            */
3191         DE_RR_CH_MODE2,                                 /* [3]  10.5.2.7        Channel Mode 2                          */
3192 /* [3]  10.5.2.7a       UTRAN predefined configuration status information / START-CS / UE CapabilityUTRAN Classmark information element 218
3193  * [3]  10.5.2.7b       (void) */
3194         DE_RR_CM_ENQ_MASK,                              /* [3]  10.5.2.7c       Classmark Enquiry Mask          */
3195 /* [3]  10.5.2.7d       GERAN Iu Mode Classmark information element                                             */
3196         DE_RR_CHNL_NEEDED,                              /* [3]  10.5.2.8        Channel Needed
3197  * [3]  10.5.2.8a       (void)  
3198  * [3]  10.5.2.8b       Channel Request Description 2 */
3199         /* Pos 20 */
3200         DE_RR_CIP_MODE_SET,                             /* [3]  10.5.2.9        Cipher Mode Setting                     */
3201 /* [3]  10.5.2.10       Cipher Response
3202  * [3]  10.5.2.11       Control Channel Description
3203  * [3]  10.5.2.11a      DTM Information Details */
3204         DE_RR_DYN_ARFCN_MAP,                    /* [3]  10.5.2.11b      Dynamic ARFCN Mapping           */
3205         DE_RR_FREQ_CH_SEQ,                              /* [3]  10.5.2.12       Frequency Channel Sequence      */
3206         DE_RR_FREQ_LIST,                                /* [3]  10.5.2.13       Frequency List                          */
3207         DE_RR_FREQ_SHORT_LIST,                  /* [3]  10.5.2.14       Frequency Short List            */
3208         DE_RR_FREQ_SHORT_LIST2,                 /* [3]  10.5.2.14a      Frequency Short List 2          */
3209 /* [3]  10.5.2.14b      Group Channel Description
3210  * [3]  10.5.2.14c      GPRS Resumption
3211  * [3]  10.5.2.14d      GPRS broadcast information
3212  * [3]  10.5.2.14e      Enhanced DTM CS Release Indication
3213  */
3214
3215         DE_RR_HO_REF,                                   /* 10.5.2.15  Handover Reference                                */
3216 /*
3217  * [3] 10.5.2.16 IA Rest Octets
3218  * [3] 10.5.2.17 IAR Rest Octets
3219  * [3] 10.5.2.18 IAX Rest Octets
3220  * [3] 10.5.2.19 L2 Pseudo Length
3221  * [3] 10.5.2.20 Measurement Results
3222  * [3] 10.5.2.20a GPRS Measurement Results
3223  */
3224         DE_RR_MOB_ALL,                                  /* [3] 10.5.2.21 Mobile Allocation                              */
3225         DE_RR_MOB_TIME_DIFF,                    /* [3] 10.5.2.21a Mobile Time Difference                */
3226         DE_RR_MULTIRATE_CONF,                   /* [3] 10.5.2.21aa MultiRate configuration              */
3227         /* Pos 30 */
3228         DE_RR_MULT_ALL,                                 /* [3] 10.5.2.21b Multislot Allocation                  */
3229
3230 /*
3231  * [3] 10.5.2.21c NC mode
3232  * [3] 10.5.2.22 Neighbour Cell Description
3233  * [3] 10.5.2.22a Neighbour Cell Description 2
3234  * [3] 10.5.2.22b (void)
3235  * [3] 10.5.2.22c NT/N Rest Octets
3236  * [3] 10.5.2.23 P1 Rest Octets
3237  * [3] 10.5.2.24 P2 Rest Octets
3238  * [3] 10.5.2.25 P3 Rest Octets
3239  * [3] 10.5.2.25a Packet Channel Description
3240  * [3] 10.5.2.25b Dedicated mode or TBF
3241  * [3] 10.5.2.25c RR Packet Uplink Assignment
3242  * [3] 10.5.2.25d RR Packet Downlink Assignment
3243  * [3] 10.5.2.26 Page Mode
3244  * [3] 10.5.2.26a (void)
3245  * [3] 10.5.2.26b (void)
3246  * [3] 10.5.2.26c (void)
3247  * [3] 10.5.2.26d (void)
3248  * [3] 10.5.2.27 NCC Permitted
3249  */
3250         DE_RR_POW_CMD,                                  /* 10.5.2.28  Power Command                                             */
3251         DE_RR_POW_CMD_AND_ACC_TYPE,             /* 10.5.2.28a Power Command and access type             */
3252 /*
3253  * [3] 10.5.2.29 RACH Control Parameters
3254  * [3] 10.5.2.30 Request Reference
3255  */
3256     DE_RR_CAUSE,                                        /* 10.5.2.31  RR Cause                                                  */
3257         DE_RR_SYNC_IND,                                 /* 10.5.2.39  Synchronization Indication                */
3258 /* [3] 10.5.2.32 SI 1 Rest Octets
3259  * [3] 10.5.2.33 SI 2bis Rest Octets 
3260  * [3] 10.5.2.33a SI 2ter Rest Octets
3261  * [3] 10.5.2.33b SI 2quater Rest Octets
3262  * [3] 10.5.2.34 SI 3 Rest Octets
3263  * [3] 10.5.2.35 SI 4 Rest Octets
3264  * [3] 10.5.2.35a SI 6 Rest Octets
3265  * [3] 10.5.2.36 SI 7 Rest Octets
3266  * [3] 10.5.2.37 SI 8 Rest Octets
3267  * [3] 10.5.2.37a SI 9 Rest Octets
3268  * [3] 10.5.2.37b SI 13 Rest Octets
3269  * [3] 10.5.2.37c (void)
3270  * [3] 10.5.2.37d (void)
3271  * [3] 10.5.2.37e SI 16 Rest Octets
3272  * [3] 10.5.2.37f SI 17 Rest Octets
3273  * [3] 10.5.2.37g SI 19 Rest Octets
3274  * [3] 10.5.2.37h SI 18 Rest Octets
3275  * [3] 10.5.2.37i SI 20 Rest Octets */
3276         DE_RR_STARTING_TIME,                    /* [3] 10.5.2.38 Starting Time                                  */
3277         DE_RR_TIMING_ADV,                               /* [3] 10.5.2.40 Timing Advance                                 */
3278         DE_RR_TIME_DIFF,                                /* [3] 10.5.2.41 Time Difference                                */
3279         DE_RR_TLLI,                                             /* [3] 10.5.2.41a TLLI                                                  */
3280 /*
3281  * [3] 10.5.2.42 TMSI/P-TMSI */
3282         DE_RR_VGCS_TAR_MODE_IND,                /* [3] 10.5.2.42a VGCS target mode Indication   */
3283         /* Pos 40 */
3284         DE_RR_VGCS_CIP_PAR,                             /* [3] 10.5.2.42b       VGCS Ciphering Parameters       */
3285
3286 /* [3] 10.5.2.43 Wait Indication
3287  * [3] 10.5.2.44 SI10 rest octets $(ASCI)$
3288  * [3] 10.5.2.45 EXTENDED MEASUREMENT RESULTS
3289  * [3] 10.5.2.46 Extended Measurement Frequency List */
3290         DE_RR_SUS_CAU,                                  /* [3] 10.5.2.47 Suspension Cause                               */
3291 /* [3] 10.5.2.48 APDU ID 
3292  * [3] 10.5.2.49 APDU Flags
3293  * [3] 10.5.2.50 APDU Data
3294  * [3] 10.5.2.51 Handover To UTRAN Command
3295  * [3] 10.5.2.52 Handover To cdma2000 Command 
3296  * [3] 10.5.2.53 (void)
3297  * [3] 10.5.2.54 (void)
3298  * [3] 10.5.2.55 (void)
3299  * [3] 10.5.2.56 3G Target Cell */
3300         DE_RR_DED_SERV_INF,                             /* [3] 10.5.2.59        Dedicated Service Information */
3301
3302
3303     /* Mobility Management Information Elements 10.5.3 */
3304     DE_AUTH_PARAM_RAND,                         /* Authentication Parameter RAND */
3305     DE_AUTH_PARAM_AUTN,                         /* Authentication Parameter AUTN (UMTS authentication challenge only) */
3306     DE_AUTH_RESP_PARAM,                         /* Authentication Response Parameter */
3307     DE_AUTH_RESP_PARAM_EXT,                     /* Authentication Response Parameter (extension) (UMTS authentication challenge only) */
3308     DE_AUTH_FAIL_PARAM,                         /* Authentication Failure Parameter (UMTS authentication challenge only) */
3309     DE_CM_SRVC_TYPE,                            /* CM Service Type */
3310     DE_ID_TYPE,                                         /* Identity Type */
3311         /* Pos 50 */
3312     DE_LOC_UPD_TYPE,                            /* Location Updating Type */
3313     DE_NETWORK_NAME,                            /* Network Name */
3314     DE_REJ_CAUSE,                                       /* Reject Cause */
3315     DE_FOP,                                                     /* Follow-on Proceed */
3316     DE_TIME_ZONE,                                       /* Time Zone */
3317     DE_TIME_ZONE_TIME,                          /* Time Zone and Time */
3318     DE_CTS_PERM,                                        /* CTS Permission */
3319     DE_LSA_ID,                                          /* LSA Identifier */
3320     DE_DAY_SAVING_TIME,                         /* Daylight Saving Time */
3321     DE_EMERGENCY_NUM_LIST,                      /* Emergency Number List */
3322     /* Call Control Information Elements 10.5.4 */
3323         /* Pos 60 */
3324     DE_AUX_STATES,                                      /* Auxiliary States */
3325     DE_BEARER_CAP,                                      /* Bearer Capability */
3326     DE_CC_CAP,                                          /* Call Control Capabilities */
3327     DE_CALL_STATE,                                      /* Call State */
3328     DE_CLD_PARTY_BCD_NUM,                       /* Called Party BCD Number */
3329     DE_CLD_PARTY_SUB_ADDR,                      /* Called Party Subaddress */
3330     DE_CLG_PARTY_BCD_NUM,                       /* Calling Party BCD Number */
3331     DE_CLG_PARTY_SUB_ADDR,                      /* Calling Party Subaddress */
3332     DE_CAUSE,                                           /* Cause */
3333     DE_CLIR_SUP,                                        /* CLIR Suppression */
3334     DE_CLIR_INV,                                        /* CLIR Invocation */
3335     DE_CONGESTION,                                      /* Congestion Level */
3336     DE_CONN_NUM,                                        /* Connected Number */
3337     DE_CONN_SUB_ADDR,                           /* Connected Subaddress */
3338     DE_FACILITY,                                        /* Facility */
3339     DE_HLC,                                                     /* High Layer Compatibility */
3340     DE_KEYPAD_FACILITY,                         /* Keypad Facility */
3341     DE_LLC,                                                     /* Low Layer Compatibility */
3342     DE_MORE_DATA,                                       /* More Data */
3343     DE_NOT_IND,                                         /* Notification Indicator */
3344     DE_PROG_IND,                                        /* Progress Indicator */
3345     DE_RECALL_TYPE,                                     /* Recall type $(CCBS)$ */
3346     DE_RED_PARTY_BCD_NUM,                       /* Redirecting Party BCD Number */
3347     DE_RED_PARTY_SUB_ADDR,                      /* Redirecting Party Subaddress */
3348     DE_REPEAT_IND,                                      /* Repeat Indicator */
3349     DE_REV_CALL_SETUP_DIR,                      /* Reverse Call Setup Direction */
3350     DE_SETUP_CONTAINER,                         /* SETUP Container $(CCBS)$ */
3351     DE_SIGNAL,                                          /* Signal */
3352     DE_SS_VER_IND,                                      /* SS Version Indicator */
3353     DE_USER_USER,                                       /* User-user */
3354     DE_ALERT_PATTERN,                           /* Alerting Pattern $(NIA)$ */
3355     DE_ALLOWED_ACTIONS,                         /* Allowed Actions $(CCBS)$ */
3356     DE_SI,                                                      /* Stream Identifier */
3357     DE_NET_CC_CAP,                                      /* Network Call Control Capabilities */
3358     DE_CAUSE_NO_CLI,                            /* Cause of No CLI */
3359     DE_IMM_MOD_IND,                                     /* Immediate Modification Indicator */
3360     DE_SUP_CODEC_LIST,                          /* Supported Codec List */
3361     DE_SRVC_CAT,                                        /* Service Category */
3362     /* GPRS Mobility Management Information Elements 10.5.5 */
3363     DE_ATTACH_RES,                                      /* [7] 10.5.1 Attach Result*/
3364     DE_ATTACH_TYPE,                                     /* [7] 10.5.2 Attach Type */
3365     DE_CIPH_ALG,                                        /* [7] 10.5.3 Cipher Algorithm */
3366     DE_TMSI_STAT,                                       /* [7] 10.5.4 TMSI Status */
3367     DE_DETACH_TYPE,                                     /* [7] 10.5.5 Detach Type */
3368     DE_DRX_PARAM,                                       /* [7] 10.5.6 DRX Parameter */
3369     DE_FORCE_TO_STAND,                          /* [7] 10.5.7 Force to Standby */
3370     DE_FORCE_TO_STAND_H,                        /* [7] 10.5.8 Force to Standby - Info is in the high nibble */
3371     DE_P_TMSI_SIG,                                      /* [7] 10.5.9 P-TMSI Signature */
3372     DE_P_TMSI_SIG_2,                            /* [7] 10.5.10 P-TMSI Signature 2 */
3373     DE_ID_TYPE_2,                                       /* [7] 10.5.11 Identity Type 2 */
3374     DE_IMEISV_REQ,                                      /* [7] 10.5.12 IMEISV Request */
3375     DE_REC_N_PDU_NUM_LIST,                      /* [7] 10.5.13 Receive N-PDU Numbers List */
3376     DE_MS_NET_CAP,                                      /* [7] 10.5.14 MS Network Capability */
3377     DE_MS_RAD_ACC_CAP,                          /* [7] 10.5.15 MS Radio Access Capability */
3378     DE_GMM_CAUSE,                                       /* [7] 10.5.16 GMM Cause */
3379     DE_RAI,                                                     /* [7] 10.5.17 Routing Area Identification */
3380     DE_UPD_RES,                                         /* [7] 10.5.18 Update Result */
3381     DE_UPD_TYPE,                                        /* [7] 10.5.19 Update Type */
3382     DE_AC_REF_NUM,                                      /* [7] 10.5.20 A&C Reference Number */
3383     DE_AC_REF_NUM_H,                            /* A&C Reference Number - Info is in the high nibble */
3384     DE_SRVC_TYPE,                                       /* [7] 10.5.20 Service Type */
3385     DE_CELL_NOT,                                        /* [7] 10.5.21 Cell Notification */
3386     DE_PS_LCS_CAP,                                      /* [7] 10.5.22 PS LCS Capability */
3387     DE_NET_FEAT_SUP,                            /* [7] 10.5.23 Network Feature Support */
3388         DE_RAT_INFO_CONTAINER,                  /* [7] 10.5.24 Inter RAT information container */
3389         /* [7] 10.5.25 Requested MS information */
3390
3391     /* Short Message Service Information Elements [5] 8.1.4 */
3392     DE_CP_USER_DATA,                            /* CP-User Data */
3393     DE_CP_CAUSE,                                        /* CP-Cause */
3394     /* Short Message Service Information Elements [5] 8.2 */
3395     DE_RP_MESSAGE_REF,                          /* RP-Message Reference */
3396     DE_RP_ORIG_ADDR,                            /* RP-Origination Address */
3397     DE_RP_DEST_ADDR,                            /* RP-Destination Address */
3398     DE_RP_USER_DATA,                            /* RP-User Data */
3399     DE_RP_CAUSE,                                        /* RP-Cause */
3400     /* Session Management Information Elements 10.5.6 */
3401     DE_ACC_POINT_NAME,                          /* Access Point Name */
3402     DE_NET_SAPI,                                        /* Network Service Access Point Identifier */
3403     DE_PRO_CONF_OPT,                            /* Protocol Configuration Options */
3404     DE_PD_PRO_ADDR,                                     /* Packet Data Protocol Address */
3405     DE_QOS,                                                     /* Quality Of Service */
3406     DE_SM_CAUSE,                                        /* SM Cause */
3407     DE_LINKED_TI,                                       /* Linked TI */
3408     DE_LLC_SAPI,                                        /* LLC Service Access Point Identifier */
3409     DE_TEAR_DOWN_IND,                           /* Tear Down Indicator */
3410     DE_PACKET_FLOW_ID,                          /* Packet Flow Identifier */
3411     DE_TRAFFIC_FLOW_TEMPLATE,           /* Traffic Flow Template */
3412     /* GPRS Common Information Elements 10.5.7 */
3413     DE_PDP_CONTEXT_STAT,                        /* [8] 10.5.7.1         PDP Context Status */
3414     DE_RAD_PRIO,                                        /* [8] 10.5.7.2         Radio Priority */
3415     DE_GPRS_TIMER,                                      /* [8] 10.5.7.3         GPRS Timer */
3416     DE_GPRS_TIMER_2,                            /* [8] 10.5.7.4         GPRS Timer 2 */
3417     DE_RAD_PRIO_2,                                      /* [8] 10.5.7.5         Radio Priority 2 */
3418         DE_MBMS_CTX_STATUS,                             /* [8] 10.5.7.6         MBMS context status */
3419     DE_SPARE_NIBBLE,                            /* Spare Nibble */
3420     DE_NONE                                                     /* NONE */
3421 }
3422 dtap_elem_idx_t;
3423
3424 #define NUM_GSM_DTAP_ELEM (sizeof(gsm_dtap_elem_strings)/sizeof(value_string))
3425 static gint ett_gsm_dtap_elem[NUM_GSM_DTAP_ELEM];
3426
3427 /* 3GPP TS 24.008
3428  * [3] 10.5.1.1 Cell Identity
3429  */
3430 guint8
3431 de_cell_id(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
3432 {
3433     guint32     curr_offset;
3434
3435     curr_offset = offset;
3436
3437     curr_offset +=
3438         /* 0x02 CI */
3439         be_cell_id_aux(tvb, tree, offset, len, add_string, string_len, 0x02);
3440
3441     /* no length check possible */
3442
3443     return(curr_offset - offset);
3444 }
3445
3446 /*
3447  * [3] 10.5.1.3
3448  */
3449 guint8
3450 de_lai(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
3451 {
3452     guint8      octs[3];
3453     guint16     value;
3454     guint32     curr_offset;
3455     proto_tree  *subtree;
3456     proto_item  *item;
3457     gchar       mcc[4];
3458     gchar       mnc[4];
3459
3460     len = len;
3461     curr_offset = offset;
3462
3463     item =
3464         proto_tree_add_text(tree,
3465             tvb, curr_offset, 5,
3466             gsm_dtap_elem_strings[DE_LAI].strptr);
3467
3468     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_LAI]);
3469
3470     octs[0] = tvb_get_guint8(tvb, curr_offset);
3471     octs[1] = tvb_get_guint8(tvb, curr_offset + 1);
3472     octs[2] = tvb_get_guint8(tvb, curr_offset + 2);
3473
3474     mcc_mnc_aux(octs, mcc, mnc);
3475
3476
3477     proto_tree_add_text(subtree,
3478         tvb, curr_offset, 3,
3479         "Mobile Country Code (MCC): %s, Mobile Network Code (MNC): %s",
3480         mcc,
3481         mnc);
3482
3483     curr_offset += 3;
3484
3485     value = tvb_get_ntohs(tvb, curr_offset);
3486
3487     proto_tree_add_text(subtree,
3488         tvb, curr_offset, 2,
3489         "Location Area Code (LAC): 0x%04x (%u)",
3490         value,
3491         value);
3492
3493     proto_item_append_text(item, " - LAC (0x%04x)", value);
3494
3495     curr_offset += 2;
3496
3497     /* no length check possible */
3498
3499     return(curr_offset - offset);
3500 }
3501
3502 /*
3503  * [3] 10.5.1.4
3504  */
3505 guint8
3506 de_mid(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
3507 {
3508     guint8      oct;
3509     guint32     curr_offset;
3510     guint8      *poctets;
3511     guint32     value;
3512     gboolean    odd;
3513
3514     curr_offset = offset;
3515     odd = FALSE;
3516
3517     oct = tvb_get_guint8(tvb, curr_offset);
3518
3519     switch (oct & 0x07)
3520     {
3521     case 0:     /* No Identity */
3522         other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
3523         proto_tree_add_text(tree,
3524             tvb, curr_offset, 1,
3525             "%s :  Unused",
3526             a_bigbuf);
3527
3528         proto_tree_add_item(tree, hf_gsm_a_odd_even_ind, tvb, curr_offset, 1, FALSE);
3529
3530         proto_tree_add_item(tree, hf_gsm_a_mobile_identity_type, tvb, curr_offset, 1, FALSE);
3531
3532         if (add_string)
3533             g_snprintf(add_string, string_len, " - No Identity Code");
3534
3535         curr_offset++;
3536
3537         if (len > 1)
3538         {
3539             proto_tree_add_text(tree, tvb, curr_offset, len - 1,
3540                 "Format not supported");
3541         }
3542
3543         curr_offset += len - 1;
3544         break;
3545
3546     case 3:     /* IMEISV */
3547
3548         /* FALLTHRU */
3549
3550     case 1:     /* IMSI */
3551
3552         other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
3553         proto_tree_add_text(tree,
3554             tvb, curr_offset, 1,
3555             "%s :  Identity Digit 1: %c",
3556             a_bigbuf,
3557             Dgt1_9_bcd.out[(oct & 0xf0) >> 4]);
3558
3559         odd = oct & 0x08;
3560
3561         proto_tree_add_item(tree, hf_gsm_a_odd_even_ind, tvb, curr_offset, 1, FALSE);
3562
3563         proto_tree_add_item(tree, hf_gsm_a_mobile_identity_type, tvb, curr_offset, 1, FALSE);
3564
3565
3566         a_bigbuf[0] = Dgt1_9_bcd.out[(oct & 0xf0) >> 4];
3567         curr_offset++;
3568
3569         poctets = tvb_get_ephemeral_string(tvb, curr_offset, len - (curr_offset - offset));
3570
3571         my_dgt_tbcd_unpack(&a_bigbuf[1], poctets, len - (curr_offset - offset),
3572             &Dgt1_9_bcd);
3573
3574         proto_tree_add_string_format(tree,
3575             ((oct & 0x07) == 3) ? hf_gsm_a_imeisv : hf_gsm_a_imsi,
3576             tvb, curr_offset, len - (curr_offset - offset),
3577             a_bigbuf,
3578             "BCD Digits: %s",
3579                 a_bigbuf);
3580
3581         if (sccp_assoc && ! sccp_assoc->calling_party) {
3582                 sccp_assoc->calling_party = se_strdup_printf(
3583                         ((oct & 0x07) == 3) ? "IMEISV: %s" : "IMSI: %s",
3584                         a_bigbuf );
3585         }
3586         
3587         if (add_string)
3588             g_snprintf(add_string, string_len, " - %s (%s)",
3589                 ((oct & 0x07) == 3) ? "IMEISV" : "IMSI",
3590                 a_bigbuf);
3591
3592         curr_offset += len - (curr_offset - offset);
3593
3594         if (!odd)
3595         {
3596             oct = tvb_get_guint8(tvb, curr_offset - 1);
3597
3598             other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
3599             proto_tree_add_text(tree,
3600                 tvb, curr_offset - 1, 1,
3601                 "%s :  Filler",
3602                 a_bigbuf);
3603         }
3604         break;
3605
3606     case 2:     /* IMEI */
3607         other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
3608         proto_tree_add_text(tree,
3609             tvb, curr_offset, 1,
3610             "%s :  Identity Digit 1: %c",
3611             a_bigbuf,
3612             Dgt1_9_bcd.out[(oct & 0xf0) >> 4]);
3613
3614         proto_tree_add_item(tree, hf_gsm_a_odd_even_ind, tvb, curr_offset, 1, FALSE);
3615
3616         proto_tree_add_item(tree, hf_gsm_a_mobile_identity_type, tvb, curr_offset, 1, FALSE);
3617
3618
3619         a_bigbuf[0] = Dgt1_9_bcd.out[(oct & 0xf0) >> 4];
3620         curr_offset++;
3621
3622         poctets = tvb_get_ephemeral_string(tvb, curr_offset, len - (curr_offset - offset));
3623
3624         my_dgt_tbcd_unpack(&a_bigbuf[1], poctets, len - (curr_offset - offset),
3625             &Dgt1_9_bcd);
3626
3627         proto_tree_add_string_format(tree,
3628             hf_gsm_a_imei,
3629             tvb, curr_offset, len - (curr_offset - offset),
3630             a_bigbuf,
3631             "BCD Digits: %s",
3632             a_bigbuf);
3633
3634         if (add_string)
3635             g_snprintf(add_string, string_len, " - IMEI (%s)", a_bigbuf);
3636
3637         curr_offset += len - (curr_offset - offset);
3638         break;
3639
3640     case 4:     /* TMSI/P-TMSI */
3641         other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
3642         proto_tree_add_text(tree,
3643             tvb, curr_offset, 1,
3644             "%s :  Unused",
3645             a_bigbuf);
3646
3647         proto_tree_add_item(tree, hf_gsm_a_odd_even_ind, tvb, curr_offset, 1, FALSE);
3648
3649         proto_tree_add_item(tree, hf_gsm_a_mobile_identity_type, tvb, curr_offset, 1, FALSE);
3650
3651
3652         curr_offset++;
3653
3654         value = tvb_get_ntohl(tvb, curr_offset);
3655
3656         proto_tree_add_uint(tree, hf_gsm_a_tmsi,
3657             tvb, curr_offset, 4,
3658             value);
3659
3660         if (add_string)
3661             g_snprintf(add_string, string_len, " - TMSI/P-TMSI (0x%04x)", value);
3662
3663         curr_offset += 4;
3664         break;
3665
3666     default:    /* Reserved */
3667         proto_tree_add_item(tree, hf_gsm_a_odd_even_ind, tvb, curr_offset, 1, FALSE);
3668         proto_tree_add_item(tree, hf_gsm_a_mobile_identity_type, tvb, curr_offset, 1, FALSE);
3669         proto_tree_add_text(tree, tvb, curr_offset, len,
3670             "Mobile station identity Format %u, Format Unknown",(oct & 0x07));
3671
3672         if (add_string)
3673             g_snprintf(add_string, string_len, " - Format Unknown");
3674
3675         curr_offset += len;
3676         break;
3677     }
3678
3679     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
3680
3681     return(curr_offset - offset);
3682 }
3683
3684 /*
3685  * [3] 10.5.1.5
3686  */
3687 guint8
3688 de_ms_cm_1(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
3689 {
3690     guint8      oct;
3691     guint32     curr_offset;
3692     proto_tree  *subtree;
3693     proto_item  *item;
3694     len = len;
3695     curr_offset = offset;
3696
3697     oct = tvb_get_guint8(tvb, curr_offset);
3698
3699     item =
3700         proto_tree_add_text(tree,
3701             tvb, curr_offset, 1,
3702             gsm_dtap_elem_strings[DE_MS_CM_1].strptr);
3703
3704     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_MS_CM_1]);
3705
3706     proto_tree_add_item(tree, hf_gsm_a_b8spare, tvb, curr_offset, 1, FALSE);
3707
3708     proto_tree_add_item(subtree, hf_gsm_a_MSC_rev, tvb, curr_offset, 1, FALSE);
3709
3710         proto_tree_add_item(subtree, hf_gsm_a_ES_IND, tvb, curr_offset, 1, FALSE);
3711
3712         proto_tree_add_item(subtree, hf_gsm_a_A5_1_algorithm_sup, tvb, curr_offset, 1, FALSE);
3713
3714     proto_tree_add_item(subtree, hf_gsm_a_RF_power_capability, tvb, curr_offset, 1, FALSE);
3715
3716     curr_offset++;
3717
3718     /* no length check possible */
3719
3720     return(curr_offset - offset);
3721 }
3722
3723 /*
3724  * [3] 10.5.1.6
3725  */
3726 guint8
3727 de_ms_cm_2(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
3728 {
3729     guint32     curr_offset;
3730     curr_offset = offset;
3731
3732
3733     proto_tree_add_item(tree, hf_gsm_a_b8spare, tvb, curr_offset, 1, FALSE);
3734
3735         proto_tree_add_item(tree, hf_gsm_a_MSC_rev, tvb, curr_offset, 1, FALSE);
3736
3737         proto_tree_add_item(tree, hf_gsm_a_ES_IND, tvb, curr_offset, 1, FALSE);
3738
3739         proto_tree_add_item(tree, hf_gsm_a_A5_1_algorithm_sup, tvb, curr_offset, 1, FALSE);
3740
3741     proto_tree_add_item(tree, hf_gsm_a_RF_power_capability, tvb, curr_offset, 1, FALSE);
3742
3743     curr_offset++;
3744
3745     NO_MORE_DATA_CHECK(len);
3746
3747     proto_tree_add_item(tree, hf_gsm_a_b8spare, tvb, curr_offset, 1, FALSE);
3748
3749     proto_tree_add_item(tree, hf_gsm_a_ps_sup_cap, tvb, curr_offset, 1, FALSE);
3750
3751     proto_tree_add_item(tree, hf_gsm_a_SS_screening_indicator, tvb, curr_offset, 1, FALSE);
3752
3753     /* SM capability (MT SMS pt to pt capability) (octet 4)*/
3754         proto_tree_add_item(tree, hf_gsm_a_SM_capability, tvb, curr_offset, 1, FALSE);
3755         /* VBS notification reception (octet 4) */
3756         proto_tree_add_item(tree, hf_gsm_a_VBS_notification_rec, tvb, curr_offset, 1, FALSE);
3757         /*VGCS notification reception (octet 4)*/
3758         proto_tree_add_item(tree, hf_gsm_a_VGCS_notification_rec, tvb, curr_offset, 1, FALSE);
3759         /* FC Frequency Capability (octet 4 ) */
3760         proto_tree_add_item(tree, hf_gsm_a_FC_frequency_cap, tvb, curr_offset, 1, FALSE);
3761
3762     curr_offset++;
3763
3764     NO_MORE_DATA_CHECK(len);
3765
3766         /* CM3 (octet 5, bit 8) */
3767         proto_tree_add_item(tree, hf_gsm_a_CM3, tvb, curr_offset, 1, FALSE);
3768         /* spare bit 7 */
3769         proto_tree_add_item(tree, hf_gsm_a_b7spare, tvb, curr_offset, 1, FALSE);
3770         /* LCS VA capability (LCS value added location request notification capability) (octet 5,bit 6) */
3771         proto_tree_add_item(tree, hf_gsm_a_LCS_VA_cap, tvb, curr_offset, 1, FALSE);
3772         /* UCS2 treatment (octet 5, bit 5) */
3773         proto_tree_add_item(tree, hf_gsm_a_UCS2_treatment, tvb, curr_offset, 1, FALSE);
3774         /* SoLSA (octet 5, bit 4) */
3775         proto_tree_add_item(tree, hf_gsm_a_SoLSA, tvb, curr_offset, 1, FALSE);
3776         /* CMSP: CM Service Prompt (octet 5, bit 3) */
3777         proto_tree_add_item(tree, hf_gsm_a_CMSP, tvb, curr_offset, 1, FALSE);
3778         /* A5/3 algorithm supported (octet 5, bit 2) */
3779         proto_tree_add_item(tree, hf_gsm_a_A5_3_algorithm_sup, tvb, curr_offset, 1, FALSE);
3780         /* A5/2 algorithm supported (octet 5, bit 1) */
3781         proto_tree_add_item(tree, hf_gsm_a_A5_2_algorithm_sup, tvb, curr_offset, 1, FALSE);
3782
3783     curr_offset++;
3784
3785     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
3786
3787     return(curr_offset - offset);
3788 }
3789
3790 /*
3791  * [3] 10.5.1.9
3792  */
3793
3794 static guint8
3795 de_d_gb_call_ref(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
3796 {
3797     guint8      oct;
3798     guint32     value;
3799     guint32     curr_offset;
3800     const gchar *str;
3801
3802     len = len;
3803     curr_offset = offset;
3804
3805     value = tvb_get_ntohl(tvb, curr_offset);
3806
3807     other_decode_bitfield_value(a_bigbuf, value, 0xffffffe0, 32);
3808     proto_tree_add_text(tree, tvb, curr_offset, 4,
3809         "%s :  Group or Broadcast call reference: %u (0x%04x)",
3810         a_bigbuf,
3811         (value & 0xffffffe0) >> 5,
3812         (value & 0xffffffe0) >> 5);
3813
3814     other_decode_bitfield_value(a_bigbuf, value, 0x00000010, 32);
3815     proto_tree_add_text(tree, tvb, curr_offset, 4,
3816         "%s :  SF Service Flag: %s",
3817         a_bigbuf,
3818         (value & 0x00000010) ?
3819             "VGCS (Group call reference)" : "VBS (Broadcast call reference)");
3820
3821     other_decode_bitfield_value(a_bigbuf, value, 0x00000008, 32);
3822     proto_tree_add_text(tree, tvb, curr_offset, 4,
3823         "%s :  AF Acknowledgement Flag: acknowledgment is %srequired",
3824         a_bigbuf,
3825         (value & 0x00000008) ? "" : "not ");
3826
3827     switch (value & 0x00000007)
3828     {
3829     case 1: str = "call priority level 4"; break;
3830     case 2: str = "call priority level 3"; break;
3831     case 3: str = "call priority level 2"; break;
3832     case 4: str = "call priority level 1"; break;
3833     case 5: str = "call priority level 0"; break;
3834     case 6: str = "call priority level B"; break;
3835     case 7: str = "call priority level A"; break;
3836     default:
3837         str = "no priority applied";
3838         break;
3839     }
3840
3841     other_decode_bitfield_value(a_bigbuf, value, 0x00000007, 32);
3842     proto_tree_add_text(tree, tvb, curr_offset, 4,
3843         "%s :  Call Priority: %s",
3844         a_bigbuf,
3845         str);
3846
3847     curr_offset += 4;
3848
3849     oct = tvb_get_guint8(tvb, curr_offset);
3850
3851     other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
3852     proto_tree_add_text(tree, tvb, curr_offset, 1,
3853         "%s :  Ciphering Information",
3854         a_bigbuf);
3855
3856     other_decode_bitfield_value(a_bigbuf, oct, 0x0f, 8);
3857     proto_tree_add_text(tree, tvb, curr_offset, 1,
3858         "%s :  Spare",
3859         a_bigbuf);
3860
3861     curr_offset++;
3862
3863     /* no length check possible */
3864
3865     return(curr_offset - offset);
3866 }
3867
3868 /*
3869  * [3] 10.5.1.10a
3870  */
3871 static guint8
3872 de_pd_sapi(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
3873 {
3874     guint8      oct;
3875     guint32     curr_offset;
3876     proto_tree  *subtree;
3877     proto_item  *item;
3878     const gchar *str;
3879
3880     len = len;
3881     curr_offset = offset;
3882
3883     oct = tvb_get_guint8(tvb, curr_offset);
3884
3885     item =
3886         proto_tree_add_text(tree,
3887             tvb, curr_offset, 1,
3888             gsm_dtap_elem_strings[DE_PD_SAPI].strptr);
3889
3890     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_PD_SAPI]);
3891
3892     other_decode_bitfield_value(a_bigbuf, oct, 0xc0, 8);
3893     proto_tree_add_text(subtree, tvb, curr_offset, 1,
3894         "%s :  Spare",
3895         a_bigbuf);
3896
3897     switch ((oct & 0x30) >> 4)
3898     {
3899     case 0: str = "SAPI 0"; break;
3900     case 3: str = "SAPI 3"; break;
3901     default:
3902         str = "Reserved";
3903         break;
3904     }
3905
3906     other_decode_bitfield_value(a_bigbuf, oct, 0x30, 8);
3907     proto_tree_add_text(subtree, tvb, curr_offset, 1,
3908         "%s :  SAPI (Sevice Access Point Identifier): %s",
3909         a_bigbuf,
3910         str);
3911
3912     proto_tree_add_item(tree, hf_gsm_a_L3_protocol_discriminator, tvb, curr_offset, 1, FALSE);
3913
3914     curr_offset++;
3915
3916     /* no length check possible */
3917
3918     return(curr_offset - offset);
3919 }
3920
3921 /*
3922  * [3] 10.5.1.11
3923  */
3924
3925 static guint8
3926 de_prio(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
3927 {
3928     guint8      oct;
3929     guint32     curr_offset;
3930     const gchar *str;
3931
3932     len = len;
3933     curr_offset = offset;
3934
3935     oct = tvb_get_guint8(tvb, curr_offset);
3936
3937     other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
3938     proto_tree_add_text(tree,
3939         tvb, curr_offset, 1,
3940         "%s :  Spare",
3941         a_bigbuf);
3942
3943     switch (oct & 0x07)
3944     {
3945     case 1: str = "Call priority level 4"; break;
3946     case 2: str = "Call priority level 3"; break;
3947     case 3: str = "Call priority level 2"; break;
3948     case 4: str = "Call priority level 1"; break;
3949     case 5: str = "Call priority level 0"; break;
3950     case 6: str = "Call priority level B"; break;
3951     case 7: str = "Call priority level A"; break;
3952     default:
3953         str = "No priority applied";
3954         break;
3955     }
3956
3957     other_decode_bitfield_value(a_bigbuf, oct, 0x07, 8);
3958     proto_tree_add_text(tree,
3959         tvb, curr_offset, 1,
3960         "%s :  %s",
3961         a_bigbuf,
3962         str);
3963
3964     curr_offset++;
3965
3966     /* no length check possible */
3967
3968     return(curr_offset - offset);
3969 }
3970
3971 /*
3972  * [3] 10.5.1.13
3973  */
3974 static guint8
3975 de_plmn_list(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
3976 {
3977     guint8      octs[3];
3978     guint32     curr_offset;
3979     gchar       mcc[4];
3980     gchar       mnc[4];
3981     guint8      num_plmn;
3982
3983     curr_offset = offset;
3984
3985     num_plmn = 0;
3986     while ((len - (curr_offset - offset)) >= 3)
3987     {
3988         octs[0] = tvb_get_guint8(tvb, curr_offset);
3989         octs[1] = tvb_get_guint8(tvb, curr_offset + 1);
3990         octs[2] = tvb_get_guint8(tvb, curr_offset + 2);
3991
3992         mcc_mnc_aux(octs, mcc, mnc);
3993
3994         proto_tree_add_text(tree,
3995             tvb, curr_offset, 3,
3996             "PLMN[%u]  Mobile Country Code (MCC): %s, Mobile Network Code (MNC): %s",
3997             num_plmn + 1,
3998             mcc,
3999             mnc);
4000
4001         curr_offset += 3;
4002
4003         num_plmn++;
4004     }
4005
4006     if (add_string)
4007         g_snprintf(add_string, string_len, " - %u PLMN%s",
4008             num_plmn, plurality(num_plmn, "", "s"));
4009
4010     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
4011
4012     return(curr_offset - offset);
4013 }
4014 /*
4015 10.5.2 Radio Resource management information elements
4016  * [3] 10.5.2.1a BA Range
4017  */
4018 /*
4019  * [3] 10.5.2.1b Cell Channel Description
4020  */
4021 static guint8
4022 de_rr_cell_ch_dsc(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4023 {
4024     guint32     curr_offset;
4025     guint8  oct,bit,byte;
4026         guint16 arfcn;
4027         proto_item      *item;
4028
4029
4030     len = len;
4031     curr_offset = offset;
4032
4033     oct = tvb_get_guint8(tvb, curr_offset);
4034
4035         /* FORMAT-ID, Format Identifier (part of octet 3)*/
4036         proto_tree_add_item(tree, hf_gsm_a_rr_format_id, tvb, curr_offset, 1, FALSE);
4037         /* Cell Channel Description */ 
4038
4039         if ((oct & 0xc0) == 0x00)
4040         {
4041                 /* bit map 0 */
4042                 item = proto_tree_add_text(tree,tvb, curr_offset, 16,"list of ARFCN for hopping = ");
4043                 bit = 4;
4044                 arfcn = 125;
4045                 for (byte = 0;byte <= 15;byte++)
4046                 {
4047                         oct = tvb_get_guint8(tvb, curr_offset);
4048                         while (bit-- != 0)
4049                         {
4050                                 arfcn--;
4051                                 if (((oct >> bit) & 1) == 1)
4052                                 {
4053                                         proto_item_append_text(item," %4d",arfcn);
4054                                 }
4055                         }
4056                         bit = 8;
4057                         curr_offset++;
4058                 }
4059         }
4060     else if ((oct & 0xf8) == 0x80)
4061         { 
4062                 /* 1024 range */
4063                 proto_tree_add_text(tree,tvb, curr_offset, 16,"Cell Channel Description (1024 range) (Not decoded)");
4064                 curr_offset = curr_offset + 16;
4065         }
4066         else if ((oct & 0xfe) == 0x88)
4067         {
4068                 /* 512 range */
4069                 proto_tree_add_text(tree,tvb, curr_offset, 16,"Cell Channel Description (512 range) (Not decoded)");
4070                 curr_offset = curr_offset + 16;
4071         }
4072         else if ((oct & 0xfe) == 0x8a)
4073         {
4074                 /* 256 range */
4075                 proto_tree_add_text(tree,tvb, curr_offset, 16,"Cell Channel Description (256 range) (Not decoded)");
4076                 curr_offset = curr_offset + 16;
4077         }
4078         else if ((oct & 0xfe) == 0x8c)
4079         {
4080                 /* 128 range */
4081                 proto_tree_add_text(tree,tvb, curr_offset, 16,"Cell Channel Description (128 range) (Not decoded)");
4082                 curr_offset = curr_offset + 16;
4083         }
4084         else if ((oct & 0xfe) == 0x8e)
4085         {
4086                 /* variable bit map */
4087                 arfcn = ((oct & 0x01) << 9) | (tvb_get_guint8(tvb, curr_offset+1) << 1) | ((tvb_get_guint8(tvb, curr_offset + 2) & 0x80) >> 7);
4088                 item = proto_tree_add_text(tree,tvb, curr_offset, 16,"list of ARFCN for hopping = %d",arfcn);
4089                 curr_offset = curr_offset + 2;
4090                 bit = 7;
4091                 for (byte = 0;byte <= 13;byte++)
4092                 {
4093                         oct = tvb_get_guint8(tvb, curr_offset);
4094                         while (bit-- != 0)
4095                         {
4096                                 arfcn++;
4097                                 if (((oct >> bit) & 1) == 1)
4098                                 {
4099                                         proto_item_append_text(item," %4d",arfcn);
4100                                 }
4101                         }
4102                         bit = 8;
4103                         curr_offset++;
4104                 }
4105         }       
4106         
4107
4108     return(curr_offset - offset);
4109 }
4110 /*
4111  * [3] 10.5.2.1c BA List Pref 
4112  * [3] 10.5.2.1d UTRAN Frequency List 
4113  */
4114 /*
4115  * [3] 10.5.2.2 Cell Description 
4116  */
4117 guint8
4118 de_rr_cell_dsc(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4119 {
4120     proto_tree  *subtree;
4121     proto_item  *item;
4122     guint8      oct;
4123     guint32     curr_offset;
4124         guint16 bcch_arfcn;
4125
4126     len = len;
4127     curr_offset = offset;
4128
4129     oct = tvb_get_guint8(tvb, curr_offset);
4130         item =
4131         proto_tree_add_text(tree,
4132             tvb, curr_offset, 2,
4133             gsm_dtap_elem_strings[DE_RR_CELL_DSC].strptr);
4134
4135     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_RR_CELL_DSC]);
4136
4137         proto_tree_add_item(subtree, hf_gsm_a_ncc, tvb, curr_offset, 1, FALSE);
4138         proto_tree_add_item(subtree, hf_gsm_a_bcc, tvb, curr_offset, 1, FALSE);
4139         bcch_arfcn = (tvb_get_guint8(tvb,curr_offset) & 0xc0) << 2;
4140         bcch_arfcn = bcch_arfcn | tvb_get_guint8(tvb,curr_offset+1);
4141         proto_tree_add_uint(subtree, hf_gsm_a_bcch_arfcn , tvb, curr_offset, 2, bcch_arfcn );
4142
4143
4144     curr_offset = curr_offset + 2;
4145
4146
4147     return(curr_offset - offset);
4148 }
4149 /*
4150  * [3] 10.5.2.3 Cell Options (BCCH) 
4151  * [3] 10.5.2.3a Cell Options (SACCH) 
4152  * [3] 10.5.2.4 Cell Selection Parameters
4153  * [3] 10.5.2.4a MAC Mode and Channel Coding Requested 
4154  * [3] 10.5.2.5 Channel Description
4155  */
4156 static guint8
4157 de_rr_ch_dsc(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4158 {
4159     guint32     curr_offset;
4160     guint8      oct8,subchannel;
4161     guint16 arfcn, hsn, maio;
4162         proto_tree      *subtree;
4163         proto_item      *item;
4164     const gchar *str;
4165
4166     len = len;
4167     curr_offset = offset;
4168
4169     item = proto_tree_add_text(tree,tvb, curr_offset, 3,gsm_dtap_elem_strings[DE_RR_CH_DSC].strptr);
4170
4171         subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_RR_CH_DSC]);
4172
4173     /* Octet 2 */
4174     oct8 = tvb_get_guint8(tvb, curr_offset);
4175     
4176     if ((oct8 & 0xf8) == 0x08)
4177     {
4178         str = "TCH/F + ACCHs"; 
4179                 other_decode_bitfield_value(a_bigbuf, oct8, 0xf8, 8);
4180         proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = %s",a_bigbuf,str);
4181     }
4182     else 
4183     {
4184         if ((oct8 & 0xf0) == 0x10) 
4185         {
4186                 str = "TCH/H + ACCHs, Subchannel";
4187                 subchannel = ((oct8 & 0x08)>>3);
4188         }
4189         else if ((oct8 & 0xe0) == 0x20)
4190         {
4191                 str = "SDCCH/4 + SACCH/C4 or CBCH (SDCCH/4), Subchannel";
4192                 subchannel = ((oct8 & 0x18)>>3);
4193         }
4194         else if ((oct8 & 0xc0) == 0x40)
4195         {
4196                 str = "SDCCH/8 + SACCH/C8 or CBCH (SDCCH/8), Subchannel";
4197                 subchannel = ((oct8 % 0x38)>>3);
4198                 } else {
4199                         str = "";
4200                         subchannel = 0;
4201                         DISSECTOR_ASSERT_NOT_REACHED();
4202                 }
4203                 
4204                 other_decode_bitfield_value(a_bigbuf, oct8, 0xf8, 8);
4205         proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = %s %d",a_bigbuf,str,subchannel);
4206     }
4207
4208         other_decode_bitfield_value(a_bigbuf, oct8, 0x07, 8);
4209     proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Timeslot: %d",a_bigbuf,(oct8 & 0x07));
4210
4211         curr_offset +=1;
4212                 
4213         /* Octet 3 */
4214         oct8 = tvb_get_guint8(tvb, curr_offset);
4215     other_decode_bitfield_value(a_bigbuf, oct8, 0xe0, 8);
4216         proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Training Sequence: %d",a_bigbuf,((oct8 & 0xe0)>>5));
4217                 
4218     
4219         if ((oct8 & 0x10) == 0x10)
4220         {
4221                 /* Hopping sequence */
4222                 maio = ((oct8 & 0x0f)<<2) | ((tvb_get_guint8(tvb,curr_offset+1) & 0xc0) >> 6);
4223                 hsn = (tvb_get_guint8(tvb,curr_offset+1) & 0x3f);
4224                 str = "Yes";
4225
4226                 other_decode_bitfield_value(a_bigbuf, oct8, 0x10, 8);
4227                 proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Hopping channel: %s",a_bigbuf,str);
4228                 proto_tree_add_text(subtree,tvb, curr_offset, 2,"Hopping channel: MAIO %d",maio);
4229                 proto_tree_add_text(subtree,tvb, curr_offset, 2,"Hopping channel: HSN %d",hsn);
4230         }
4231         else
4232         {
4233                 /* sinlge ARFCN */
4234                 arfcn = ((oct8 & 0x03) << 8) | tvb_get_guint8(tvb,curr_offset+1);
4235                 str = "No";
4236
4237                 other_decode_bitfield_value(a_bigbuf, oct8, 0x10, 8);
4238                 proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Hopping channel: %s",a_bigbuf,str);
4239                 other_decode_bitfield_value(a_bigbuf, oct8, 0x0c, 8);
4240                 proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Spare",a_bigbuf);
4241                 proto_tree_add_text(subtree,tvb, curr_offset, 2,"Single channel : ARFCN %d",arfcn);
4242         }
4243                 
4244         curr_offset = curr_offset + 2;
4245
4246     return(curr_offset - offset);
4247 }
4248 /*
4249  * [3] 10.5.2.5a Channel Description 2
4250  */
4251 static guint8
4252 de_rr_ch_dsc2(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4253 {
4254     guint32     curr_offset;
4255     guint8      oct8,subchannel;
4256     guint16 arfcn, hsn, maio;
4257         proto_tree      *subtree;
4258         proto_item      *item;
4259     const gchar *str;
4260
4261     len = len;
4262     curr_offset = offset;
4263
4264     item = proto_tree_add_text(tree,tvb, curr_offset, 3,gsm_dtap_elem_strings[DE_RR_CH_DSC2].strptr);
4265
4266         subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_RR_CH_DSC2]);
4267
4268     /* Octet 2 */
4269     oct8 = tvb_get_guint8(tvb, curr_offset);
4270     
4271     if ((oct8 & 0xf8) == 0x0)
4272     {
4273         str = "TCH/F + FACCH/F and SACCH/M"; 
4274                 other_decode_bitfield_value(a_bigbuf, oct8, 0xf8, 8);
4275         proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = %s",a_bigbuf,str);
4276     }
4277         else if ((oct8 & 0xf8) == 0x08)
4278     {
4279         str = "TCH/F + FACCH/F and SACCH/F"; 
4280                 other_decode_bitfield_value(a_bigbuf, oct8, 0xf8, 8);
4281         proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = %s",a_bigbuf,str);
4282     }
4283         else if ((oct8 & 0xf8) == 0xf0)
4284         {
4285                 str = "TCH/F + FACCH/F and SACCH/M + bi- and unidirectional channels";
4286                 other_decode_bitfield_value(a_bigbuf, oct8, 0xf8, 8);
4287         proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = %s",a_bigbuf,str);
4288         }
4289     else 
4290     {
4291         if ((oct8 & 0xf0) == 0x10) 
4292         {
4293                 str = "TCH/H + ACCHs, Subchannel";
4294                 subchannel = ((oct8 & 0x08)>>3);
4295         }
4296         else if ((oct8 & 0xe0) == 0x20)
4297         {
4298                 str = "SDCCH/4 + SACCH/C4 or CBCH (SDCCH/4), Subchannel";
4299                 subchannel = ((oct8 & 0x18)>>3);
4300         }
4301         else if ((oct8 & 0xc0) == 0x40)
4302         {
4303                 str = "SDCCH/8 + SACCH/C8 or CBCH (SDCCH/8), Subchannel";
4304                 subchannel = ((oct8 % 0x38)>>3);
4305                 }
4306                 else if ((oct8 & 0xc0) == 0x80)
4307                 {
4308                         str = "TCH/F + FACCH/F and SACCH/M + bidirectional channels at timeslot";
4309                         subchannel = ((oct8 % 0x38)>>3);
4310                 }
4311                 else if ((oct8 & 0xe0) == 0xc0)
4312                 {
4313                         str = "TCH/F + FACCH/F and SACCH/M + unidirectional channels at timeslot";
4314                         subchannel = ((oct8 % 0x38)>>3);
4315                 } else {
4316                         str = "";
4317                         subchannel = 0;
4318                         DISSECTOR_ASSERT_NOT_REACHED();
4319                 }
4320                 other_decode_bitfield_value(a_bigbuf, oct8, 0xf8, 8);
4321         proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = %s %d",a_bigbuf,str,subchannel);
4322     }
4323
4324         other_decode_bitfield_value(a_bigbuf, oct8, 0x07, 8);
4325     proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Timeslot: %d",a_bigbuf,(oct8 & 0x07));
4326
4327         curr_offset +=1;
4328                 
4329         /* Octet 3 */
4330         oct8 = tvb_get_guint8(tvb, curr_offset);
4331     other_decode_bitfield_value(a_bigbuf, oct8, 0xe0, 8);
4332         proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Training Sequence: %d",a_bigbuf,((oct8 & 0xe0)>>5));
4333                 
4334     
4335         if ((oct8 & 0x10) == 0x10)
4336         {
4337                 /* Hopping sequence */
4338                 maio = ((oct8 & 0x0f)<<2) | ((tvb_get_guint8(tvb,curr_offset+1) & 0xc0) >> 6);
4339                 hsn = (tvb_get_guint8(tvb,curr_offset+1) & 0x3f);
4340                 str = "Yes";
4341
4342                 other_decode_bitfield_value(a_bigbuf, oct8, 0x10, 8);
4343                 proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Hopping channel: %s",a_bigbuf,str);
4344                 proto_tree_add_text(subtree,tvb, curr_offset, 2,"Hopping channel: MAIO %d",maio);
4345                 proto_tree_add_text(subtree,tvb, curr_offset, 2,"Hopping channel: HSN %d",hsn);
4346         }
4347         else
4348         {
4349                 /* sinlge ARFCN */
4350                 arfcn = ((oct8 & 0x03) << 8) | tvb_get_guint8(tvb,curr_offset+1);
4351                 str = "No";
4352
4353                 other_decode_bitfield_value(a_bigbuf, oct8, 0x10, 8);
4354                 proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Hopping channel: %s",a_bigbuf,str);
4355                 other_decode_bitfield_value(a_bigbuf, oct8, 0x0c, 8);
4356                 proto_tree_add_text(subtree,tvb, curr_offset, 1,"%s = Spare",a_bigbuf);
4357                 proto_tree_add_text(subtree,tvb, curr_offset, 2,"Single channel : ARFCN %d",arfcn);
4358         }
4359                 
4360         curr_offset = curr_offset + 2;
4361
4362     return(curr_offset - offset);
4363 }
4364 /*
4365  * [3] 10.5.2.6 Channel Mode
4366  */
4367
4368 /* Channel Mode  */
4369 static const value_string gsm_a_rr_channel_mode_vals[] = {
4370 { 0x00,         "signalling only"},
4371 { 0x01,         "speech full rate or half rate version 1(GSM FR or GSM HR)"},
4372 { 0x21,         "speech full rate or half rate version 2(GSM EFR)"},
4373 { 0x41,         "speech full rate or half rate version 3(FR AMR or HR AMR)"},
4374 { 0x81,         "speech full rate or half rate version 4(OFR AMR-WB or OHR AMR-WB)"},
4375 { 0x82,         "speech full rate or half rate version 5(FR AMR-WB )"},
4376 { 0x83,         "speech full rate or half rate version 6(OHR AMR )"},
4377 { 0x61,         "data, 43.5 kbit/s (downlink)+14.5 kbps (uplink)"},
4378 { 0x62,         "data, 29.0 kbit/s (downlink)+14.5 kbps (uplink)"},
4379 { 0x64,         "data, 43.5 kbit/s (downlink)+29.0 kbps (uplink)"},
4380 { 0x67,         "data, 14.5 kbit/s (downlink)+43.5 kbps (uplink)"},
4381 { 0x65,         "data, 14.5 kbit/s (downlink)+29.0 kbps (uplink)"},
4382 { 0x66,         "data, 29.0 kbit/s (downlink)+43.5 kbps (uplink)"},
4383 { 0x27,         "data, 43.5 kbit/s radio interface rate"},
4384 { 0x63,         "data, 32.0 kbit/s radio interface rate"},
4385 { 0x43,         "data, 29.0 kbit/s radio interface rate"},
4386 { 0x0f,         "data, 14.5 kbit/s radio interface rate"},
4387 { 0x03,         "data, 12.0 kbit/s radio interface rate"},
4388 { 0x0b,         "data, 6.0 kbit/s radio interface rate"},
4389 { 0x13,         "data, 3.6 kbit/s radio interface rate"},
4390         { 0,    NULL }
4391 };
4392
4393 guint8
4394 de_rr_ch_mode(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4395 {
4396     guint32     curr_offset;
4397
4398     len = len;
4399     curr_offset = offset;
4400
4401     proto_tree_add_item(tree, hf_gsm_a_rr_channel_mode, tvb, curr_offset, 1, FALSE);
4402         
4403         curr_offset = curr_offset + 1;
4404
4405     return(curr_offset - offset);
4406 }
4407 /*
4408  * [3] 10.5.2.7 Channel Mode 2 
4409  */
4410
4411 static const value_string gsm_a_rr_channel_mode2_vals[] = {
4412 { 0x00,         "signalling only"},
4413 { 0x05,         "speech half rate version 1(GSM HR)"},
4414 { 0x25,         "speech half rate version 2(GSM EFR)"},
4415 { 0x45,         "speech half rate version 3(HR AMR)"},
4416 { 0x85,         "speech half rate version 4(OHR AMR-WB)"},
4417 { 0x06,         "speech half rate version 6(OHR AMR )"},
4418 { 0x0f,         "data, 6.0 kbit/s radio interface rate"},
4419 { 0x17,         "data, 3.6 kbit/s radio interface rate"},
4420         { 0,    NULL }
4421 };
4422
4423 static guint8
4424 de_rr_ch_mode2(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4425 {
4426     guint32     curr_offset;
4427
4428     len = len;
4429     curr_offset = offset;
4430
4431     proto_tree_add_item(tree, hf_gsm_a_rr_channel_mode2, tvb, curr_offset, 1, FALSE);
4432         
4433         curr_offset = curr_offset + 1;
4434
4435     return(curr_offset - offset);
4436 }  
4437 /*
4438  * [3] 10.5.2.7a UTRAN Classmark information element
4439  * [3] 10.5.2.7b (void)
4440  */
4441 /*
4442  * [3] 10.5.2.7c Classmark Enquiry Mask
4443  * Bit 8:
4444  * 0    CLASSMARK CHANGE message is requested
4445  * 1    CLASSMARK CHANGE message is not requested
4446  * Bits 7-5 . 5
4447  * 000  UTRAN CLASSMARK CHANGE message including status on predefined configurations (i.e. Sequence Description) is requested
4448  * 111  UTRAN CLASSMARK CHANGE message including status on predefined configurations (i.e. Sequence Description) is not requested.
4449  * All other values shall not be sent. If received, they shall be interpreted as '000'.
4450  * Bit 4:
4451  * 0    CDMA2000 CLASSMARK CHANGE message requested
4452  * 1    CDMA2000 CLASSMARK CHANGE message not requested.
4453  * Bit 3:
4454  * 0    GERAN IU MODE CLASSMARK CHANGE message requested
4455  * 1    GERAN IU MODE CLASSMARK CHANGE message not requested.
4456  * Bits 2 - 1: spare(0).
4457  */
4458 static const true_false_string gsm_a_msg_req_value  = {
4459   "message is not requested",
4460   "message is requested"
4461 };
4462 static const value_string gsm_a_rr_utran_cm_cng_msg_req_vals[] = {
4463 { 0x0,          "message including status on predefined configurations (i.e. Sequence Description) is requested"},
4464 { 0x1,          "message including status on predefined configurations (i.e. Sequence Description) is requested"},
4465 { 0x2,          "message including status on predefined configurations (i.e. Sequence Description) is requested"},
4466 { 0x3,          "message including status on predefined configurations (i.e. Sequence Description) is requested"},
4467 { 0x4,          "message including status on predefined configurations (i.e. Sequence Description) is requested"},
4468 { 0x5,          "message including status on predefined configurations (i.e. Sequence Description) is requested"},
4469 { 0x6,          "message including status on predefined configurations (i.e. Sequence Description) is requested"},
4470 { 0x7,          "message including status on predefined configurations (i.e. Sequence Description) is not requested."},
4471         { 0,    NULL }
4472 };
4473 guint8
4474 de_rr_cm_enq_mask(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4475 {
4476     guint32     curr_offset;
4477
4478     len = len;
4479     curr_offset = offset;
4480         
4481         proto_tree_add_item(tree, hf_gsm_a_rr_cm_cng_msg_req, tvb, curr_offset, 1, FALSE);
4482         proto_tree_add_item(tree, hf_gsm_a_rr_utran_cm_cng_msg_req, tvb, curr_offset, 1, FALSE);
4483         proto_tree_add_item(tree, hf_gsm_a_rr_cdma200_cm_cng_msg_req, tvb, curr_offset, 1, FALSE);
4484         proto_tree_add_item(tree, hf_gsm_a_rr_geran_iu_cm_cng_msg_req, tvb, curr_offset, 1, FALSE);
4485
4486         curr_offset = curr_offset + 1;
4487
4488     return(curr_offset - offset);
4489 }
4490 /*
4491  * [3] 10.5.2.8 Channel Needed
4492  */
4493 static const value_string gsm_a_rr_channel_needed_vals[] = {
4494 { 0x00,         "Any channel"},
4495 { 0x01,         "SDCCH"},
4496 { 0x02,         "TCH/F (Full rate)"},
4497 { 0x03,         "TCH/H or TCH/F (Dual rate)"},
4498         { 0,    NULL }
4499 };
4500 guint8
4501 de_rr_chnl_needed(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4502 {
4503     guint32     curr_offset;
4504
4505     len = len;
4506     curr_offset = offset;
4507         
4508         proto_tree_add_item(tree, hf_gsm_a_rr_chnl_needed_ch1, tvb, curr_offset, 1, FALSE);
4509         proto_tree_add_item(tree, hf_gsm_a_rr_chnl_needed_ch2, tvb, curr_offset, 1, FALSE);
4510
4511         curr_offset = curr_offset + 1;
4512
4513     return(curr_offset - offset);
4514 }
4515 /*
4516  * [3] 10.5.2.8a Channel Request Description
4517  * [3] 10.5.2.8b Channel Request Description 2
4518  */
4519 /*
4520  * [3] 10.5.2.9 Cipher Mode Setting
4521  */
4522 /* SC (octet 1) */
4523 static const value_string gsm_a_rr_sc_vals[] = {
4524         { 0,            "No ciphering"},
4525         { 1,            "Start ciphering"},
4526         { 0,    NULL }
4527 };
4528 /* algorithm identifier
4529  * If SC=1 then:
4530  * bits
4531  * 4 3 2
4532  */
4533
4534 guint8
4535 de_rr_cip_mode_set(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4536 {
4537     guint32     curr_offset;
4538         guint8 oct;
4539
4540     len = len;
4541     curr_offset = offset;               
4542
4543         /* Cipher Mode Setting
4544                  * Note: The coding of fields SC and algorithm identifier is defined in [44.018] 
4545                  * as part of the Cipher Mode Setting IE.
4546                  */
4547                 proto_tree_add_item(tree, hf_gsm_a_rr_sc, tvb, curr_offset, 1, FALSE);
4548                 oct = tvb_get_guint8(tvb,curr_offset);
4549                 if ( (oct & 1) == 1){ /* Start ciphering */
4550                         /* algorithm identifier */
4551                         proto_tree_add_item(tree, hf_gsm_a_algorithm_id, tvb, curr_offset, 1, FALSE);
4552                 }
4553         curr_offset = curr_offset + 1;
4554
4555     return(curr_offset - offset);
4556 }
4557 /*
4558  * [3] 10.5.2.10 Cipher Response
4559  * [3] 10.5.2.11 Control Channel Description
4560  * [3] 10.5.2.11a DTM Information Details
4561  */
4562 /* 
4563  * [3]  10.5.2.11b      Dynamic ARFCN Mapping           
4564  */
4565 static guint8
4566 de_rr_dyn_arfcn_map(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4567 {
4568     guint32     curr_offset;
4569
4570     len = len;
4571     curr_offset = offset;
4572
4573         proto_tree_add_text(tree,tvb, curr_offset, len,"Dynamic ARFCN Mapping content(Not decoded)");
4574
4575         
4576         curr_offset = curr_offset + len;
4577
4578     return(curr_offset - offset);
4579 }  
4580 /*
4581  * [3] 10.5.2.12 Frequency Channel Sequence
4582  */
4583 static guint8
4584 de_rr_freq_ch_seq(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4585 {
4586     guint32     curr_offset;
4587
4588     len = len;
4589     curr_offset = offset;
4590
4591         proto_tree_add_text(tree,tvb, curr_offset, 9,"Frequency Channel Sequence(Not decoded)");
4592
4593         
4594         curr_offset = curr_offset + 9;
4595
4596     return(curr_offset - offset);
4597 }  
4598 /*
4599  * [3] 10.5.2.13 Frequency List
4600  * 
4601  * Bit Bit Bit Bit Bit format notation
4602  * 8 7  4 3 2
4603  * 0 0  X X X bit map 0
4604  * 1 0  0 X X 1024 range
4605  * 1 0  1 0 0 512 range
4606  * 1 0  1 0 1 256 range
4607  * 1 0  1 1 0 128 range
4608  * 1 0  1 1 1 variable bit map
4609  */
4610 /* The mask 0xce (1100 1110) will produce the result 0110 0111*/ 
4611 static const value_string gsm_a_rr_freq_list_format_id_vals[] = {
4612         { 0x00,         "bit map 0"},
4613         { 0x02,         "bit map 0"},
4614         { 0x04,         "bit map 0"},
4615         { 0x06,         "bit map 0"},
4616         { 0x08,         "bit map 0"},
4617         { 0x0a,         "bit map 0"},
4618         { 0x0c,         "bit map 0"},
4619         { 0x0e,         "bit map 0"},
4620         { 0x40,         "1024 range"},
4621         { 0x41,         "1024 range"},
4622         { 0x42,         "1024 range"},
4623         { 0x43,         "1024 range"},
4624         { 0x44,         "512 range"},
4625         { 0x45,         "256 range"},
4626         { 0x46,         "128 range"},
4627         { 0x47,         "variable bit map"},
4628         { 0x00, NULL }
4629 };
4630 static guint8
4631 de_rr_freq_list(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4632 {
4633     guint32     curr_offset;
4634
4635     len = len;
4636     curr_offset = offset;
4637
4638         /* FORMAT-ID, Format Identifier (part of octet 3)*/
4639         proto_tree_add_item(tree, hf_gsm_a_rr_format_id, tvb, curr_offset, 1, FALSE);
4640         /* Frequency list */ 
4641         proto_tree_add_text(tree,tvb, curr_offset, len-1,"Frequency Data(Not decoded)");
4642
4643         curr_offset = curr_offset + len;
4644     return(curr_offset - offset);
4645
4646 }
4647 /*
4648  * [3] 10.5.2.13.1 General description
4649  * [3] 10.5.2.13.2 Bit map 0 format
4650  * [3] 10.5.2.13.3 Range 1024 format
4651  * [3] 10.5.2.13.4 Range 512 format
4652  * [3] 10.5.2.13.5 Range 256 format
4653  * [3] 10.5.2.13.6 Range 128 format
4654  * [3] 10.5.2.13.7 Variable bit map format
4655  */
4656 /*
4657  * [3] 10.5.2.14 Frequency Short List
4658  *
4659  *The Frequency Short List information element is a type 3 information element of 10 octet length.
4660  *
4661  * This element is encoded exactly as the Frequency List information element, 
4662  * except that it has a fixed length instead of a variable length and does 
4663  * not contain a length indicator and that it shall not be encoded in bitmap 0 format.
4664  */
4665 static guint8
4666 de_rr_freq_short_list(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4667 {
4668     guint32     curr_offset;
4669
4670     len = len;
4671     curr_offset = offset;
4672
4673         /* FORMAT-ID, Format Identifier (part of octet 3)*/
4674         proto_tree_add_item(tree, hf_gsm_a_rr_format_id, tvb, curr_offset, 1, FALSE);
4675         /* Frequency list */ 
4676         proto_tree_add_text(tree,tvb, curr_offset, 9,"Frequency Data(Not decoded)");
4677
4678         curr_offset = curr_offset + 9;
4679     return(curr_offset - offset);
4680
4681 }
4682 /*
4683  * [3] 10.5.2.14a Frequency Short List 2
4684  *
4685  * The Frequency Short List information element is a type 3 information element of 8 octet length.
4686  *
4687  * This element is encoded exactly as the Frequency List information element, 
4688  * except that it has a fixed length instead of a variable length and does 
4689  * not contain a length indicator and that it shall not be encoded in bitmap 0 format.
4690  */
4691 static guint8
4692 de_rr_freq_short_list2(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4693 {
4694     guint32     curr_offset;
4695
4696     len = len;
4697     curr_offset = offset;
4698
4699         /* FORMAT-ID, Format Identifier (part of octet 3)*/
4700         proto_tree_add_item(tree, hf_gsm_a_rr_format_id, tvb, curr_offset, 1, FALSE);
4701
4702         /* Frequency list */ 
4703         proto_tree_add_text(tree,tvb, curr_offset, 7,"Frequency Data(Not decoded)");
4704
4705         curr_offset = curr_offset + 8;
4706     return(curr_offset - offset);
4707
4708 }
4709 /*
4710  * [3] 10.5.2.14b Group Channel Description
4711  * [3] 10.5.2.14c GPRS Resumption
4712  * [3] 10.5.2.14d GPRS broadcast information
4713  */
4714 /*
4715  * [3] 10.5.2.15 Handover Reference
4716  */
4717 static guint8
4718 de_rr_ho_ref(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4719 {
4720     proto_tree  *subtree;
4721     proto_item  *item;
4722     guint32     curr_offset;
4723
4724     len = len;
4725     curr_offset = offset;
4726
4727         item =
4728         proto_tree_add_text(tree,
4729             tvb, curr_offset, 1,
4730             gsm_dtap_elem_strings[DE_RR_HO_REF].strptr);
4731
4732     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_RR_HO_REF]);
4733
4734         /* Handover reference value */
4735     proto_tree_add_item(subtree, hf_gsm_a_rr_ho_ref_val, tvb, curr_offset, 1, FALSE);
4736         
4737         curr_offset = curr_offset + 1;
4738
4739     return(curr_offset - offset);
4740 }
4741 /*
4742  * [3] 10.5.2.16 IA Rest Octets
4743  * [3] 10.5.2.17 IAR Rest Octets
4744  * [3] 10.5.2.18 IAX Rest Octets
4745  * [3] 10.5.2.19 L2 Pseudo Length
4746  * [3] 10.5.2.20 Measurement Results
4747  * [3] 10.5.2.20a GPRS Measurement Results
4748  */
4749 /*
4750  * [3] 10.5.2.21 Mobile Allocation
4751  */
4752 static guint8
4753 de_rr_mob_all(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4754 {
4755     guint32     curr_offset;
4756
4757     len = len;
4758     curr_offset = offset;
4759
4760         proto_tree_add_text(tree,tvb, curr_offset, len ,"Data(Not decoded)");
4761
4762         curr_offset = curr_offset + len;
4763     return(curr_offset - offset);
4764
4765 }
4766 /*
4767  * [3] 10.5.2.21a Mobile Time Difference
4768  */
4769 static guint8
4770 de_rr_mob_time_diff(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.21aa MultiRate configuration
4785  */
4786 /*      Multirate speech version Octet 3 Bits 8 7 6 */
4787 static const value_string multirate_speech_ver_vals[] = {
4788         { 1,            "Adaptive Multirate speech version 1"},
4789         { 2,            "Adaptive Multirate speech version 2"},
4790         { 0,    NULL }
4791 };
4792 /* Bit  5       NSCB: Noise Suppression Control Bit */
4793 static const value_string NSCB_vals[] = {
4794         { 0,            "Noise Suppression can be used (default)"},
4795         { 1,            "Noise Suppression shall be turned off"},
4796         { 0,    NULL }
4797 };
4798 /* Bit  4       ICMI: Initial Codec Mode Indicator */
4799 static const value_string ICMI_vals[] = {
4800         { 0,            "The initial codec mode is defined by the implicit rule provided in 3GPP TS 05.09"},
4801         { 1,            "The initial codec mode is defined by the Start Mode field"},
4802         { 0,    NULL }
4803 };
4804 /*
4805 Table 10.5.2.21aa.2: Set of adaptive multirate codec modes field (octet 4)
4806 for the Multirate speech version 1
4807 */
4808 static const true_false_string gsm_a_rr_set_of_amr_codec_modes  = {
4809   "is part of the subset",
4810   "is not part of the subset"
4811 };
4812
4813
4814
4815 guint8
4816 de_rr_multirate_conf(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4817 {
4818     guint32     curr_offset;
4819         guint8 oct;
4820
4821     len = len;
4822     curr_offset = offset;
4823
4824         proto_tree_add_item(tree, hf_gsm_a_rr_multirate_speech_ver, tvb, curr_offset, 1, FALSE);
4825         proto_tree_add_item(tree, hf_gsm_a_rr_NCSB, tvb, curr_offset, 1, FALSE);
4826         proto_tree_add_item(tree, hf_gsm_a_rr_ICMI, tvb, curr_offset, 1, FALSE);
4827         /* The initial codec mode is coded as in 3GPP TS 45.009 */
4828         proto_tree_add_item(tree, hf_gsm_a_rr_start_mode, tvb, curr_offset, 1, FALSE);
4829         oct = ( tvb_get_guint8(tvb,curr_offset) &0xe0 ) >> 5;
4830         curr_offset++;
4831         switch ( oct){
4832         case 1:
4833                 /* Adaptive Multirate speech version 1 */
4834                 /* Set of AMR codec modes */
4835                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v1_b8, tvb, curr_offset, 1, FALSE);
4836                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v1_b7, tvb, curr_offset, 1, FALSE);
4837                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v1_b6, tvb, curr_offset, 1, FALSE);
4838                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v1_b5, tvb, curr_offset, 1, FALSE);
4839                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v1_b4, tvb, curr_offset, 1, FALSE);
4840                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v1_b3, tvb, curr_offset, 1, FALSE);
4841                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v1_b2, tvb, curr_offset, 1, FALSE);
4842                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v1_b1, tvb, curr_offset, 1, FALSE);
4843                 curr_offset++;
4844
4845                 proto_tree_add_text(tree,tvb, curr_offset, len-2 ,"Parameters for multirate speech field(Not decoded)");
4846
4847                 break;
4848         case 2:
4849                 /* Adaptive Multirate speech version 2 */
4850                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v2_b5, tvb, curr_offset, 1, FALSE);
4851                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v2_b4, tvb, curr_offset, 1, FALSE);
4852                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v2_b3, tvb, curr_offset, 1, FALSE);
4853                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v2_b2, tvb, curr_offset, 1, FALSE);
4854                 proto_tree_add_item(tree, hf_gsm_a_rr_set_of_amr_codec_modes_v2_b1, tvb, curr_offset, 1, FALSE);
4855                 curr_offset++;
4856
4857                 proto_tree_add_text(tree,tvb, curr_offset, len-2 ,"Parameters for multirate speech field(Not decoded)");
4858                 break;
4859         default:
4860                 proto_tree_add_text(tree,tvb,offset,1,"Unknown version");
4861                 proto_tree_add_text(tree,tvb, curr_offset, len-1 ,"Data(Not decoded)");
4862                         break;
4863         }
4864
4865         curr_offset = offset + len;
4866     return(curr_offset - offset);
4867
4868 }
4869 /*
4870  * [3] 10.5.2.21b Multislot Allocation
4871  */
4872 static guint8
4873 de_rr_mult_all(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4874 {
4875     guint32     curr_offset;
4876
4877     len = len;
4878     curr_offset = offset;
4879
4880         proto_tree_add_text(tree,tvb, curr_offset, len ,"Data(Not decoded)");
4881
4882         curr_offset = curr_offset + len;
4883     return(curr_offset - offset);
4884
4885 }
4886 /*
4887  * [3] 10.5.2.21c NC mode
4888  * [3] 10.5.2.22 Neighbour Cell Description
4889  * [3] 10.5.2.22a Neighbour Cell Description 2
4890  * [3] 10.5.2.22b (void)
4891  * [3] 10.5.2.22c NT/N Rest Octets
4892  * [3] 10.5.2.23 P1 Rest Octets
4893  * [3] 10.5.2.24 P2 Rest Octets
4894  * [3] 10.5.2.25 P3 Rest Octets
4895  * [3] 10.5.2.25a Packet Channel Description
4896  * [3] 10.5.2.25b Dedicated mode or TBF
4897  * [3] 10.5.2.25c RR Packet Uplink Assignment
4898  * [3] 10.5.2.25d RR Packet Downlink Assignment
4899  * [3] 10.5.2.26 Page Mode
4900  * [3] 10.5.2.26a (void)
4901  * [3] 10.5.2.26b (void)
4902  * [3] 10.5.2.26c (void)
4903  * [3] 10.5.2.26d (void)
4904  * [3] 10.5.2.27 NCC Permitted
4905  */
4906 /*
4907  * [3] 10.5.2.28 Power Command
4908  *
4909  *
4910  * ATC (Access Type Control) (octet 2)Bit 8
4911  * 0    Sending of Handover access is mandatory
4912  * 1    Sending of Handover access is optional
4913  */
4914 static const true_false_string gsm_a_rr_pow_cmd_atc_value  = {
4915   "Sending of Handover access is optional",
4916   "Sending of Handover access is mandatory"
4917 };
4918 /*
4919  *  The EPC mode field (octet 2) indicates whether the assigned channel(s) 
4920  *  shall be in enhanced power control (EPC) mode. It is only valid for channels
4921  *  on which EPC may be used. It is coded as follows:
4922 */
4923 static const true_false_string gsm_a_rr_pow_cmd_epc_value  = {
4924   "Channel(s) in EPC mode",
4925   "Channel(s) not in EPC mode"
4926 };
4927 /*
4928  * FPC_EPC (octet 2)
4929  * The FPC_EPC field (octet 2) has different interpretation depending
4930  *              on the channel mode     of the assigned channel (s) and the value 
4931  *              of the EPC mode field.
4932  * If the channel mode is such that fast power control (FPC) may be 
4933  *              used, the FPC_EPC field indicates whether Fast Measurement
4934  *              Reporting and Power Control mechanism is used.
4935  *              It is coded as follows:
4936  * Value 0      FPC not in use
4937  *       1      FPC in use
4938  * If the channel mode is such that EPC may be used and the EPC mode 
4939  *              field indicates that the channel is in EPC mode, the FPC_EPC
4940  *              field indicates whether EPC shall be used for uplink power control. 
4941  * It is coded as follows:
4942  * Value 0      EPC not in use for uplink power control
4943  *               1      EPC in use for uplink power control
4944  *
4945  */
4946 static const true_false_string gsm_a_rr_pow_cmd_fpcepc_value  = {
4947   "FPC in use/EPC in use for uplink power control",
4948   "FPC not in use/C not in use for uplink power control"
4949 };
4950
4951 /*
4952  * Power level (octet 2)The power level field is coded as the binaryRepresentation 
4953  * of the "power control level", see 3GPP TS 3GPP TS 45.005. This value shall be used 
4954  * by the mobile station According to 3GPP TS 45.008.Range: 0 to 31.
4955  */
4956
4957 static guint8
4958 de_rr_pow_cmd(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
4959 {
4960     proto_tree  *subtree;
4961     proto_item  *item;
4962     guint32     curr_offset;
4963
4964     len = len;
4965     curr_offset = offset;
4966
4967         item =
4968         proto_tree_add_text(tree,
4969             tvb, curr_offset, 1,
4970             gsm_dtap_elem_strings[DE_RR_POW_CMD].strptr);
4971
4972     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_RR_POW_CMD]);
4973
4974     proto_tree_add_item(subtree, hf_gsm_a_b8spare, tvb, curr_offset, 1, FALSE);
4975         /*EPC mode */   
4976     proto_tree_add_item(subtree, hf_gsm_a_rr_pow_cmd_epc, tvb, curr_offset, 1, FALSE);
4977         /*FPC_EPC*/
4978     proto_tree_add_item(subtree, hf_gsm_a_rr_pow_cmd_fpcepc, tvb, curr_offset, 1, FALSE);
4979         /*POWER LEVEL*/
4980     proto_tree_add_item(subtree, hf_gsm_a_rr_pow_cmd_powlev, tvb, curr_offset, 1, FALSE);
4981         
4982         curr_offset = curr_offset + 1;
4983
4984     return(curr_offset - offset);
4985 }
4986
4987 /*
4988  * [3] 10.5.2.28a Power Command and access type
4989  */
4990 static guint8
4991 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_)
4992 {
4993     proto_tree  *subtree;
4994     proto_item  *item;
4995     guint32     curr_offset;
4996
4997     len = len;
4998     curr_offset = offset;
4999
5000         item =
5001         proto_tree_add_text(tree,
5002             tvb, curr_offset, 1,
5003             gsm_dtap_elem_strings[DE_RR_POW_CMD_AND_ACC_TYPE].strptr);
5004
5005     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_RR_POW_CMD_AND_ACC_TYPE]);
5006
5007         /*ATC */        
5008     proto_tree_add_item(subtree, hf_gsm_a_rr_pow_cmd_atc, tvb, curr_offset, 1, FALSE);
5009         /*EPC mode */   
5010     proto_tree_add_item(subtree, hf_gsm_a_rr_pow_cmd_epc, tvb, curr_offset, 1, FALSE);
5011         /*FPC_EPC*/
5012     proto_tree_add_item(subtree, hf_gsm_a_rr_pow_cmd_fpcepc, tvb, curr_offset, 1, FALSE);
5013         /*POWER LEVEL*/
5014     proto_tree_add_item(subtree, hf_gsm_a_rr_pow_cmd_powlev, tvb, curr_offset, 1, FALSE);
5015         
5016         curr_offset = curr_offset + 1;
5017
5018     return(curr_offset - offset);
5019 }
5020 /*
5021  * [3] 10.5.2.29 RACH Control Parameters
5022  * [3] 10.5.2.30 Request Reference
5023  */
5024
5025 /*
5026  * [3] 10.5.2.31
5027  */
5028 guint8
5029 de_rr_cause(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5030 {
5031     guint32     curr_offset;
5032
5033     len = len;
5034     curr_offset = offset;
5035
5036         proto_tree_add_item(tree, hf_gsm_a_rr_RR_cause, tvb, curr_offset, 1, FALSE);
5037
5038     curr_offset++;
5039
5040     return(curr_offset - offset);
5041 }
5042 /*
5043  * [3] 10.5.2.32 SI 1 Rest Octets
5044  * [3] 10.5.2.33 SI 2bis Rest Octets 
5045  * [3] 10.5.2.33a SI 2ter Rest Octets
5046  * [3] 10.5.2.33b SI 2quater Rest Octets
5047  * [3] 10.5.2.34 SI 3 Rest Octets
5048  * [3] 10.5.2.35 SI 4 Rest Octets
5049  * [3] 10.5.2.35a SI 6 Rest Octets
5050  * [3] 10.5.2.36 SI 7 Rest Octets
5051  * [3] 10.5.2.37 SI 8 Rest Octets
5052  * [3] 10.5.2.37a SI 9 Rest Octets
5053  * [3] 10.5.2.37b SI 13 Rest Octets
5054  * [3] 10.5.2.37c (void)
5055  * [3] 10.5.2.37d (void)
5056  * [3] 10.5.2.37e SI 16 Rest Octets
5057  * [3] 10.5.2.37f SI 17 Rest Octets
5058  * [3] 10.5.2.37g SI 19 Rest Octets
5059  * [3] 10.5.2.37h SI 18 Rest Octets
5060  * [3] 10.5.2.37i SI 20 Rest Octets
5061  */
5062 /*
5063  * [3] 10.5.2.38 Starting Time
5064  */
5065 static guint8
5066 de_rr_starting_time(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5067 {
5068     guint32     curr_offset;
5069
5070     len = len;
5071     curr_offset = offset;
5072
5073         proto_tree_add_text(tree,tvb, curr_offset, 3 ,"Data(Not decoded)");
5074
5075         curr_offset = curr_offset + 2;
5076     return(curr_offset - offset);
5077 }
5078 /*
5079  * [3] 10.5.2.39 Synchronization Indication
5080  */
5081 /*
5082  * ROT: Report Observed Time Difference (Octet1 bit 3) */
5083
5084 static const true_false_string sm_a_rr_sync_ind_rot_value  = {
5085   "Mobile Time Difference IE shall be included in the HANDOVER COMPLETE message",
5086   "Mobile Time Difference IE shall not be included in the HANDOVER COMPLETE message"
5087 };
5088
5089 /* SI: Synchronization indication (octet 1)Bit2 1 */
5090
5091 static const value_string gsm_a_rr_sync_ind_si_vals[] = {
5092         { 0,            "Non-synchronized"},
5093         { 1,            "Synchronized"},
5094         { 2,            "Pre-synchronised"},
5095         { 3,            "Pseudo-synchronised"},
5096         { 0,    NULL }
5097 };
5098 /* NCI: Normal cell indication (octet 1, bit 4) */
5099
5100 static const true_false_string gsm_a_rr_sync_ind_nci_value  = {
5101   "Out of range timing advance shall trigger a handover failure procedure",
5102   "Out of range timing advance is ignored"
5103 };
5104
5105
5106 static guint8
5107 de_rr_sync_ind(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5108 {
5109     guint32     curr_offset;
5110
5111     len = len;
5112     curr_offset = offset;
5113
5114         /*NCI */        
5115     proto_tree_add_item(tree, hf_gsm_a_rr_sync_ind_nci, tvb, curr_offset, 1, FALSE);
5116         /*ROT */        
5117     proto_tree_add_item(tree, hf_gsm_a_rr_sync_ind_rot, tvb, curr_offset, 1, FALSE);
5118         /*SI*/
5119     proto_tree_add_item(tree, hf_gsm_a_rr_sync_ind_si, tvb, curr_offset, 1, FALSE);
5120         
5121         curr_offset = curr_offset + 1;
5122
5123     return(curr_offset - offset);
5124 }
5125
5126 /*
5127  * [3] 10.5.2.40 Timing Advance
5128  */
5129 static guint8
5130 de_rr_timing_adv(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5131 {
5132     guint32     curr_offset;
5133
5134     len = len;
5135     curr_offset = offset;
5136
5137         proto_tree_add_item(tree, hf_gsm_a_rr_timing_adv, tvb, curr_offset, 1, FALSE);
5138         curr_offset = curr_offset + 1;
5139
5140     return(curr_offset - offset);
5141 }
5142
5143 /*
5144  * [3] 10.5.2.41 Time Difference
5145  */
5146 static guint8
5147 de_rr_time_diff(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_time_diff, tvb, curr_offset, 1, FALSE);
5155         curr_offset = curr_offset + 1;
5156
5157     return(curr_offset - offset);
5158 }
5159 /*
5160  * [3] 10.5.2.41a TLLI
5161  * The TLLI is encoded as a binary number with a length of 4 octets. TLLI is defined in 3GPP TS 23.003
5162  */
5163 guint8
5164 de_rr_tlli(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_tlli, tvb, curr_offset, 4, FALSE);
5172         curr_offset = curr_offset + 4;
5173
5174     return(curr_offset - offset);
5175 }
5176 /*
5177  * [3] 10.5.2.42 TMSI/P-TMSI
5178  */
5179 /*
5180  * [3] 10.5.2.42a VGCS target mode Indication
5181  */
5182 /*
5183 Target mode (octet 3)
5184 Bit     8 7
5185         0 0     dedicated mode
5186         0 1     group transmit mode
5187         Other values are reserved for future use.
5188 */
5189 static const value_string gsm_a_rr_target_mode_vals[] _U_ = {
5190         { 0,            "Dedicated mode"},
5191         { 1,            "Group transmit mode"},
5192         { 0,    NULL }
5193 };
5194 static guint8
5195 de_rr_vgcs_tar_mode_ind(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5196 {
5197     guint32     curr_offset;
5198
5199     len = len;
5200     curr_offset = offset;
5201
5202         proto_tree_add_item(tree, hf_gsm_a_rr_target_mode, tvb, curr_offset, 1, FALSE);
5203         proto_tree_add_item(tree, hf_gsm_a_rr_group_cipher_key_number, tvb, curr_offset, 1, FALSE);
5204         curr_offset = curr_offset + 1;
5205
5206     return(curr_offset - offset);
5207 }
5208
5209 /* 
5210  * [3] 10.5.2.42b       VGCS Ciphering Parameters       
5211  */
5212 static guint8
5213 de_rr_vgcs_cip_par(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5214 {
5215     guint32     curr_offset;
5216
5217     len = len;
5218     curr_offset = offset;
5219
5220         proto_tree_add_text(tree,tvb, curr_offset, len ,"Data(Not decoded)");
5221
5222         curr_offset = curr_offset + 2;
5223     return(curr_offset - offset);
5224 }
5225 /*
5226  * [3] 10.5.2.43 Wait Indication
5227  * [3] 10.5.2.44 SI10 rest octets $(ASCI)$
5228  * [3] 10.5.2.45 EXTENDED MEASUREMENT RESULTS
5229  * [3] 10.5.2.46 Extended Measurement Frequency List
5230  */
5231 /*
5232  * [3] 10.5.2.47 Suspension Cause
5233  */
5234 /*Suspension cause value (octet 2)*/
5235 static const value_string gsm_a_rr_suspension_cause_vals[] = {
5236         { 0,            "Emergency call, mobile originating call or call re-establishment"},
5237         { 1,            "Location Area Update"},
5238         { 2,            "MO Short message service"},
5239         { 3,            "Other procedure which can be completed with an SDCCH"},
5240         { 4,            "MO Voice broadcast or group call"},
5241         { 5,            "Mobile terminating CS connection"},
5242         { 6,            "DTM not supported in the cell"},
5243         { 0,    NULL }
5244 };
5245 guint8
5246 de_rr_sus_cau(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5247 {
5248     guint32     curr_offset;
5249
5250     len = len;
5251     curr_offset = offset;
5252
5253         proto_tree_add_item(tree, hf_gsm_a_rr_suspension_cause, tvb, curr_offset, 1, FALSE);
5254
5255         curr_offset = curr_offset + 1;
5256     return(curr_offset - offset);
5257 }
5258 /*
5259  * [3] 10.5.2.48 APDU ID 
5260  * [3] 10.5.2.49 APDU Flags
5261  * [3] 10.5.2.50 APDU Data
5262  * [3] 10.5.2.51 Handover To UTRAN Command
5263  * [3] 10.5.2.52 Handover To cdma2000 Command 
5264  * [3] 10.5.2.53 (void)
5265  * [3] 10.5.2.54 (void)
5266  * [3] 10.5.2.55 (void)
5267  * [3] 10.5.2.56 3G Target Cell
5268 */
5269 /* 
5270  * [3] 10.5.2.59        Dedicated Service Information 
5271  */
5272 /*
5273 Last Segment (octet 2)
5274 bit 1
5275 0       mobile station shall not perform Service Information Sending procedure on new cell.
5276 1       mobile station shall perform Service Information Sending procedure on new cell.
5277 */
5278 static const true_false_string gsm_a_rr_last_segment_value  = {
5279   "Mobile station shall perform Service Information Sending procedure on new cell.",
5280   "mobile station shall not perform Service Information Sending procedure on new cell."
5281 };
5282 static guint8
5283 de_rr_ded_serv_inf(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5284 {
5285     guint32     curr_offset;
5286
5287     len = len;
5288     curr_offset = offset;
5289
5290         proto_tree_add_item(tree, hf_gsm_a_rr_last_segment, tvb, curr_offset, 1, FALSE);
5291
5292         curr_offset = curr_offset + 3;
5293     return(curr_offset - offset);
5294 }
5295
5296
5297
5298 /*
5299  * [3] 10.5.3.1
5300  */
5301 static guint8
5302 de_auth_param_rand(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5303 {
5304     guint32     curr_offset;
5305
5306     len = len;
5307     curr_offset = offset;
5308
5309 /*
5310  * 16 octets == 128 bits
5311  */
5312 #define AUTH_PARAM_RAND_LEN     16
5313
5314     proto_tree_add_text(tree,
5315         tvb, curr_offset, AUTH_PARAM_RAND_LEN,
5316                         "RAND value: %s",
5317                         tvb_bytes_to_str(tvb, curr_offset, AUTH_PARAM_RAND_LEN));
5318
5319     curr_offset += AUTH_PARAM_RAND_LEN;
5320
5321     /* no length check possible */
5322
5323     return(curr_offset - offset);
5324 }
5325
5326 /*
5327  * [3] 10.5.3.1.1
5328  */
5329 static guint8
5330 de_auth_param_autn(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5331 {
5332     guint32     curr_offset;
5333
5334     curr_offset = offset;
5335
5336     proto_tree_add_text(tree,
5337         tvb, curr_offset, len,
5338         "AUTN value: %s",
5339         tvb_bytes_to_str(tvb, curr_offset, len));
5340
5341     curr_offset += len;
5342
5343     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
5344
5345     return(curr_offset - offset);
5346 }
5347
5348 /*
5349  * [3] 10.5.3.2
5350  */
5351 static guint8
5352 de_auth_resp_param(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5353 {
5354     guint32     curr_offset;
5355
5356     len = len;
5357     curr_offset = offset;
5358
5359 /*
5360  * 4 octets == 32 bits
5361  */
5362 #define AUTH_PARAM_SRES_LEN     4
5363
5364     proto_tree_add_text(tree,
5365         tvb, curr_offset, AUTH_PARAM_SRES_LEN,
5366                         "SRES value: %s",
5367                         tvb_bytes_to_str(tvb, curr_offset, AUTH_PARAM_SRES_LEN));
5368
5369     curr_offset += AUTH_PARAM_SRES_LEN;
5370
5371     /* no length check possible */
5372
5373     return(curr_offset - offset);
5374 }
5375
5376 /*
5377  * [3] 10.5.3.2.1
5378  */
5379 static guint8
5380 de_auth_resp_param_ext(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5381 {
5382     guint32     curr_offset;
5383
5384     curr_offset = offset;
5385
5386     proto_tree_add_text(tree,
5387         tvb, curr_offset, len,
5388          "XRES value: %s",
5389          tvb_bytes_to_str(tvb, curr_offset, len));
5390
5391     curr_offset += len;
5392
5393     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
5394
5395     return(curr_offset - offset);
5396 }
5397
5398 /*
5399  * [3] 10.5.3.2.2
5400  */
5401 static guint8
5402 de_auth_fail_param(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5403 {
5404     guint32     curr_offset;
5405
5406     curr_offset = offset;
5407
5408     proto_tree_add_text(tree,
5409         tvb, curr_offset, len,
5410         "AUTS value: %s",
5411         tvb_bytes_to_str(tvb, curr_offset, len));
5412
5413     curr_offset += len;
5414
5415     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
5416
5417     return(curr_offset - offset);
5418 }
5419
5420 /*
5421  * [3] 10.5.3.5a
5422  */
5423 static guint8
5424 de_network_name(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5425 {
5426     guint8      oct;
5427     guint32     curr_offset;
5428     const gchar *str;
5429
5430     curr_offset = offset;
5431
5432     oct = tvb_get_guint8(tvb, curr_offset);
5433
5434     proto_tree_add_item(tree, hf_gsm_a_extension, tvb, curr_offset, 1, FALSE);
5435
5436     switch ((oct & 0x70) >> 4)
5437     {
5438     case 0x00: str = "Cell Broadcast data coding scheme, GSM default alphabet, language unspecified, defined in 3GPP TS 03.38"; break;
5439     case 0x01: str = "UCS2 (16 bit)"; break;
5440     default:
5441         str = "Reserved";
5442         break;
5443     }
5444
5445     other_decode_bitfield_value(a_bigbuf, oct, 0x70, 8);
5446     proto_tree_add_text(tree,
5447         tvb, curr_offset, 1,
5448         "%s :  Coding Scheme: %s",
5449         a_bigbuf,
5450         str);
5451
5452     other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
5453     proto_tree_add_text(tree,
5454         tvb, curr_offset, 1,
5455         "%s :  Add CI: The MS should %s",
5456         a_bigbuf,
5457         (oct & 0x08) ?
5458             "add the letters for the Country's Initials and a separator (e.g. a space) to the text string" :
5459             "The MS should not add the letters for the Country's Initials to the text string");
5460
5461     switch (oct & 0x07)
5462     {
5463     case 1: str = "bit 8 is spare and set to '0' in octet n"; break;
5464     case 2: str = "bits 7 and 8 are spare and set to '0' in octet n"; break;
5465     case 3: str = "bits 6 to 8(inclusive) are spare and set to '0' in octet n"; break;
5466     case 4: str = "bits 5 to 8(inclusive) are spare and set to '0' in octet n"; break;
5467     case 5: str = "bits 4 to 8(inclusive) are spare and set to '0' in octet n"; break;
5468     case 6: str = "bits 3 to 8(inclusive) are spare and set to '0' in octet n"; break;
5469     case 7: str = "bits 2 to 8(inclusive) are spare and set to '0' in octet n"; break;
5470     default:
5471         str = "this field carries no information about the number of spare bits in octet n";
5472         break;
5473     }
5474
5475     other_decode_bitfield_value(a_bigbuf, oct, 0x07, 8);
5476     proto_tree_add_text(tree,
5477         tvb, curr_offset, 1,
5478         "%s :  Number of spare bits in last octet: %s",
5479         a_bigbuf,
5480         str);
5481
5482     curr_offset++;
5483
5484     NO_MORE_DATA_CHECK(len);
5485
5486     proto_tree_add_text(tree,
5487         tvb, curr_offset, len - 1,
5488         "Text string encoded according to Coding Scheme");
5489
5490     curr_offset += len - 1;
5491
5492     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
5493
5494     return(curr_offset - offset);
5495 }
5496
5497 /* 3GPP TS 24.008
5498  * [3] 10.5.3.6 Reject cause
5499  */
5500 guint8
5501 de_rej_cause(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5502 {
5503     guint8      oct;
5504     guint32     curr_offset;
5505     const gchar *str;
5506
5507     len = len;
5508     curr_offset = offset;
5509
5510     oct = tvb_get_guint8(tvb, curr_offset);
5511
5512     switch (oct)
5513     {
5514     case 0x02: str = "IMSI unknown in HLR"; break;
5515     case 0x03: str = "Illegal MS"; break;
5516     case 0x04: str = "IMSI unknown in VLR"; break;
5517     case 0x05: str = "IMEI not accepted"; break;
5518     case 0x06: str = "Illegal ME"; break;
5519     case 0x0b: str = "PLMN not allowed"; break;
5520     case 0x0c: str = "Location Area not allowed"; break;
5521     case 0x0d: str = "Roaming not allowed in this location area"; break;
5522     case 0x0f: str = "No Suitable Cells In Location Area"; break;
5523     case 0x11: str = "Network failure"; break;
5524     case 0x14: str = "MAC failure"; break;
5525     case 0x15: str = "Synch failure"; break;
5526     case 0x16: str = "Congestion"; break;
5527     case 0x17: str = "GSM authentication unacceptable"; break;
5528     case 0x20: str = "Service option not supported"; break;
5529     case 0x21: str = "Requested service option not subscribed"; break;
5530     case 0x22: str = "Service option temporarily out of order"; break;
5531     case 0x26: str = "Call cannot be identified"; break;
5532     case 0x5f: str = "Semantically incorrect message"; break;
5533     case 0x60: str = "Invalid mandatory information"; break;
5534     case 0x61: str = "Message type non-existent or not implemented"; break;
5535     case 0x62: str = "Message type not compatible with the protocol state"; break;
5536     case 0x63: str = "Information element non-existent or not implemented"; break;
5537     case 0x64: str = "Conditional IE error"; break;
5538     case 0x65: str = "Message not compatible with the protocol state"; break;
5539     case 0x6f: str = "Protocol error, unspecified"; break;
5540     default:
5541         switch (is_uplink)
5542         {
5543         case IS_UPLINK_FALSE:
5544             str = "Service option temporarily out of order";
5545             break;
5546         default:
5547             str = "Protocol error, unspecified";
5548             break;
5549         }
5550         break;
5551     }
5552
5553     proto_tree_add_text(tree,
5554         tvb, curr_offset, 1,
5555         "Reject Cause value: 0x%02x (%u) %s",
5556         oct,
5557         oct,
5558         str);
5559
5560     curr_offset++;
5561
5562     /* no length check possible */
5563
5564     return(curr_offset - offset);
5565 }
5566
5567 /*
5568  * [3] 10.5.3.8
5569  */
5570 static guint8
5571 de_time_zone(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5572 {
5573     guint8      oct;
5574     guint32     curr_offset;
5575     char sign;
5576
5577     len = len;
5578     curr_offset = offset;
5579
5580         /* 3GPP TS 23.040 version 6.6.0 Release 6 
5581          * 9.2.3.11 TP-Service-Centre-Time-Stamp (TP-SCTS)
5582          * :
5583          * The Time Zone indicates the difference, expressed in quarters of an hour, 
5584          * between the local time and GMT. In the first of the two semi-octets, 
5585          * the first bit (bit 3 of the seventh octet of the TP-Service-Centre-Time-Stamp field)
5586          * represents the algebraic sign of this difference (0: positive, 1: negative).
5587          */
5588
5589     oct = tvb_get_guint8(tvb, curr_offset);
5590     sign = (oct & 0x08)?'-':'+';
5591     oct = (oct >> 4) + (oct & 0x07) * 10;
5592
5593     proto_tree_add_text(tree,
5594         tvb, offset, 1,
5595         "Timezone: GMT %c %d hours %d minutes",
5596         sign, oct / 4, oct % 4 * 15);
5597     curr_offset++;
5598
5599     /* no length check possible */
5600
5601     return(curr_offset - offset);
5602 }
5603
5604 /*
5605  * [3] 10.5.3.9
5606  */
5607 static guint8
5608 de_time_zone_time(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5609 {
5610     guint8      oct, oct2, oct3;
5611     guint32     curr_offset;
5612     char sign;
5613
5614     len = len;
5615     curr_offset = offset;
5616
5617     oct = tvb_get_guint8(tvb, curr_offset);
5618     oct2 = tvb_get_guint8(tvb, curr_offset+1);
5619     oct3 = tvb_get_guint8(tvb, curr_offset+2);
5620
5621     proto_tree_add_text(tree,
5622         tvb, curr_offset, 3,
5623         "Year %u%u, Month %u%u, Day %u%u",
5624         oct & 0x0f,
5625         (oct & 0xf0) >> 4,
5626         oct2 & 0x0f,
5627         (oct2 & 0xf0) >> 4,
5628         oct3 & 0x0f,
5629         (oct3 & 0xf0) >> 4);
5630
5631     curr_offset += 3;
5632
5633     oct = tvb_get_guint8(tvb, curr_offset);
5634     oct2 = tvb_get_guint8(tvb, curr_offset+1);
5635     oct3 = tvb_get_guint8(tvb, curr_offset+2);
5636
5637     proto_tree_add_text(tree,
5638         tvb, curr_offset, 3,
5639         "Hour %u%u, Minutes %u%u, Seconds %u%u",
5640         oct & 0x0f,
5641         (oct & 0xf0) >> 4,
5642         oct2 & 0x0f,
5643         (oct2 & 0xf0) >> 4,
5644         oct3 & 0x0f,
5645         (oct3 & 0xf0) >> 4);
5646
5647     curr_offset += 3;
5648
5649         /* 3GPP TS 23.040 version 6.6.0 Release 6 
5650          * 9.2.3.11 TP-Service-Centre-Time-Stamp (TP-SCTS)
5651          * :
5652          * The Time Zone indicates the difference, expressed in quarters of an hour, 
5653          * between the local time and GMT. In the first of the two semi-octets, 
5654          * the first bit (bit 3 of the seventh octet of the TP-Service-Centre-Time-Stamp field)
5655          * represents the algebraic sign of this difference (0: positive, 1: negative).
5656          */
5657
5658     oct = tvb_get_guint8(tvb, curr_offset);
5659     sign = (oct & 0x08)?'-':'+';
5660     oct = (oct >> 4) + (oct & 0x07) * 10;
5661
5662     proto_tree_add_text(tree,
5663         tvb, offset, 1,
5664         "Timezone: GMT %c %d hours %d minutes",
5665         sign, oct / 4, oct % 4 * 15);
5666
5667     curr_offset++;
5668
5669     /* no length check possible */
5670
5671     return(curr_offset - offset);
5672 }
5673
5674 /*
5675  * [3] 10.5.3.11 3GPP TS 24.008 version 6.8.0 Release 6
5676  */
5677 static guint8
5678 de_lsa_id(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5679 {
5680     guint32     curr_offset;
5681
5682     curr_offset = offset;
5683
5684         if (len == 0){
5685                 proto_tree_add_text(tree,tvb, curr_offset, len,"LSA ID not included");
5686         }else{
5687                 proto_tree_add_item(tree, hf_gsm_a_lsa_id, tvb, curr_offset, 3, FALSE);
5688         }
5689
5690     curr_offset += len;
5691
5692     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
5693
5694     return(curr_offset - offset);
5695 }
5696
5697 /*
5698  * [3] 10.5.3.12
5699  */
5700 static guint8
5701 de_day_saving_time(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5702 {
5703     guint8      oct;
5704     guint32     curr_offset;
5705     const gchar *str;
5706
5707     curr_offset = offset;
5708
5709     oct = tvb_get_guint8(tvb, curr_offset);
5710
5711     other_decode_bitfield_value(a_bigbuf, oct, 0xfc, 8);
5712     proto_tree_add_text(tree,
5713         tvb, curr_offset, 1,
5714         "%s :  Spare",
5715         a_bigbuf);
5716
5717     switch (oct & 0x03)
5718     {
5719     case 0: str = "No adjustment for Daylight Saving Time"; break;
5720     case 1: str = "+1 hour adjustment for Daylight Saving Time"; break;
5721     case 2: str = "+2 hours adjustment for Daylight Saving Time"; break;
5722     default:
5723         str = "Reserved";
5724         break;
5725     }
5726
5727     other_decode_bitfield_value(a_bigbuf, oct, 0x03, 8);
5728     proto_tree_add_text(tree,
5729         tvb, curr_offset, 1,
5730         "%s :  %s",
5731         a_bigbuf,
5732         str);
5733
5734     curr_offset++;
5735
5736     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
5737
5738     return(curr_offset - offset);
5739 }
5740
5741 /*
5742  * [3] 10.5.4.4
5743  */
5744 static guint8
5745 de_aux_states(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
5746 {
5747     guint8      oct;
5748     guint32     curr_offset;
5749     const gchar *str;
5750
5751     curr_offset = offset;
5752
5753     oct = tvb_get_guint8(tvb, curr_offset);
5754
5755     proto_tree_add_item(tree, hf_gsm_a_extension, tvb, curr_offset, 1, FALSE);
5756
5757     other_decode_bitfield_value(a_bigbuf, oct, 0x70, 8);
5758     proto_tree_add_text(tree,
5759         tvb, curr_offset, 1,
5760         "%s :  Spare",
5761         a_bigbuf);
5762
5763     switch ((oct & 0x0c) >> 2)
5764     {
5765     case 0: str = "Idle"; break;
5766     case 1: str = "Hold request"; break;
5767     case 2: str = "Call held"; break;
5768     default:
5769         str = "Retrieve request";
5770         break;
5771     }
5772
5773     other_decode_bitfield_value(a_bigbuf, oct, 0x0c, 8);
5774     proto_tree_add_text(tree,
5775         tvb, curr_offset, 1,
5776         "%s :  Hold auxiliary state: %s",
5777         a_bigbuf,
5778         str);
5779
5780     switch (oct & 0x03)
5781     {
5782     case 0: str = "Idle"; break;
5783     case 1: str = "MPTY request"; break;
5784     case 2: str = "Call in MPTY"; break;
5785     default:
5786         str = "Split request";
5787         break;
5788     }
5789
5790     other_decode_bitfield_value(a_bigbuf, oct, 0x03, 8);
5791     proto_tree_add_text(tree,
5792         tvb, curr_offset, 1,
5793         "%s :  Multi party auxiliary state: %s",
5794         a_bigbuf,
5795         str);
5796
5797     curr_offset++;
5798
5799     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
5800
5801     return(curr_offset - offset);
5802 }
5803
5804 /*
5805  * [3] 10.5.4.5
5806  */
5807 static guint8
5808 de_bearer_cap(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
5809 {
5810     guint8      oct;
5811     guint8      itc;
5812     gboolean    extended;
5813     guint32     curr_offset;
5814     guint32     saved_offset;
5815     proto_tree  *subtree;
5816     proto_item  *item;
5817     const gchar *str;
5818
5819 #define DE_BC_ITC_SPEECH        0x00
5820 #define DE_BC_ITC_UDI           0x01
5821 #define DE_BC_ITC_EX_PLMN       0x02
5822 #define DE_BC_ITC_FASC_G3       0x03
5823 #define DE_BC_ITC_OTHER_ITC     0x05
5824 #define DE_BC_ITC_RSVD_NET      0x07
5825
5826     curr_offset = offset;
5827
5828     oct = tvb_get_guint8(tvb, curr_offset);
5829
5830     /* octet 3 */
5831
5832     /*
5833      * warning, bearer cap uses extended values that
5834      * are reversed from other parameters!
5835      */
5836     extended = (oct & 0x80) ? FALSE : TRUE;
5837     itc = oct & 0x07;
5838
5839     other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
5840     proto_tree_add_text(tree,
5841         tvb, curr_offset, 1,
5842         "%s :  Extension: %s",
5843         a_bigbuf,
5844         extended ? "extended" : "not extended");
5845
5846     switch (is_uplink)
5847     {
5848     case IS_UPLINK_FALSE:
5849         str = "Spare";
5850         break;
5851
5852     case IS_UPLINK_TRUE:
5853         /*
5854          * depends on Information transfer capability
5855          */
5856         switch (itc)
5857         {
5858         case DE_BC_ITC_SPEECH:
5859             if (extended)
5860             {
5861                 switch ((oct & 0x60) >> 5)
5862                 {
5863                 case 1: str = "MS supports at least full rate speech version 1 but does not support half rate speech version 1"; break;
5864                 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;
5865                 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;
5866                 default:
5867                     str = "Reserved";
5868                     break;
5869                 }
5870                 break;
5871             }
5872             else
5873             {
5874                 switch ((oct & 0x60) >> 5)
5875                 {
5876                 case 1: str = "Full rate support only MS/fullrate speech version 1 supported"; break;
5877                 case 2: str = "Dual rate support MS/half rate speech version 1 preferred, full rate speech version 1 also supported"; break;
5878                 case 3: str = "Dual rate support MS/full rate speech version 1 preferred, half rate speech version 1 also supported"; break;
5879                 default:
5880                     str = "Reserved";
5881                     break;
5882                 }
5883                 break;
5884             }
5885             break;
5886
5887         default:
5888             switch ((oct & 0x60) >> 5)
5889             {
5890             case 1: str = "Full rate support only MS"; break;
5891             case 2: str = "Dual rate support MS/half rate preferred"; break;
5892             case 3: str = "Dual rate support MS/full rate preferred"; break;
5893             default:
5894                 str = "Reserved";
5895                 break;
5896             }
5897             break;
5898         }
5899         break;
5900
5901     default:
5902         str = "(dissect problem)";
5903         break;
5904     }
5905
5906     other_decode_bitfield_value(a_bigbuf, oct, 0x60, 8);
5907     proto_tree_add_text(tree,
5908         tvb, curr_offset, 1,
5909         "%s :  Radio channel requirement: %s",
5910         a_bigbuf,
5911         str);
5912
5913     other_decode_bitfield_value(a_bigbuf, oct, 0x10, 8);
5914     proto_tree_add_text(tree,
5915         tvb, curr_offset, 1,
5916         "%s :  Coding standard: %s",
5917         a_bigbuf,
5918         (oct & 0x10) ? "reserved" : "GSM standardized coding");
5919
5920     other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
5921     proto_tree_add_text(tree,
5922         tvb, curr_offset, 1,
5923         "%s :  Transfer mode: %s",
5924         a_bigbuf,
5925         (oct & 0x08) ? "packet" : "circuit");
5926
5927     switch (itc)
5928     {
5929     case DE_BC_ITC_SPEECH: str = "Speech"; break;
5930     case DE_BC_ITC_UDI: str = "Unrestricted digital information"; break;
5931     case DE_BC_ITC_EX_PLMN: str = "3.1 kHz audio, ex PLMN"; break;
5932     case DE_BC_ITC_FASC_G3: str = "Facsimile group 3"; break;
5933     case DE_BC_ITC_OTHER_ITC: str = "Other ITC (See Octet 5a)"; break;
5934     case DE_BC_ITC_RSVD_NET: str = "Reserved, to be used in the network"; break;
5935     default:
5936         str = "Reserved";
5937         break;
5938     }
5939
5940     other_decode_bitfield_value(a_bigbuf, oct, 0x07, 8);
5941     proto_tree_add_text(tree,
5942         tvb, curr_offset, 1,
5943         "%s :  Information transfer capability: %s",
5944         a_bigbuf,
5945         str);
5946
5947     if (add_string)
5948         g_snprintf(add_string, string_len, " - (%s)", str);
5949
5950     curr_offset++;
5951
5952     NO_MORE_DATA_CHECK(len);
5953
5954     switch (itc)
5955     {
5956     case DE_BC_ITC_SPEECH:
5957         /* octets 3a */
5958
5959         item =
5960             proto_tree_add_text(tree,
5961                 tvb, curr_offset, -1,
5962                 "Octets 3a - Speech Versions");
5963
5964         subtree = proto_item_add_subtree(item, ett_bc_oct_3a);
5965
5966         saved_offset = curr_offset;
5967
5968         do
5969         {
5970             oct = tvb_get_guint8(tvb, curr_offset);
5971
5972             extended = (oct & 0x80) ? FALSE : TRUE;
5973
5974             other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
5975             proto_tree_add_text(subtree,
5976                 tvb, curr_offset, 1,
5977                 "%s :  Extension: %s",
5978                 a_bigbuf,
5979                 extended ? "extended" : "not extended");
5980
5981             other_decode_bitfield_value(a_bigbuf, oct, 0x40, 8);
5982             proto_tree_add_text(subtree,
5983                 tvb, curr_offset, 1,
5984                 "%s :  Coding: octet used for %s",
5985                 a_bigbuf,
5986                 (oct & 0x40) ? "other extension of octet 3" :
5987                     "extension of information transfer capability");
5988
5989             other_decode_bitfield_value(a_bigbuf, oct, 0x30, 8);
5990             proto_tree_add_text(subtree,
5991                 tvb, curr_offset, 1,
5992                 "%s :  Spare",
5993                 a_bigbuf);
5994
5995             switch (oct & 0x0f)
5996             {
5997             case 0: str = "GSM full rate speech version 1"; break;
5998             case 2: str = "GSM full rate speech version 2"; break;
5999             case 4: str = "GSM full rate speech version 3"; break;
6000             case 1: str = "GSM half rate speech version 1"; break;
6001             case 5: str = "GSM half rate speech version 3"; break;
6002             default:
6003                 str = "Speech version TBD";
6004                 break;
6005             }
6006
6007             other_decode_bitfield_value(a_bigbuf, oct, 0x0f, 8);
6008             proto_tree_add_text(subtree,
6009                 tvb, curr_offset, 1,
6010                 "%s :  Speech version indication: %s",
6011                 a_bigbuf,
6012                 str);
6013
6014             curr_offset++;
6015         }
6016         while (extended &&
6017             ((len - (curr_offset - offset)) > 0));
6018
6019         proto_item_set_len(item, curr_offset - saved_offset);
6020         break;
6021
6022     default:
6023         /* octet 4 */
6024
6025         item =
6026             proto_tree_add_text(tree,
6027                 tvb, curr_offset, 1,
6028                 "Octet 4");
6029
6030         subtree = proto_item_add_subtree(item, ett_bc_oct_4);
6031
6032         oct = tvb_get_guint8(tvb, curr_offset);
6033
6034         extended = (oct & 0x80) ? FALSE : TRUE;
6035
6036         other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
6037         proto_tree_add_text(subtree,
6038             tvb, curr_offset, 1,
6039             "%s :  Extension: %s",
6040             a_bigbuf,
6041             extended ? "extended" : "not extended");
6042
6043         other_decode_bitfield_value(a_bigbuf, oct, 0x40, 8);
6044         proto_tree_add_text(subtree,
6045             tvb, curr_offset, 1,
6046             "%s :  Compression: data compression %s%s",
6047             a_bigbuf,
6048             (oct & 0x40) ? "" : "not ",
6049             is_uplink ? "allowed" : "possible");
6050
6051         switch ((oct & 0x30) >> 4)
6052         {
6053         case 0x00: str = "Service data unit integrity"; break;
6054         case 0x03: str = "Unstructured"; break;
6055         default:
6056             str = "Reserved";
6057             break;
6058         }
6059
6060         other_decode_bitfield_value(a_bigbuf, oct, 0x30, 8);
6061         proto_tree_add_text(subtree,
6062             tvb, curr_offset, 1,
6063             "%s :  Structure: %s",
6064             a_bigbuf,
6065             str);
6066
6067         other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
6068         proto_tree_add_text(subtree,
6069             tvb, curr_offset, 1,
6070             "%s :  Duplex mode: %s",
6071             a_bigbuf,
6072             (oct & 0x08) ? "Full" : "Half");
6073
6074         other_decode_bitfield_value(a_bigbuf, oct, 0x04, 8);
6075         proto_tree_add_text(subtree,
6076             tvb, curr_offset, 1,
6077             "%s :  Configuration: %s",
6078             a_bigbuf,
6079             (oct & 0x04) ? "Reserved" : "Point-to-point");
6080
6081         other_decode_bitfield_value(a_bigbuf, oct, 0x02, 8);
6082         proto_tree_add_text(subtree,
6083             tvb, curr_offset, 1,
6084             "%s :  NIRR: %s",
6085             a_bigbuf,
6086             (oct & 0x02) ?
6087                 "Data up to and including 4.8 kb/s, full rate, non-transparent, 6 kb/s radio interface rate is requested" :
6088                 "No meaning is associated with this value");
6089
6090         other_decode_bitfield_value(a_bigbuf, oct, 0x01, 8);
6091         proto_tree_add_text(subtree,
6092             tvb, curr_offset, 1,
6093             "%s :  Establishment: %s",
6094             a_bigbuf,
6095             (oct & 0x01) ? "Reserved" : "Demand");
6096
6097         curr_offset++;
6098
6099         NO_MORE_DATA_CHECK(len);
6100
6101         /* octet 5 */
6102
6103         item =
6104             proto_tree_add_text(tree,
6105                 tvb, curr_offset, 1,
6106                 "Octet 5");
6107
6108         subtree = proto_item_add_subtree(item, ett_bc_oct_5);
6109
6110         oct = tvb_get_guint8(tvb, curr_offset);
6111
6112         extended = (oct & 0x80) ? FALSE : TRUE;
6113
6114         other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
6115         proto_tree_add_text(subtree,
6116             tvb, curr_offset, 1,
6117             "%s :  Extension: %s",
6118             a_bigbuf,
6119             extended ? "extended" : "not extended");
6120
6121         other_decode_bitfield_value(a_bigbuf, oct, 0x60, 8);
6122         proto_tree_add_text(subtree,
6123             tvb, curr_offset, 1,
6124             "%s :  Access Identity: %s",
6125             a_bigbuf,
6126             (oct & 0x60) ? "Reserved" : "Octet identifier");
6127
6128         switch ((oct & 0x18) >> 3)
6129         {
6130         case 0x00: str = "No rate adaption"; break;
6131         case 0x01: str = "V.110, I.460/X.30 rate adaptation"; break;
6132         case 0x02: str = "ITU-T X.31 flag stuffing"; break;
6133         default:
6134             str = "Other rate adaption (see octet 5a)"; break;
6135             break;
6136         }
6137
6138         other_decode_bitfield_value(a_bigbuf, oct, 0x18, 8);
6139         proto_tree_add_text(subtree,
6140             tvb, curr_offset, 1,
6141             "%s :  Rate Adaption: %s",
6142             a_bigbuf,
6143             str);
6144
6145         switch (oct & 0x07)
6146         {
6147         case 0x01: str = "I.440/450"; break;
6148         case 0x02: str = "Reserved: was allocated in earlier phases of the protocol"; break;
6149         case 0x03: str = "Reserved: was allocated in earlier phases of the protocol"; break;
6150         case 0x04: str = "Reserved: was allocated in earlier phases of the protocol"; break;
6151         case 0x05: str = "Reserved: was allocated in earlier phases of the protocol"; break;
6152         case 0x06: str = "Reserved: was allocated in earlier phases of the protocol"; break;
6153         default:
6154             str = "Reserved"; break;
6155             break;
6156         }
6157
6158         other_decode_bitfield_value(a_bigbuf, oct, 0x07, 8);
6159         proto_tree_add_text(subtree,
6160             tvb, curr_offset, 1,
6161             "%s :  Signalling Access Protocol: %s",
6162             a_bigbuf,
6163             str);
6164
6165         curr_offset++;
6166
6167         NO_MORE_DATA_CHECK(len);
6168
6169         if (!extended) goto bc_octet_6;
6170
6171         /* octet 5a */
6172
6173         item =
6174             proto_tree_add_text(tree,
6175                 tvb, curr_offset, 1,
6176                 "Octet 5a");
6177
6178         subtree = proto_item_add_subtree(item, ett_bc_oct_5a);
6179
6180         oct = tvb_get_guint8(tvb, curr_offset);
6181
6182         extended = (oct & 0x80) ? FALSE : TRUE;
6183
6184         other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
6185         proto_tree_add_text(subtree,
6186             tvb, curr_offset, 1,
6187             "%s :  Extension: %s",
6188             a_bigbuf,
6189             extended ? "extended" : "not extended");
6190
6191         other_decode_bitfield_value(a_bigbuf, oct, 0x60, 8);
6192         proto_tree_add_text(subtree,
6193             tvb, curr_offset, 1,
6194             "%s :  Other ITC: %s",
6195             a_bigbuf,
6196             (oct & 0x60) ? "Reserved" : "Restricted digital information");
6197
6198         switch ((oct & 0x18) >> 3)
6199         {
6200         case 0x00: str = "V.120"; break;
6201         case 0x01: str = "H.223 & H.245"; break;
6202         case 0x02: str = "PIAFS"; break;
6203         default:
6204             str = "Reserved";
6205             break;
6206         }
6207
6208         other_decode_bitfield_value(a_bigbuf, oct, 0x18, 8);
6209         proto_tree_add_text(subtree,
6210             tvb, curr_offset, 1,
6211             "%s :  Other Rate Adaption: %s",
6212             a_bigbuf,
6213             str);
6214
6215         other_decode_bitfield_value(a_bigbuf, oct, 0x07, 8);
6216         proto_tree_add_text(subtree,
6217             tvb, curr_offset, 1,
6218             "%s :  Spare",
6219             a_bigbuf);
6220
6221         curr_offset++;
6222
6223         NO_MORE_DATA_CHECK(len);
6224
6225         if (!extended) goto bc_octet_6;
6226
6227         /* octet 5b */
6228
6229         item =
6230             proto_tree_add_text(tree,
6231                 tvb, curr_offset, 1,
6232                 "Octet 5b");
6233
6234         subtree = proto_item_add_subtree(item, ett_bc_oct_5b);
6235
6236         oct = tvb_get_guint8(tvb, curr_offset);
6237
6238         extended = (oct & 0x80) ? FALSE : TRUE;
6239
6240         other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
6241         proto_tree_add_text(subtree,
6242             tvb, curr_offset, 1,
6243             "%s :  Extension: %s",
6244             a_bigbuf,
6245             extended ? "extended" : "not extended");
6246
6247         other_decode_bitfield_value(a_bigbuf, oct, 0x40, 8);
6248         proto_tree_add_text(subtree,
6249             tvb, curr_offset, 1,
6250             "%s :  Rate Adaption Header: %sincluded",
6251             a_bigbuf,
6252             (oct & 0x40) ? "" : "not ");
6253
6254         other_decode_bitfield_value(a_bigbuf, oct, 0x20, 8);
6255         proto_tree_add_text(subtree,
6256             tvb, curr_offset, 1,
6257             "%s :  Multiple frame establishment support in data link: %s",
6258             a_bigbuf,
6259             (oct & 0x20) ? "Supported" : "Not supported, only UI frames allowed");
6260
6261         other_decode_bitfield_value(a_bigbuf, oct, 0x10, 8);
6262         proto_tree_add_text(subtree,
6263             tvb, curr_offset, 1,
6264             "%s :  Mode of operation: %s",
6265             a_bigbuf,
6266             (oct & 0x10) ? "Protocol sensitive" : "Bit transparent");
6267
6268         other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
6269         proto_tree_add_text(subtree,
6270             tvb, curr_offset, 1,
6271             "%s :  Logical link identifier negotiation: %s",
6272             a_bigbuf,
6273             (oct & 0x08) ? "Full protocol negotiation" : "Default, LLI=256 only");
6274
6275         other_decode_bitfield_value(a_bigbuf, oct, 0x04, 8);
6276         proto_tree_add_text(subtree,
6277             tvb, curr_offset, 1,
6278             "%s :  Assignor/Assignee: Message originator is '%s'",
6279             a_bigbuf,
6280             (oct & 0x04) ? "assignor only" : "default assignee");
6281
6282         other_decode_bitfield_value(a_bigbuf, oct, 0x02, 8);
6283         proto_tree_add_text(subtree,
6284             tvb, curr_offset, 1,
6285             "%s :  In band/Out of band negotiation: Negotiation is done %s",
6286             a_bigbuf,
6287             (oct & 0x02) ?
6288                 "with USER INFORMATION messages on a temporary signalling connection" :
6289                 "in-band using logical link zero");
6290
6291         other_decode_bitfield_value(a_bigbuf, oct, 0x01, 8);
6292         proto_tree_add_text(subtree,
6293             tvb, curr_offset, 1,
6294             "%s :  Spare",
6295             a_bigbuf);
6296
6297         curr_offset++;
6298
6299         NO_MORE_DATA_CHECK(len);
6300
6301 bc_octet_6:
6302
6303         /* octet 6 */
6304
6305         item =
6306             proto_tree_add_text(tree,
6307                 tvb, curr_offset, 1,
6308                 "Octet 6");
6309
6310         subtree = proto_item_add_subtree(item, ett_bc_oct_6);
6311
6312         oct = tvb_get_guint8(tvb, curr_offset);
6313
6314         extended = (oct & 0x80) ? FALSE : TRUE;
6315
6316         other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
6317         proto_tree_add_text(subtree,
6318             tvb, curr_offset, 1,
6319             "%s :  Extension: %s",
6320             a_bigbuf,
6321             extended ? "extended" : "not extended");
6322
6323         other_decode_bitfield_value(a_bigbuf, oct, 0x60, 8);
6324         proto_tree_add_text(subtree,
6325             tvb, curr_offset, 1,
6326             "%s :  Layer 1 Identity: %s",
6327             a_bigbuf,
6328             ((oct & 0x60) == 0x20) ? "Octet identifier" : "Reserved");
6329
6330         other_decode_bitfield_value(a_bigbuf, oct, 0x1e, 8);
6331         proto_tree_add_text(subtree,
6332             tvb, curr_offset, 1,
6333             "%s :  User information layer 1 protocol: %s",
6334             a_bigbuf,
6335             (oct & 0x1e) ? "Reserved" : "Default layer 1 protocol");
6336
6337         other_decode_bitfield_value(a_bigbuf, oct, 0x01, 8);
6338         proto_tree_add_text(subtree,
6339             tvb, curr_offset, 1,
6340             "%s :  Synchronous/asynchronous: %s",
6341             a_bigbuf,
6342             (oct & 0x01) ? "Asynchronous" : "Synchronous");
6343
6344         curr_offset++;
6345
6346         NO_MORE_DATA_CHECK(len);
6347
6348         if (!extended) goto bc_octet_7;
6349
6350         /* octet 6a */
6351
6352         item =
6353             proto_tree_add_text(tree,
6354                 tvb, curr_offset, 1,
6355                 "Octet 6a");
6356
6357         subtree = proto_item_add_subtree(item, ett_bc_oct_6a);
6358
6359         oct = tvb_get_guint8(tvb, curr_offset);
6360
6361         extended = (oct & 0x80) ? FALSE : TRUE;
6362
6363         other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
6364         proto_tree_add_text(subtree,
6365             tvb, curr_offset, 1,
6366             "%s :  Extension: %s",
6367             a_bigbuf,
6368             extended ? "extended" : "not extended");
6369
6370         other_decode_bitfield_value(a_bigbuf, oct, 0x40, 8);
6371         proto_tree_add_text(subtree,
6372             tvb, curr_offset, 1,
6373             "%s :  Number of Stop Bits: %s",
6374             a_bigbuf,
6375             (oct & 0x40) ? "2" : "1");
6376
6377         other_decode_bitfield_value(a_bigbuf, oct, 0x20, 8);
6378         proto_tree_add_text(subtree,
6379             tvb, curr_offset, 1,
6380             "%s :  Negotiation: %s",
6381             a_bigbuf,
6382             (oct & 0x20) ? "Reserved" : "In-band negotiation not possible");
6383
6384         other_decode_bitfield_value(a_bigbuf, oct, 0x10, 8);
6385         proto_tree_add_text(subtree,
6386             tvb, curr_offset, 1,
6387             "%s :  Number of data bits excluding parity bit if present: %s",
6388             a_bigbuf,
6389             (oct & 0x10) ? "8" : "7");
6390
6391         switch (oct & 0x0f)
6392         {
6393         case 0x01: str = "0.3 kbit/s Recommendation X.1 and V.110"; break;
6394         case 0x02: str = "1.2 kbit/s Recommendation X.1 and V.110"; break;
6395         case 0x03: str = "2.4 kbit/s Recommendation X.1 and V.110"; break;
6396         case 0x04: str = "4.8 kbit/s Recommendation X.1 and V.110"; break;
6397         case 0x05: str = "9.6 kbit/s Recommendation X.1 and V.110"; break;
6398         case 0x06: str = "12.0 kbit/s transparent (non compliance with X.1 and V.110)"; break;
6399         case 0x07: str = "Reserved: was allocated in earlier phases of the protocol"; break;
6400         default:
6401             str = "Reserved";
6402             break;
6403         }
6404
6405         other_decode_bitfield_value(a_bigbuf, oct, 0x0f, 8);
6406         proto_tree_add_text(subtree,
6407             tvb, curr_offset, 1,
6408             "%s :  User rate: %s",
6409             a_bigbuf,
6410             str);
6411
6412         curr_offset++;
6413
6414         NO_MORE_DATA_CHECK(len);
6415
6416         if (!extended) goto bc_octet_7;
6417
6418         /* octet 6b */
6419
6420         item =
6421             proto_tree_add_text(tree,
6422                 tvb, curr_offset, 1,
6423                 "Octet 6b");
6424
6425         subtree = proto_item_add_subtree(item, ett_bc_oct_6b);
6426
6427         oct = tvb_get_guint8(tvb, curr_offset);
6428
6429         extended = (oct & 0x80) ? FALSE : TRUE;
6430
6431         other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
6432         proto_tree_add_text(subtree,
6433             tvb, curr_offset, 1,
6434             "%s :  Extension: %s",
6435             a_bigbuf,
6436             extended ? "extended" : "not extended");
6437
6438         switch ((oct & 0x60) >> 5)
6439         {
6440         case 0x02: str = "8 kbit/s"; break;
6441         case 0x03: str = "16 kbit/s"; break;
6442         default:
6443             str = "Reserved";
6444             break;
6445         }
6446
6447         other_decode_bitfield_value(a_bigbuf, oct, 0x60, 8);
6448         proto_tree_add_text(subtree,
6449             tvb, curr_offset, 1,
6450             "%s :  V.110/X.30 rate adaptation Intermediate rate: %s",
6451             a_bigbuf,
6452             str);
6453
6454         other_decode_bitfield_value(a_bigbuf, oct, 0x10, 8);
6455         proto_tree_add_text(subtree,
6456             tvb, curr_offset, 1,
6457             "%s :  Network independent clock (NIC) on transmission (Tx): %s to send data with network independent clock",
6458             a_bigbuf,
6459             (oct & 0x10) ? "requires" : "does not require");
6460
6461         other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
6462         proto_tree_add_text(subtree,
6463             tvb, curr_offset, 1,
6464             "%s :  Network independent clock (NIC) on reception (Rx): %s accept data with network independent clock",
6465             a_bigbuf,
6466             (oct & 0x08) ? "can" : "cannot");
6467
6468         switch (oct & 0x07)
6469         {
6470         case 0x00: str = "Odd"; break;
6471         case 0x02: str = "Even"; break;
6472         case 0x03: str = "None"; break;
6473         case 0x04: str = "Forced to 0"; break;
6474         case 0x05: str = "Forced to 1"; break;
6475         default:
6476             str = "Reserved";
6477             break;
6478         }
6479
6480         other_decode_bitfield_value(a_bigbuf, oct, 0x07, 8);
6481         proto_tree_add_text(subtree,
6482             tvb, curr_offset, 1,
6483             "%s :  Parity information: %s",
6484             a_bigbuf,
6485             str);
6486
6487         curr_offset++;
6488
6489         NO_MORE_DATA_CHECK(len);
6490
6491         if (!extended) goto bc_octet_7;
6492
6493         /* octet 6c */
6494
6495         item =
6496             proto_tree_add_text(tree,
6497                 tvb, curr_offset, 1,
6498                 "Octet 6c");
6499
6500         subtree = proto_item_add_subtree(item, ett_bc_oct_6c);
6501
6502         oct = tvb_get_guint8(tvb, curr_offset);
6503
6504         extended = (oct & 0x80) ? FALSE : TRUE;
6505
6506         other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
6507         proto_tree_add_text(subtree,
6508             tvb, curr_offset, 1,
6509             "%s :  Extension: %s",
6510             a_bigbuf,
6511             extended ? "extended" : "not extended");
6512
6513         switch ((oct & 0x60) >> 5)
6514         {
6515         case 0x01: str = "Non transparent (RLP)"; break;
6516         case 0x02: str = "Both, transparent preferred"; break;
6517         case 0x03: str = "Both, non transparent preferred"; break;
6518         default:
6519             str = "Transparent";
6520             break;
6521         }
6522
6523         other_decode_bitfield_value(a_bigbuf, oct, 0x60, 8);
6524         proto_tree_add_text(subtree,
6525             tvb, curr_offset, 1,
6526             "%s :  Connection element: %s",
6527             a_bigbuf,
6528             str);
6529
6530         switch (oct & 0x1f)
6531         {
6532         case 0x00: str = "None"; break;
6533         case 0x01: str = "V.21"; break;
6534         case 0x02: str = "V.22"; break;
6535         case 0x03: str = "V.22 bis"; break;
6536         case 0x04: str = "Reserved: was allocated in earlier phases of the protocol"; break;
6537         case 0x05: str = "V.26 ter"; break;
6538         case 0x06: str = "V.32"; break;
6539         case 0x07: str = "Modem for undefined interface"; break;
6540         case 0x08: str = "Autobauding type 1"; break;
6541         default:
6542             str = "Reserved";
6543             break;
6544         }
6545
6546         other_decode_bitfield_value(a_bigbuf, oct, 0x1f, 8);
6547         proto_tree_add_text(subtree,
6548             tvb, curr_offset, 1,
6549             "%s :  Modem type: %s",
6550             a_bigbuf,
6551             str);
6552
6553         curr_offset++;
6554
6555         NO_MORE_DATA_CHECK(len);
6556
6557         if (!extended) goto bc_octet_7;
6558
6559         /* octet 6d */
6560
6561         item =
6562             proto_tree_add_text(tree,
6563                 tvb, curr_offset, 1,
6564                 "Octet 6d");
6565
6566         subtree = proto_item_add_subtree(item, ett_bc_oct_6d);
6567
6568         oct = tvb_get_guint8(tvb, curr_offset);
6569
6570         extended = (oct & 0x80) ? FALSE : TRUE;
6571
6572         other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
6573         proto_tree_add_text(subtree,
6574             tvb, curr_offset, 1,
6575             "%s :  Extension: %s",
6576             a_bigbuf,
6577             extended ? "extended" : "not extended");
6578
6579         switch ((oct & 0x60) >> 5)
6580         {
6581         case 0x00: str = "No other modem type specified in this field"; break;
6582         case 0x02: str = "V.34"; break;
6583         default:
6584             str = "Reserved";
6585             break;
6586         }
6587
6588         other_decode_bitfield_value(a_bigbuf, oct, 0x60, 8);
6589         proto_tree_add_text(subtree,
6590             tvb, curr_offset, 1,
6591             "%s :  Other modem type: %s",
6592             a_bigbuf,
6593             str);
6594
6595         switch (oct & 0x1f)
6596         {
6597         case 0x00: str = "Fixed network user rate not applicable/No meaning is associated with this value"; break;
6598         case 0x01: str = "9.6 kbit/s Recommendation X.1 and V.110"; break;
6599         case 0x02: str = "14.4 kbit/s Recommendation X.1 and V.110"; break;
6600         case 0x03: str = "19.2 kbit/s Recommendation X.1 and V.110"; break;
6601         case 0x04: str = "28.8 kbit/s Recommendation X.1 and V.110"; break;
6602         case 0x05: str = "38.4 kbit/s Recommendation X.1 and V.110"; break;
6603         case 0x06: str = "48.0 kbit/s Recommendation X.1 and V.110(synch)"; break;
6604         case 0x07: str = "56.0 kbit/s Recommendation X.1 and V.110(synch) /bit transparent"; break;
6605         case 0x08: str = "64.0 kbit/s bit transparent"; break;
6606         case 0x09: str = "33.6 kbit/s bit transparent"; break;
6607         case 0x0a: str = "32.0 kbit/s Recommendation I.460"; break;
6608         case 0x0b: str = "31.2 kbit/s Recommendation V.34"; break;
6609         default:
6610             str = "Reserved";
6611             break;
6612         }
6613
6614         other_decode_bitfield_value(a_bigbuf, oct, 0x1f, 8);
6615         proto_tree_add_text(subtree,
6616             tvb, curr_offset, 1,
6617             "%s :  Fixed network user rate: %s",
6618             a_bigbuf,
6619             str);
6620
6621         curr_offset++;
6622
6623         NO_MORE_DATA_CHECK(len);
6624
6625         if (!extended) goto bc_octet_7;
6626
6627         /* octet 6e */
6628
6629         item =
6630             proto_tree_add_text(tree,
6631                 tvb, curr_offset, 1,
6632                 "Octet 6e");
6633
6634         subtree = proto_item_add_subtree(item, ett_bc_oct_6e);
6635
6636         oct = tvb_get_guint8(tvb, curr_offset);
6637
6638         extended = (oct & 0x80) ? FALSE : TRUE;
6639
6640         other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
6641         proto_tree_add_text(subtree,
6642             tvb, curr_offset, 1,
6643             "%s :  Extension: %s",
6644             a_bigbuf,
6645             extended ? "extended" : "not extended");
6646
6647         if (is_uplink == IS_UPLINK_TRUE)
6648         {
6649             other_decode_bitfield_value(a_bigbuf, oct, 0x40, 8);
6650             proto_tree_add_text(subtree,
6651                 tvb, curr_offset, 1,
6652                 "%s :  Acceptable channel codings: TCH/F14.4 %sacceptable",
6653                 a_bigbuf,
6654                 (oct & 0x40) ? "" : "not ");
6655
6656             other_decode_bitfield_value(a_bigbuf, oct, 0x20, 8);
6657             proto_tree_add_text(subtree,
6658                 tvb, curr_offset, 1,
6659                 "%s :  Acceptable channel codings: Spare",
6660                 a_bigbuf);
6661
6662             other_decode_bitfield_value(a_bigbuf, oct, 0x10, 8);
6663             proto_tree_add_text(subtree,
6664                 tvb, curr_offset, 1,
6665                 "%s :  Acceptable channel codings: TCH/F9.6 %sacceptable",
6666                 a_bigbuf,
6667                 (oct & 0x10) ? "" : "not ");
6668
6669             other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
6670             proto_tree_add_text(subtree,
6671                 tvb, curr_offset, 1,
6672                 "%s :  Acceptable channel codings: TCH/F4.8 %sacceptable",
6673                 a_bigbuf,
6674                 (oct & 0x08) ? "" : "not ");
6675
6676             other_decode_bitfield_value(a_bigbuf, oct, 0x07, 8);
6677             proto_tree_add_text(subtree,
6678                 tvb, curr_offset, 1,
6679                 "%s :  Maximum number of traffic channels: %u TCH",
6680                 a_bigbuf,
6681                 (oct & 0x07) + 1);
6682         }
6683         else
6684         {
6685             other_decode_bitfield_value(a_bigbuf, oct, 0x78, 8);
6686             proto_tree_add_text(subtree,
6687                 tvb, curr_offset, 1,
6688                 "%s :  Acceptable channel codings: Spare",
6689                 a_bigbuf);
6690
6691             other_decode_bitfield_value(a_bigbuf, oct, 0x07, 8);
6692             proto_tree_add_text(subtree,
6693                 tvb, curr_offset, 1,
6694                 "%s :  Maximum number of traffic channels: Spare",
6695                 a_bigbuf);
6696         }
6697
6698         curr_offset++;
6699
6700         NO_MORE_DATA_CHECK(len);
6701
6702         if (!extended) goto bc_octet_7;
6703
6704         /* octet 6f */
6705
6706         item =
6707             proto_tree_add_text(tree,
6708                 tvb, curr_offset, 1,
6709                 "Octet 6f");
6710
6711         subtree = proto_item_add_subtree(item, ett_bc_oct_6f);
6712
6713         oct = tvb_get_guint8(tvb, curr_offset);
6714
6715         extended = (oct & 0x80) ? FALSE : TRUE;
6716
6717         other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
6718         proto_tree_add_text(subtree,
6719             tvb, curr_offset, 1,
6720             "%s :  Extension: %s",
6721             a_bigbuf,
6722             extended ? "extended" : "not extended");
6723
6724         switch ((oct & 0x70) >> 4)
6725         {
6726         case 0x00: str = "not allowed/required/applicable"; break;
6727         case 0x01: str = "up to 1 TCH/F allowed/may be requested"; break;
6728         case 0x02: str = "up to 2 TCH/F allowed/may be requested"; break;
6729         case 0x03: str = "up to 3 TCH/F allowed/may be requested"; break;
6730         case 0x04: str = "up to 4 TCH/F allowed/may be requested"; break;
6731         default:
6732             str = "up to 4 TCH/F may be requested";
6733             break;
6734         }
6735
6736         other_decode_bitfield_value(a_bigbuf, oct, 0x70, 8);
6737         proto_tree_add_text(subtree,
6738             tvb, curr_offset, 1,
6739             "%s :  UIMI, User initiated modification indication: %s",
6740             a_bigbuf,
6741             str);
6742
6743         if (is_uplink == IS_UPLINK_TRUE)
6744         {
6745             switch (oct & 0x0f)
6746             {
6747             case 0x00: str = "Air interface user rate not applicable/No meaning associated with this value"; break;
6748             case 0x01: str = "9.6 kbit/s"; break;
6749             case 0x02: str = "14.4 kbit/s"; break;
6750             case 0x03: str = "19.2 kbit/s"; break;
6751             case 0x05: str = "28.8 kbit/s"; break;
6752             case 0x06: str = "38.4 kbit/s"; break;
6753             case 0x07: str = "43.2 kbit/s"; break;
6754             case 0x08: str = "57.6 kbit/s"; break;
6755             case 0x09: str = "interpreted by the network as 38.4 kbit/s in this version of the protocol"; break;
6756             case 0x0a: str = "interpreted by the network as 38.4 kbit/s in this version of the protocol"; break;
6757             case 0x0b: str = "interpreted by the network as 38.4 kbit/s in this version of the protocol"; break;
6758             case 0x0c: str = "interpreted by the network as 38.4 kbit/s in this version of the protocol"; break;
6759             default:
6760                 str = "Reserved";
6761                 break;
6762             }
6763
6764             other_decode_bitfield_value(a_bigbuf, oct, 0x0f, 8);
6765             proto_tree_add_text(subtree,
6766                 tvb, curr_offset, 1,
6767                 "%s :  Wanted air interface user rate: %s",
6768                 a_bigbuf,
6769                 str);
6770         }
6771         else
6772         {
6773             other_decode_bitfield_value(a_bigbuf, oct, 0x0f, 8);
6774             proto_tree_add_text(subtree,
6775                 tvb, curr_offset, 1,
6776                 "%s :  Wanted air interface user rate: Spare",
6777                 a_bigbuf);
6778         }
6779
6780         curr_offset++;
6781
6782         NO_MORE_DATA_CHECK(len);
6783
6784         if (!extended) goto bc_octet_7;
6785
6786         /* octet 6g */
6787
6788         item =
6789             proto_tree_add_text(tree,
6790                 tvb, curr_offset, 1,
6791                 "Octet 6g");
6792
6793         subtree = proto_item_add_subtree(item, ett_bc_oct_6g);
6794
6795         oct = tvb_get_guint8(tvb, curr_offset);
6796
6797         extended = (oct & 0x80) ? FALSE : TRUE;
6798
6799         other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
6800         proto_tree_add_text(subtree,
6801             tvb, curr_offset, 1,
6802             "%s :  Extension: %s",
6803             a_bigbuf,
6804             extended ? "extended" : "not extended");
6805
6806         if (is_uplink == IS_UPLINK_TRUE)
6807         {
6808             other_decode_bitfield_value(a_bigbuf, oct, 0x40, 8);
6809             proto_tree_add_text(subtree,
6810                 tvb, curr_offset, 1,
6811                 "%s :  Acceptable channel codings extended: TCH/F28.8 %sacceptable",
6812                 a_bigbuf,
6813                 (oct & 0x40) ? "" : "not ");
6814
6815             other_decode_bitfield_value(a_bigbuf, oct, 0x20, 8);
6816             proto_tree_add_text(subtree,
6817                 tvb, curr_offset, 1,
6818                 "%s :  Acceptable channel codings extended: TCH/F32.0 %sacceptable",
6819                 a_bigbuf,
6820                 (oct & 0x20) ? "" : "not ");
6821
6822             other_decode_bitfield_value(a_bigbuf, oct, 0x10, 8);
6823             proto_tree_add_text(subtree,
6824                 tvb, curr_offset, 1,
6825                 "%s :  Acceptable channel codings extended: TCH/F43.2 %sacceptable",
6826                 a_bigbuf,
6827                 (oct & 0x10) ? "" : "not ");
6828
6829             other_decode_bitfield_value(a_bigbuf, oct, 0x10, 8);
6830             proto_tree_add_text(subtree,
6831                 tvb, curr_offset, 1,
6832                 "%s :  Acceptable channel codings extended: TCH/F43.2 %sacceptable",
6833                 a_bigbuf,
6834                 (oct & 0x10) ? "" : "not ");
6835
6836             switch ((oct & 0x0c) >> 2)
6837             {
6838             case 0: str = "Channel coding symmetry preferred"; break;
6839             case 2: str = "Downlink biased channel coding asymmetry is preferred"; break;
6840             case 1: str = "Uplink biased channel coding asymmetry is preferred"; break;
6841             default:
6842                 str = "Unused, treat as Channel coding symmetry preferred";
6843                 break;
6844             }
6845
6846             other_decode_bitfield_value(a_bigbuf, oct, 0x0c, 8);
6847             proto_tree_add_text(subtree,
6848                 tvb, curr_offset, 1,
6849                 "%s :  Channel Coding Asymmetry Indication: %s",
6850                 a_bigbuf,
6851                 str);
6852         }
6853         else
6854         {
6855             other_decode_bitfield_value(a_bigbuf, oct, 0x7c, 8);
6856             proto_tree_add_text(subtree,
6857                 tvb, curr_offset, 1,
6858                 "%s :  EDGE Channel Codings: Spare",
6859                 a_bigbuf);
6860         }
6861
6862         other_decode_bitfield_value(a_bigbuf, oct, 0x03, 8);
6863         proto_tree_add_text(subtree,
6864             tvb, curr_offset, 1,
6865             "%s :  Spare",
6866             a_bigbuf);
6867
6868         curr_offset++;
6869
6870         NO_MORE_DATA_CHECK(len);
6871
6872 bc_octet_7:
6873
6874         /* octet 7 */
6875
6876         item =
6877             proto_tree_add_text(tree,
6878                 tvb, curr_offset, 1,
6879                 "Octet 7");
6880
6881         subtree = proto_item_add_subtree(item, ett_bc_oct_7);
6882
6883         extended = (oct & 0x80) ? FALSE : TRUE;
6884
6885         oct = tvb_get_guint8(tvb, curr_offset);
6886
6887         other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
6888         proto_tree_add_text(subtree,
6889             tvb, curr_offset, 1,
6890             "%s :  Extension: %s",
6891             a_bigbuf,
6892             extended ? "extended" : "not extended");
6893
6894         other_decode_bitfield_value(a_bigbuf, oct, 0x60, 8);
6895         proto_tree_add_text(subtree,
6896             tvb, curr_offset, 1,
6897             "%s :  Layer 2 Identity: %s",
6898             a_bigbuf,
6899             ((oct & 0x60) == 0x40) ? "Octet identifier" : "Reserved");
6900
6901         switch (oct & 0x1f)
6902         {
6903         case 0x06: str = "Reserved: was allocated in earlier phases of the protocol"; break;
6904         case 0x08: str = "ISO 6429, codeset 0 (DC1/DC3)"; break;
6905         case 0x09: str = "Reserved: was allocated but never used in earlier phases of the protocol"; break;
6906         case 0x0a: str = "Videotex profile 1"; break;
6907         case 0x0c: str = "COPnoFlCt (Character oriented Protocol with no Flow Control mechanism)"; break;
6908         case 0x0d: str = "Reserved: was allocated in earlier phases of the protocol"; break;
6909         default:
6910             str = "Reserved";
6911             break;
6912         }
6913
6914         other_decode_bitfield_value(a_bigbuf, oct, 0x1f, 8);
6915         proto_tree_add_text(subtree,
6916             tvb, curr_offset, 1,
6917             "%s :  User information layer 2 protocol: %s",
6918             a_bigbuf,
6919             str);
6920         break;
6921     }
6922
6923     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
6924
6925     return(curr_offset - offset);
6926 }
6927
6928 /*
6929  * [3] 10.5.4.5a
6930  */
6931 static guint8
6932 de_cc_cap(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
6933 {
6934     guint8      oct;
6935     guint32     curr_offset;
6936
6937     curr_offset = offset;
6938
6939     oct = tvb_get_guint8(tvb, curr_offset);
6940
6941     other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
6942
6943     switch ((oct & 0xf0) >> 4)
6944     {
6945     case 0:
6946         proto_tree_add_text(tree,
6947             tvb, curr_offset, 1,
6948             "%s :  Maximum number of supported bearers: 1",
6949             a_bigbuf);
6950         break;
6951
6952     default:
6953         proto_tree_add_text(tree,
6954             tvb, curr_offset, 1,
6955             "%s :  Maximum number of supported bearers: %u",
6956             a_bigbuf,
6957             (oct & 0xf0) >> 4);
6958         break;
6959     }
6960
6961     other_decode_bitfield_value(a_bigbuf, oct, 0x0c, 8);
6962     proto_tree_add_text(tree,
6963         tvb, curr_offset, 1,
6964         "%s :  Spare",
6965         a_bigbuf);
6966
6967     other_decode_bitfield_value(a_bigbuf, oct, 0x02, 8);
6968     proto_tree_add_text(tree,
6969         tvb, curr_offset, 1,
6970         "%s :  PCP: the mobile station %s the Prolonged Clearing Procedure",
6971         a_bigbuf,
6972         (oct & 0x02) ? "supports" : "does not support");
6973
6974     other_decode_bitfield_value(a_bigbuf, oct, 0x01, 8);
6975     proto_tree_add_text(tree,
6976         tvb, curr_offset, 1,
6977         "%s :  DTMF: %s",
6978         a_bigbuf,
6979         (oct & 0x01) ?
6980             "the mobile station supports DTMF as specified in subclause 5.5.7 of TS 24.008" :
6981             "reserved for earlier versions of the protocol");
6982
6983     curr_offset++;
6984
6985     NO_MORE_DATA_CHECK(len);
6986
6987     oct = tvb_get_guint8(tvb, curr_offset);
6988
6989     other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
6990     proto_tree_add_text(tree,
6991         tvb, curr_offset, 1,
6992         "%s :  Spare",
6993         a_bigbuf);
6994
6995     other_decode_bitfield_value(a_bigbuf, oct, 0x0f, 8);
6996     proto_tree_add_text(tree,
6997         tvb, curr_offset, 1,
6998         "%s :  Maximum number of speech bearers: %u",
6999         a_bigbuf,
7000         oct & 0x0f);
7001
7002     curr_offset++;
7003
7004     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
7005
7006     return(curr_offset - offset);
7007 }
7008
7009 /*
7010  * [3] 10.5.4.6
7011  */
7012 static guint8
7013 de_call_state(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
7014 {
7015     guint8      oct;
7016     guint32     curr_offset;
7017     proto_tree  *subtree;
7018     proto_item  *item;
7019     const gchar *str;
7020
7021     len = len;
7022     curr_offset = offset;
7023
7024     oct = tvb_get_guint8(tvb, curr_offset);
7025
7026     item =
7027         proto_tree_add_text(tree,
7028             tvb, curr_offset, 1,
7029             gsm_dtap_elem_strings[DE_CALL_STATE].strptr);
7030
7031     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_CALL_STATE]);
7032
7033     switch ((oct & 0xc0) >> 6)
7034     {
7035     case 0: str = "Coding as specified in ITU-T Rec. Q.931"; break;
7036     case 1: str = "Reserved for other international standards"; break;
7037     case 2: str = "National standard"; break;
7038     default:
7039         str = "Standard defined for the GSM PLMNS";
7040         break;
7041     }
7042
7043     other_decode_bitfield_value(a_bigbuf, oct, 0xc0, 8);
7044     proto_tree_add_text(subtree,
7045         tvb, curr_offset, 1,
7046         "%s :  Coding standard: %s",
7047         a_bigbuf,
7048         str);
7049
7050     switch (oct & 0x3f)
7051     {
7052     case 0x00: str = "UO - null                                 NO - null"; break;
7053     case 0x02: str = "U0.1- MM connection pending               N0.1- MM connection pending"; break;
7054     case 0x22: str = "U0.2- CC prompt present                   N0.2- CC connection pending"; break;
7055     case 0x23: str = "U0.3- Wait for network information        N0.3- Network answer pending"; break;
7056     case 0x24: str = "U0.4- CC-Establishment present            N0.4- CC-Establishment present"; break;
7057     case 0x25: str = "U0.5- CC-Establishment confirmed          N0.5- CC-Establishment confirmed"; break;
7058     case 0x26: str = "U0.6- Recall present                      N0.6- Recall present"; break;
7059     case 0x01: str = "U1 - call initiated                       N1 - call initiated"; break;
7060     case 0x03: str = "U3 - mobile originating call proceeding   N3 - mobile originating call proceeding"; break;
7061     case 0x04: str = "U4 - call delivered                       N4 - call delivered"; break;
7062     case 0x06: str = "U6 - call present                         N6 - call present"; break;
7063     case 0x07: str = "U7 - call received                        N7 - call received"; break;
7064     case 0x08: str = "U8 - connect request                      N8 - connect request"; break;
7065     case 0x09: str = "U9 - mobile terminating call confirmed    N9 - mobile terminating call confirmed"; break;
7066     case 0x0a: str = "U10- active                               N10- active"; break;
7067     case 0x0b: str = "U11- disconnect request"; break;
7068     case 0x0c: str = "U12- disconnect indication                N12-disconnect indication"; break;
7069     case 0x13: str = "U19- release request                      N19- release request"; break;
7070     case 0x1a: str = "U26- mobile originating modify            N26- mobile originating modify"; break;
7071     case 0x1b: str = "U27- mobile terminating modify            N27- mobile terminating modify"; break;
7072     case 0x1c: str = "                                          N28- connect indication"; break;
7073     default:
7074         str = "Unknown";
7075         break;
7076     }
7077
7078     other_decode_bitfield_value(a_bigbuf, oct, 0x3f, 8);
7079     proto_tree_add_text(subtree,
7080         tvb, curr_offset, 1,
7081         "%s :  Call state value: %s",
7082         a_bigbuf,
7083         str);
7084
7085     curr_offset++;
7086
7087     /* no length check possible */
7088
7089     return(curr_offset - offset);
7090 }
7091
7092 static const true_false_string gsm_a_extension_value = {
7093   "No Extension",
7094   "Extension"
7095 };
7096
7097 const value_string gsm_a_type_of_number_values[] = {
7098         {   0x00,       "unknown" },
7099         {   0x01,       "International Number" },
7100         {   0x02,       "National number" },
7101         {   0x03,       "Network Specific Number" },
7102         {   0x04,       "Dedicated access, short code" },
7103         {   0x05,       "Reserved" },
7104         {   0x06,       "Reserved" },
7105         {   0x07,       "Reserved for extension" },
7106         { 0, NULL }
7107 };
7108
7109 const value_string gsm_a_numbering_plan_id_values[] = {
7110         {   0x00,       "unknown" },
7111         {   0x01,       "ISDN/Telephony Numbering (Rec ITU-T E.164)" },
7112         {   0x02,       "spare" },
7113         {   0x03,       "Data Numbering (ITU-T Rec. X.121)" },
7114         {   0x04,       "Telex Numbering (ITU-T Rec. F.69)" },
7115         {   0x08,       "National Numbering" },
7116         {   0x09,       "Private Numbering" },
7117         {       0x0d,   "reserved for CTS (see 3GPP TS 44.056 [91])" },
7118         {   0x0f,       "Reserved for extension" },
7119         { 0, NULL }
7120 };
7121
7122 /*
7123  * [3] 10.5.4.7
7124  */
7125 static guint8
7126 de_cld_party_bcd_num(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
7127 {
7128     guint8      *poctets;
7129     guint32     curr_offset;
7130
7131     curr_offset = offset;
7132
7133     proto_tree_add_item(tree, hf_gsm_a_extension, tvb, curr_offset, 1, FALSE);
7134         proto_tree_add_item(tree, hf_gsm_a_type_of_number , tvb, curr_offset, 1, FALSE);
7135         proto_tree_add_item(tree, hf_gsm_a_numbering_plan_id , tvb, curr_offset, 1, FALSE);
7136
7137     curr_offset++;
7138
7139     NO_MORE_DATA_CHECK(len);
7140
7141     poctets = tvb_get_ephemeral_string(tvb, curr_offset, len - (curr_offset - offset));
7142
7143     my_dgt_tbcd_unpack(a_bigbuf, poctets, len - (curr_offset - offset),
7144         &Dgt_mbcd);
7145
7146     proto_tree_add_string_format(tree, hf_gsm_a_cld_party_bcd_num,
7147         tvb, curr_offset, len - (curr_offset - offset),
7148         a_bigbuf,
7149         "BCD Digits: %s",
7150         a_bigbuf);
7151
7152         if (sccp_assoc && ! sccp_assoc->called_party) {
7153                 sccp_assoc->called_party = se_strdup(a_bigbuf);
7154         }
7155         
7156     curr_offset += len - (curr_offset - offset);
7157
7158     if (add_string)
7159         g_snprintf(add_string, string_len, " - (%s)", a_bigbuf);
7160
7161     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
7162
7163     return(curr_offset - offset);
7164 }
7165
7166 /*
7167  * [3] 10.5.4.8
7168  */
7169 static guint8
7170 de_cld_party_sub_addr(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
7171 {
7172     guint8      oct;
7173     guint32     curr_offset;
7174     const gchar *str;
7175
7176     curr_offset = offset;
7177
7178     oct = tvb_get_guint8(tvb, curr_offset);
7179
7180     proto_tree_add_item(tree, hf_gsm_a_extension, tvb, curr_offset, 1, FALSE);
7181
7182     switch ((oct & 0x70) >> 4)
7183     {
7184     case 0: str = "NSAP (X.213/ISO 8348 AD2)"; break;
7185     case 2: str = "User specified"; break;
7186     default:
7187         str = "Reserved";
7188         break;
7189     }
7190
7191     other_decode_bitfield_value(a_bigbuf, oct, 0x70, 8);
7192     proto_tree_add_text(tree,
7193         tvb, curr_offset, 1,
7194         "%s :  Type of subaddress: %s",
7195         a_bigbuf,
7196         str);
7197
7198     other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
7199     proto_tree_add_text(tree,
7200         tvb, curr_offset, 1,
7201         "%s :  Odd/Even indicator: %s",
7202         a_bigbuf,
7203         (oct & 0x08) ?
7204             "odd number of address signals" : "even number of address signals");
7205
7206     other_decode_bitfield_value(a_bigbuf, oct, 0x07, 8);
7207     proto_tree_add_text(tree,
7208         tvb, curr_offset, 1,
7209         "%s :  Spare",
7210         a_bigbuf);
7211
7212     curr_offset++;
7213
7214     NO_MORE_DATA_CHECK(len);
7215
7216     proto_tree_add_text(tree,
7217         tvb, curr_offset, len - (curr_offset - offset),
7218         "Subaddress information");
7219
7220     curr_offset += len - (curr_offset - offset);
7221
7222     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
7223
7224     return(curr_offset - offset);
7225 }
7226
7227 /* 3GPP TS 24.008
7228  * [3] 10.5.4.9
7229  */
7230 static guint8
7231 de_clg_party_bcd_num(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
7232 {
7233     guint8      oct;
7234     guint8      *poctets;
7235     guint32     curr_offset;
7236     const gchar *str;
7237
7238     curr_offset = offset;
7239
7240     proto_tree_add_item(tree, hf_gsm_a_extension, tvb, curr_offset, 1, FALSE);
7241         proto_tree_add_item(tree, hf_gsm_a_type_of_number , tvb, curr_offset, 1, FALSE);
7242         proto_tree_add_item(tree, hf_gsm_a_numbering_plan_id , tvb, curr_offset, 1, FALSE);
7243
7244     curr_offset++;
7245
7246     oct = tvb_get_guint8(tvb, curr_offset);
7247
7248     proto_tree_add_item(tree, hf_gsm_a_extension, tvb, curr_offset, 1, FALSE);
7249
7250     switch ((oct & 0x60) >> 5)
7251     {
7252     case 0: str = "Presentation allowed"; break;
7253     case 1: str = "Presentation restricted"; break;
7254     case 2: str = "Number not available due to interworking"; break;
7255     default:
7256         str = "Reserved";
7257         break;
7258     }
7259
7260     other_decode_bitfield_value(a_bigbuf, oct, 0x60, 8);
7261     proto_tree_add_text(tree,
7262         tvb, curr_offset, 1,
7263         "%s :  Presentation indicator: %s",
7264         a_bigbuf,
7265         str);
7266
7267     other_decode_bitfield_value(a_bigbuf, oct, 0x1c, 8);
7268     proto_tree_add_text(tree,
7269         tvb, curr_offset, 1,
7270         "%s :  Spare",
7271         a_bigbuf);
7272
7273     switch (oct & 0x03)
7274     {
7275     case 0: str = "User-provided, not screened"; break;
7276     case 1: str = "User-provided, verified and passed"; break;
7277     case 2: str = "User-provided, verified and failed"; break;
7278     default:
7279         str = "Network provided";
7280         break;
7281     }
7282
7283     other_decode_bitfield_value(a_bigbuf, oct, 0x03, 8);
7284     proto_tree_add_text(tree,
7285         tvb, curr_offset, 1,
7286         "%s :  Screening indicator: %s",
7287         a_bigbuf,
7288         str);
7289
7290     curr_offset++;
7291
7292     NO_MORE_DATA_CHECK(len);
7293
7294     poctets = tvb_get_ephemeral_string(tvb, curr_offset, len - (curr_offset - offset));
7295
7296     my_dgt_tbcd_unpack(a_bigbuf, poctets, len - (curr_offset - offset),
7297         &Dgt_mbcd);
7298
7299     proto_tree_add_string_format(tree, hf_gsm_a_clg_party_bcd_num,
7300         tvb, curr_offset, len - (curr_offset - offset),
7301         a_bigbuf,
7302         "BCD Digits: %s",
7303         a_bigbuf);
7304
7305     curr_offset += len - (curr_offset - offset);
7306
7307     if (add_string)
7308         g_snprintf(add_string, string_len, " - (%s)", a_bigbuf);
7309
7310     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
7311
7312     return(curr_offset - offset);
7313 }
7314
7315 /*
7316  * [3] 10.5.4.10
7317  */
7318 static guint8
7319 de_clg_party_sub_addr(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
7320 {
7321     guint8      oct;
7322     guint32     curr_offset;
7323     const gchar *str;
7324
7325     curr_offset = offset;
7326
7327     oct = tvb_get_guint8(tvb, curr_offset);
7328
7329     proto_tree_add_item(tree, hf_gsm_a_extension, tvb, curr_offset, 1, FALSE);
7330
7331     switch ((oct & 0x70) >> 4)
7332     {
7333     case 0: str = "NSAP (X.213/ISO 8348 AD2)"; break;
7334     case 2: str = "User specified"; break;
7335     default:
7336         str = "Reserved";
7337         break;
7338     }
7339
7340     other_decode_bitfield_value(a_bigbuf, oct, 0x70, 8);
7341     proto_tree_add_text(tree,
7342         tvb, curr_offset, 1,
7343         "%s :  Type of subaddress: %s",
7344         a_bigbuf,
7345         str);
7346
7347     other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
7348     proto_tree_add_text(tree,
7349         tvb, curr_offset, 1,
7350         "%s :  Odd/Even indicator: %s",
7351         a_bigbuf,
7352         (oct & 0x08) ?
7353             "odd number of address signals" : "even number of address signals");
7354
7355     other_decode_bitfield_value(a_bigbuf, oct, 0x07, 8);
7356     proto_tree_add_text(tree,
7357         tvb, curr_offset, 1,
7358         "%s :  Spare",
7359         a_bigbuf);
7360
7361     curr_offset++;
7362
7363     NO_MORE_DATA_CHECK(len);
7364
7365     proto_tree_add_text(tree,
7366         tvb, curr_offset, len - (curr_offset - offset),
7367         "Subaddress information");
7368
7369     curr_offset += len - (curr_offset - offset);
7370
7371     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
7372
7373     return(curr_offset - offset);
7374 }
7375
7376 /*
7377  * [3] 10.5.4.11
7378  */
7379 static guint8
7380 de_cause(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
7381 {
7382     guint8      oct;
7383     guint8      cause;
7384     guint32     curr_offset;
7385     const gchar *str;
7386
7387     curr_offset = offset;
7388
7389     oct = tvb_get_guint8(tvb, curr_offset);
7390
7391     other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
7392     proto_tree_add_text(tree,
7393         tvb, curr_offset, 1,
7394         "%s :  Extension: %s",
7395         a_bigbuf,
7396         (oct & 0x80) ? "not extended" : "extended");
7397
7398     switch ((oct & 0x60) >> 5)
7399     {
7400     case 0: str = "Coding as specified in ITU-T Rec. Q.931"; break;
7401     case 1: str = "Reserved for other international standards"; break;
7402     case 2: str = "National standard"; break;
7403     default:
7404         str = "Standard defined for the GSM PLMNS";
7405         break;
7406     }
7407
7408     other_decode_bitfield_value(a_bigbuf, oct, 0x60, 8);
7409     proto_tree_add_text(tree,
7410         tvb, curr_offset, 1,
7411         "%s :  Coding standard: %s",
7412         a_bigbuf,
7413         str);
7414
7415     other_decode_bitfield_value(a_bigbuf, oct, 0x10, 8);
7416     proto_tree_add_text(tree,
7417         tvb, curr_offset, 1,
7418         "%s :  Spare",
7419         a_bigbuf);
7420
7421     switch (oct & 0x0f)
7422     {
7423     case 0: str = "User"; break;
7424     case 1: str = "Private network serving the local user"; break;
7425     case 2: str = "Public network serving the local user"; break;
7426     case 3: str = "Transit network"; break;
7427     case 4: str = "Public network serving the remote user"; break;
7428     case 5: str = "Private network serving the remote user"; break;
7429     case 7: str = "International network"; break;
7430     case 10: str = "Network beyond interworking point"; break;
7431     default:
7432         str = "Reserved";
7433         break;
7434     }
7435
7436     other_decode_bitfield_value(a_bigbuf, oct, 0x0f, 8);
7437     proto_tree_add_text(tree,
7438         tvb, curr_offset, 1,
7439         "%s :  Location: %s",
7440         a_bigbuf,
7441         str);
7442
7443     curr_offset++;
7444
7445     oct = tvb_get_guint8(tvb, curr_offset);
7446
7447     if (!(oct & 0x80))
7448     {
7449         proto_tree_add_item(tree, hf_gsm_a_extension, tvb, curr_offset, 1, FALSE);
7450
7451         other_decode_bitfield_value(a_bigbuf, oct, 0x7f, 8);
7452         proto_tree_add_text(tree,
7453             tvb, curr_offset, 1,
7454             "%s :  Recommendation",
7455             a_bigbuf);
7456
7457         curr_offset++;
7458
7459         oct = tvb_get_guint8(tvb, curr_offset);
7460     }
7461
7462     proto_tree_add_item(tree, hf_gsm_a_extension, tvb, curr_offset, 1, FALSE);
7463
7464     cause = oct & 0x7f;
7465     switch (cause)
7466     {
7467     case 1: str = "Unassigned (unallocated) number"; break;
7468     case 3: str = "No route to destination"; break;
7469     case 6: str = "Channel unacceptable"; break;
7470     case 8: str = "Operator determined barring"; break;
7471     case 16: str = "Normal call clearing"; break;
7472     case 17: str = "User busy"; break;
7473     case 18: str = "No user responding"; break;
7474     case 19: str = "User alerting, no answer"; break;
7475     case 21: str = "Call rejected"; break;
7476     case 22: str = "Number changed"; break;
7477     case 25: str = "Pre-emption"; break;
7478     case 26: str = "Non selected user clearing"; break;
7479     case 27: str = "Destination out of order"; break;
7480     case 28: str = "Invalid number format (incomplete number)"; break;
7481     case 29: str = "Facility rejected"; break;
7482     case 30: str = "Response to STATUS ENQUIRY"; break;
7483     case 31: str = "Normal, unspecified"; break;
7484     case 34: str = "No circuit/channel available"; break;
7485     case 38: str = "Network out of order"; break;
7486     case 41: str = "Temporary failure"; break;
7487     case 42: str = "Switching equipment congestion"; break;
7488     case 43: str = "Access information discarded"; break;
7489     case 44: str = "requested circuit/channel not available"; break;
7490     case 47: str = "Resources unavailable, unspecified"; break;
7491     case 49: str = "Quality of service unavailable"; break;
7492     case 50: str = "Requested facility not subscribed"; break;
7493     case 55: str = "Incoming calls barred within the CUG"; break;
7494     case 57: str = "Bearer capability not authorized"; break;
7495     case 58: str = "Bearer capability not presently available"; break;
7496     case 63: str = "Service or option not available, unspecified"; break;
7497     case 65: str = "Bearer service not implemented"; break;
7498     case 68: str = "ACM equal to or greater than ACMmax"; break;
7499     case 69: str = "Requested facility not implemented"; break;
7500     case 70: str = "Only restricted digital information bearer capability is available"; break;
7501     case 79: str = "Service or option not implemented, unspecified"; break;
7502     case 81: str = "Invalid transaction identifier value"; break;
7503     case 87: str = "User not member of CUG"; break;
7504     case 88: str = "Incompatible destination"; break;
7505     case 91: str = "Invalid transit network selection"; break;
7506     case 95: str = "Semantically incorrect message"; break;
7507     case 96: str = "Invalid mandatory information"; break;
7508     case 97: str = "Message type non-existent or not implemented"; break;
7509     case 98: str = "Message type not compatible with protocol state"; break;
7510     case 99: str = "Information element non-existent or not implemented"; break;
7511     case 100: str = "Conditional IE error"; break;
7512     case 101: str = "Message not compatible with protocol state"; break;
7513     case 102: str = "Recovery on timer expiry"; break;
7514     case 111: str = "Protocol error, unspecified"; break;
7515     case 127: str = "Interworking, unspecified"; break;
7516     default:
7517         if (cause <= 31) { str = "Treat as Normal, unspecified"; }
7518         else if ((cause >= 32) && (cause <= 47)) { str = "Treat as Resources unavailable, unspecified"; }
7519         else if ((cause >= 48) && (cause <= 63)) { str = "Treat as Service or option not available, unspecified"; }
7520         else if ((cause >= 64) && (cause <= 79)) { str = "Treat as Service or option not implemented, unspecified"; }
7521         else if ((cause >= 80) && (cause <= 95)) { str = "Treat as Semantically incorrect message"; }
7522         else if ((cause >= 96) && (cause <= 111)) { str = "Treat as Protocol error, unspecified"; }
7523         else if ((cause >= 112) && (cause <= 127)) { str = "Treat as Interworking, unspecified"; }
7524         break;
7525     }
7526
7527     other_decode_bitfield_value(a_bigbuf, oct, 0x7f, 8);
7528     proto_tree_add_uint_format(tree, hf_gsm_a_dtap_cause,
7529         tvb, curr_offset, 1, cause,
7530         "%s :  Cause: (%u) %s",
7531         a_bigbuf,
7532         cause,
7533         str);
7534
7535     curr_offset++;
7536
7537     if (add_string)
7538         g_snprintf(add_string, string_len, " - (%u) %s", cause, str);
7539
7540     NO_MORE_DATA_CHECK(len);
7541
7542     proto_tree_add_text(tree,
7543         tvb, curr_offset, len - (curr_offset - offset),
7544         "Diagnostics");
7545
7546     curr_offset += len - (curr_offset - offset);
7547
7548     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
7549
7550     return(curr_offset - offset);
7551 }
7552
7553 /*
7554  * 10.5.4.18 Low layer compatibility 
7555  */
7556 static guint8
7557 de_llc(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
7558 {
7559     guint32     curr_offset;
7560
7561     curr_offset = offset;
7562
7563         dissect_q931_bearer_capability_ie(tvb, offset, len, tree);
7564
7565         curr_offset = curr_offset + len;
7566     return(curr_offset - offset);
7567 }
7568
7569 /*
7570  * [6] 3.6
7571  */
7572
7573
7574 static guint8
7575 de_facility(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint fac_len, gchar *add_string _U_, int string_len _U_)
7576 {
7577     guint       saved_offset;
7578         gint8 class;
7579         gboolean pc;
7580         gboolean ind = FALSE;
7581         guint32 component_len = 0;
7582         guint32 header_end_offset;
7583         guint32 header_len;
7584         asn1_ctx_t asn1_ctx;
7585         tvbuff_t *SS_tvb = NULL;
7586         void *save_private_data;
7587
7588         asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, g_pinfo);
7589         
7590         
7591         save_private_data= g_pinfo->private_data;
7592         saved_offset = offset;
7593         g_pinfo->private_data = NULL;
7594         while ( fac_len > (offset - saved_offset)){ 
7595
7596                 /* Get the length of the component there can be more tnan one component in a facility message */
7597           
7598                 header_end_offset = get_ber_identifier(tvb, offset, &class, &pc, &comp_type_tag);
7599                 header_end_offset = get_ber_length(tvb, header_end_offset, &component_len, &ind);
7600                 if (ind){
7601                         proto_tree_add_text(tree, tvb, offset+1, 1,
7602                                 "Indefinte length, ignoring component");
7603                         return (fac_len);
7604                 }
7605                 header_len = header_end_offset - offset;
7606                 component_len = header_len + component_len;
7607                 /*
7608                 dissect_ROS_Component(FALSE, tvb, offset, &asn1_ctx, tree, hf_ROS_component);
7609                 TODO Call gsm map here
7610                 */
7611             SS_tvb = tvb_new_subset(tvb, offset, component_len, component_len);
7612                 call_dissector(gsm_map_handle, SS_tvb, g_pinfo, tree);
7613                 offset = offset + component_len;
7614         } 
7615         g_pinfo->private_data = save_private_data;
7616         return(fac_len);
7617
7618
7619 }
7620
7621 /*
7622  * [3] 10.5.4.17
7623  */
7624 static guint8
7625 de_keypad_facility(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
7626 {
7627     guint8      oct;
7628     guint32     curr_offset;
7629
7630     len = len;
7631     curr_offset = offset;
7632
7633     oct = tvb_get_guint8(tvb, curr_offset);
7634
7635     other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
7636     proto_tree_add_text(tree,
7637         tvb, curr_offset, 1,
7638         "%s :  Spare",
7639         a_bigbuf);
7640
7641     other_decode_bitfield_value(a_bigbuf, oct, 0x7f, 8);
7642     proto_tree_add_text(tree,
7643         tvb, curr_offset, 1,
7644         "%s :  Keypad information: %c",
7645         a_bigbuf,
7646         oct & 0x7f);
7647
7648     curr_offset++;
7649
7650     if (add_string)
7651         g_snprintf(add_string, string_len, " - %c", oct & 0x7f);
7652
7653     /* no length check possible */
7654
7655     return(curr_offset - offset);
7656 }
7657
7658 /*
7659  * [3] 10.5.4.21
7660  */
7661 static guint8
7662 de_prog_ind(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
7663 {
7664     guint8      oct;
7665     guint32     curr_offset;
7666     const gchar *str;
7667
7668     len = len;
7669     curr_offset = offset;
7670
7671     oct = tvb_get_guint8(tvb, curr_offset);
7672
7673     other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
7674     proto_tree_add_text(tree,
7675         tvb, curr_offset, 1,
7676         "%s :  Extension: %s",
7677         a_bigbuf,
7678         (oct & 0x80) ? "extended" : "not extended");
7679
7680     switch ((oct & 0x60) >> 5)
7681     {
7682     case 0: str = "Coding as specified in ITU-T Rec. Q.931"; break;
7683     case 1: str = "Reserved for other international standards"; break;
7684     case 2: str = "National standard"; break;
7685     default:
7686         str = "Standard defined for the GSM PLMNS";
7687         break;
7688     }
7689
7690     other_decode_bitfield_value(a_bigbuf, oct, 0x60, 8);
7691     proto_tree_add_text(tree,
7692         tvb, curr_offset, 1,
7693         "%s :  Coding standard: %s",
7694         a_bigbuf,
7695         str);
7696
7697     other_decode_bitfield_value(a_bigbuf, oct, 0x10, 8);
7698     proto_tree_add_text(tree,
7699         tvb, curr_offset, 1,
7700         "%s :  Spare",
7701         a_bigbuf);
7702
7703     switch (oct & 0x0f)
7704     {
7705     case 0: str = "User"; break;
7706     case 1: str = "Private network serving the local user"; break;
7707     case 2: str = "Public network serving the local user"; break;
7708     case 4: str = "Public network serving the remote user"; break;
7709     case 5: str = "Private network serving the remote user"; break;
7710     case 10: str = "Network beyond interworking point"; break;
7711     default:
7712         str = "Reserved";
7713         break;
7714     }
7715
7716     other_decode_bitfield_value(a_bigbuf, oct, 0x0f, 8);
7717     proto_tree_add_text(tree,
7718         tvb, curr_offset, 1,
7719         "%s :  Location: %s",
7720         a_bigbuf,
7721         str);
7722
7723     curr_offset++;
7724
7725     oct = tvb_get_guint8(tvb, curr_offset);
7726
7727     other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
7728     proto_tree_add_text(tree,
7729         tvb, curr_offset, 1,
7730         "%s :  Extension: %s",
7731         a_bigbuf,
7732         (oct & 0x80) ? "extended" : "not extended");
7733
7734     switch (oct & 0x7f)
7735     {
7736     case 1: str = "Call is not end-to-end PLMN/ISDN, further call progress information may be available in-band"; break;
7737     case 2: str = "Destination address in non-PLMN/ISDN"; break;
7738     case 3: str = "Origination address in non-PLMN/ISDN"; break;
7739     case 4: str = "Call has returned to the PLMN/ISDN"; break;
7740     case 8: str = "In-band information or appropriate pattern now available"; break;
7741     case 32: str = "Call is end-to-end PLMN/ISDN"; break;
7742     case 64: str = "Queueing"; break;
7743     default:
7744         str = "Unspecific";
7745         break;
7746     }
7747
7748     other_decode_bitfield_value(a_bigbuf, oct, 0x7f, 8);
7749     proto_tree_add_text(tree,
7750         tvb, curr_offset, 1,
7751         "%s :  Progress Description: %s (%d)",
7752         a_bigbuf,
7753         str,
7754         oct & 0x7f);
7755
7756     if (add_string)
7757         g_snprintf(add_string, string_len, " - %d", oct & 0x7f);
7758
7759     curr_offset++;
7760
7761     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
7762
7763     return(curr_offset - offset);
7764 }
7765
7766 /*
7767  * [3] 10.5.4.22
7768  */
7769 static guint8
7770 de_repeat_ind(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
7771 {
7772     guint8      oct;
7773     guint32     curr_offset;
7774     const gchar *str;
7775
7776     len = len;
7777     curr_offset = offset;
7778
7779     oct = tvb_get_guint8(tvb, curr_offset);
7780
7781     switch (oct & 0x0f)
7782     {
7783     case 1: str = "Circular for successive selection 'mode 1 alternate mode 2'"; break;
7784     case 2: str = "Support of fallback  mode 1 preferred, mode 2 selected if setup of mode 1 fails"; break;
7785     case 3: str = "Reserved: was allocated in earlier phases of the protocol"; break;
7786     default:
7787         str = "Reserved";
7788         break;
7789     }
7790
7791     other_decode_bitfield_value(a_bigbuf, oct, 0x0f, 8);
7792     proto_tree_add_text(tree,
7793         tvb, curr_offset, 1,
7794         "%s :  %s",
7795         a_bigbuf,
7796         str);
7797
7798     curr_offset++;
7799
7800     /* no length check possible */
7801
7802     return(curr_offset - offset);
7803 }
7804
7805 /*
7806  * [6] 3.7.2
7807  */
7808 static guint8
7809 de_ss_ver_ind(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
7810 {
7811     guint8      oct;
7812     guint32     curr_offset;
7813     const gchar *str;
7814
7815     curr_offset = offset;
7816
7817     oct = tvb_get_guint8(tvb, curr_offset);
7818
7819     switch (oct)
7820     {
7821     case 0: str = "Phase 2 service, ellipsis notation, and phase 2 error handling is supported"; break;
7822     case 1: str = "SS-Protocol version 3 is supported, and phase 2 error handling is supported"; break;
7823     default:
7824         str = "Reserved";
7825         break;
7826     }
7827
7828     proto_tree_add_text(tree,
7829         tvb, curr_offset, 1,
7830         "%s",
7831         str);
7832
7833     curr_offset++;
7834
7835     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
7836
7837     return(curr_offset - offset);
7838 }
7839
7840 /*
7841  * [5] 8.1.4.1 3GPP TS 24.011 version 6.1.0 Release 6
7842  */
7843 static guint8
7844 de_cp_user_data(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
7845 {
7846     guint32     curr_offset;
7847     tvbuff_t    *rp_tvb;
7848
7849     curr_offset = offset;
7850
7851     proto_tree_add_text(tree, tvb, curr_offset, len,
7852         "RPDU (not displayed)");
7853
7854     /*
7855      * dissect the embedded RP message
7856      */
7857     rp_tvb = tvb_new_subset(tvb, curr_offset, len, len);
7858
7859     call_dissector(rp_handle, rp_tvb, g_pinfo, g_tree);
7860
7861     curr_offset += len;
7862
7863     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
7864
7865     return(curr_offset - offset);
7866 }
7867
7868 /*
7869  * [5] 8.1.4.2
7870  */
7871 static guint8
7872 de_cp_cause(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
7873 {
7874     guint8      oct;
7875     guint32     curr_offset;
7876     const gchar *str;
7877
7878     len = len;
7879     curr_offset = offset;
7880
7881     oct = tvb_get_guint8(tvb, curr_offset);
7882
7883     switch (oct)
7884     {
7885     case 17: str = "Network failure"; break;
7886     case 22: str = "Congestion"; break;
7887     case 81: str = "Invalid Transaction Identifier value"; break;
7888     case 95: str = "Semantically incorrect message"; break;
7889     case 96: str = "Invalid mandatory information"; break;
7890     case 97: str = "Message type non-existent or not implemented"; break;
7891     case 98: str = "Message not compatible with the short message protocol state"; break;
7892     case 99: str = "Information element non-existent or not implemented"; break;
7893     case 111: str = "Protocol error, unspecified"; break;
7894     default:
7895         str = "Reserved, treat as Protocol error, unspecified";
7896         break;
7897     }
7898
7899     proto_tree_add_text(tree,
7900         tvb, curr_offset, 1,
7901         "Cause: (%u) %s",
7902         oct,
7903         str);
7904
7905     curr_offset++;
7906
7907     if (add_string)
7908         g_snprintf(add_string, string_len, " - (%u) %s", oct, str);
7909
7910     /* no length check possible */
7911
7912     return(curr_offset - offset);
7913 }
7914
7915 /*
7916  * [5] 8.2.3
7917  */
7918 static guint8
7919 de_rp_message_ref(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
7920 {
7921     guint8      oct;
7922     guint32     curr_offset;
7923
7924     len = len;
7925     curr_offset = offset;
7926
7927     oct = tvb_get_guint8(tvb, curr_offset);
7928
7929     proto_tree_add_text(tree,
7930         tvb, curr_offset, 1,
7931         "RP-Message Reference: 0x%02x (%u)",
7932         oct,
7933         oct);
7934
7935     curr_offset++;
7936
7937     /* no length check possible */
7938
7939     return(curr_offset - offset);
7940 }
7941
7942 /*
7943  * [5] 8.2.5.1
7944  */
7945 static guint8
7946 de_rp_orig_addr(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
7947 {
7948     return(de_cld_party_bcd_num(tvb, tree, offset, len, add_string, string_len));
7949 }
7950
7951 /*
7952  * [5] 8.2.5.2
7953  */
7954 static guint8
7955 de_rp_dest_addr(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
7956 {
7957     return(de_cld_party_bcd_num(tvb, tree, offset, len, add_string, string_len));
7958 }
7959
7960 /*
7961  * [5] 8.2.5.3
7962  */
7963 static guint8
7964 de_rp_user_data(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
7965 {
7966     guint32     curr_offset;
7967     tvbuff_t    *tpdu_tvb;
7968
7969     curr_offset = offset;
7970
7971     proto_tree_add_text(tree, tvb, curr_offset, len,
7972         "TPDU (not displayed)");
7973
7974     /*
7975      * dissect the embedded TPDU message
7976      */
7977     tpdu_tvb = tvb_new_subset(tvb, curr_offset, len, len);
7978
7979     dissector_try_port(sms_dissector_table, 0, tpdu_tvb, g_pinfo, g_tree);
7980
7981     curr_offset += len;
7982
7983     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
7984
7985     return(curr_offset - offset);
7986 }
7987
7988 /*
7989  * [5] 8.2.5.4
7990  */
7991 static guint8
7992 de_rp_cause(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len)
7993 {
7994     guint8      oct;
7995     guint32     curr_offset;
7996     const gchar *str;
7997
7998     curr_offset = offset;
7999
8000     oct = tvb_get_guint8(tvb, curr_offset);
8001
8002     other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
8003     proto_tree_add_text(tree,
8004         tvb, curr_offset, 1,
8005         "%s :  Extension: %s",
8006         a_bigbuf,
8007         (oct & 0x80) ? "extended" : "not extended");
8008
8009     switch (oct & 0x7f)
8010     {
8011     case 1: str = "Unassigned (unallocated) number"; break;
8012     case 8: str = "Operator determined barring"; break;
8013     case 10: str = "Call barred"; break;
8014     case 11: str = "Reserved"; break;
8015     case 21: str = "Short message transfer rejected"; break;
8016     case 22: str = "Memory capacity exceeded"; break;
8017     case 27: str = "Destination out of order"; break;
8018     case 28: str = "Unidentified subscriber"; break;
8019     case 29: str = "Facility rejected"; break;
8020     case 30: str = "Unknown subscriber"; break;
8021     case 38: str = "Network out of order"; break;
8022     case 41: str = "Temporary failure"; break;
8023     case 42: str = "Congestion"; break;
8024     case 47: str = "Resources unavailable, unspecified"; break;
8025     case 50: str = "Requested facility not subscribed"; break;
8026     case 69: str = "Requested facility not implemented"; break;
8027     case 81: str = "Invalid short message transfer reference value"; break;
8028     case 95: str = "Semantically incorrect message"; break;
8029     case 96: str = "Invalid mandatory information"; break;
8030     case 97: str = "Message type non-existent or not implemented"; break;
8031     case 98: str = "Message not compatible with short message protocol state"; break;
8032     case 99: str = "Information element non-existent or not implemented"; break;
8033     case 111: str = "Protocol error, unspecified"; break;
8034     case 127: str = "Interworking, unspecified"; break;
8035     default:
8036         str = "Reserved";
8037         break;
8038     }
8039
8040     other_decode_bitfield_value(a_bigbuf, oct, 0x7f, 8);
8041     proto_tree_add_text(tree,
8042         tvb, curr_offset, 1,
8043         "%s :  Cause: (%u) %s",
8044         a_bigbuf,
8045         oct & 0x7f,
8046         str);
8047
8048     curr_offset++;
8049
8050     if (add_string)
8051         g_snprintf(add_string, string_len, " - (%u) %s", oct & 0x7f, str);
8052
8053     NO_MORE_DATA_CHECK(len);
8054
8055     proto_tree_add_text(tree,
8056         tvb, curr_offset, len - (curr_offset - offset),
8057         "Diagnostic field");
8058
8059     curr_offset += len - (curr_offset - offset);
8060
8061     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
8062
8063     return(curr_offset - offset);
8064 }
8065
8066 /*
8067  * [7] 10.5.5.1
8068  */
8069 static guint8
8070 de_gmm_attach_res(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
8071 {
8072     guint8      oct;
8073     guint32     curr_offset;
8074     const gchar *str;
8075     
8076     len = len;
8077     curr_offset = offset;
8078
8079     oct = tvb_get_guint8(tvb, curr_offset);
8080
8081     switch(oct&7)
8082     {
8083         case 1: str="GPRS only attached"; break;
8084         case 3: str="Combined GPRS/IMSI attached";      break;
8085         default: str="reserved";
8086     }
8087
8088     proto_tree_add_text(tree,
8089         tvb, curr_offset, 1,
8090         "Attach Result: (%u) %s",
8091         oct&7,
8092         str);
8093
8094     curr_offset++;
8095
8096     /* no length check possible */
8097
8098     return(curr_offset - offset);
8099 }
8100
8101 /*
8102  * [7] 10.5.5.2
8103  */
8104 static guint8
8105 de_gmm_attach_type(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
8106 {
8107     guint8      oct;
8108     guint8      oct_ciph;
8109     guint32     curr_offset;
8110     const gchar *str_follow;
8111     const gchar *str_attach;
8112     proto_item  *tf = NULL;
8113     proto_tree      *tf_tree = NULL;
8114     
8115     len = len;
8116     curr_offset = offset;
8117
8118     oct = tvb_get_guint8(tvb, curr_offset);
8119     oct_ciph = oct>>4;
8120
8121     oct &= 0x0f;
8122
8123     switch(oct&7)
8124     {
8125         case 1: str_attach="GPRS attach"; break;
8126         case 2: str_attach="GPRS attach while IMSI attached"; break;
8127         case 3: str_attach="Combined GPRS/IMSI attach"; break;
8128         default: str_attach="reserved";
8129     }
8130     switch(oct&8)
8131     {
8132         case 8: str_follow="Follow-on request pending"; break;
8133         default: str_follow="No follow-on request pending";
8134     }
8135
8136     tf = proto_tree_add_text(tree,
8137         tvb, curr_offset, 1,
8138         "Attach Type");
8139
8140     tf_tree = proto_item_add_subtree(tf, ett_gmm_attach_type );
8141
8142     proto_tree_add_text(tf_tree,
8143         tvb, curr_offset, 1,
8144         "Type: (%u) %s",
8145         oct&7,
8146         str_attach);
8147     proto_tree_add_text(tf_tree,
8148         tvb, curr_offset, 1,
8149         "Follow: (%u) %s",
8150         (oct>>3)&1,
8151         str_follow);
8152
8153     /* The ciphering key sequence number is added here */
8154     proto_tree_add_text(tree,
8155         tvb, curr_offset, 1,
8156         "Ciphering key sequence number: 0x%02x (%u)",
8157         oct_ciph,
8158         oct_ciph);
8159
8160     curr_offset++;
8161
8162     /* no length check possible */
8163
8164     return(curr_offset - offset);
8165 }
8166
8167 /*
8168  * [7] 10.5.5.3
8169  */
8170 static guint8
8171 de_gmm_ciph_alg(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
8172 {
8173     guint8      oct;
8174     guint32     curr_offset;
8175     const gchar *str;
8176     
8177     len = len;
8178     curr_offset = offset;
8179
8180     oct = tvb_get_guint8(tvb, curr_offset);
8181
8182     switch(oct&7)
8183     {
8184         case 0: str="ciphering not used"; break;
8185         case 1: str="GPRS Encryption Algorithm GEA/1"; break;
8186         case 2: str="GPRS Encryption Algorithm GEA/2"; break;
8187         case 3: str="GPRS Encryption Algorithm GEA/3"; break;
8188         case 4: str="GPRS Encryption Algorithm GEA/4"; break;
8189         case 5: str="GPRS Encryption Algorithm GEA/5"; break;
8190         case 6: str="GPRS Encryption Algorithm GEA/6"; break;
8191         case 7: str="GPRS Encryption Algorithm GEA/7"; break;
8192         default: str="This should never happen";
8193     }
8194
8195     proto_tree_add_text(tree,
8196         tvb, curr_offset, 1,
8197         "Ciphering Algorithm: (%u) %s",
8198         oct&7,
8199         str);
8200
8201     curr_offset++;
8202
8203     /* no length check possible */
8204
8205     return(curr_offset - offset);
8206 }
8207
8208 /*
8209  * [7] 10.5.5.4
8210  */
8211 static guint8
8212 de_gmm_tmsi_stat(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
8213 {
8214     guint8      oct;
8215     guint32     curr_offset;
8216     const gchar *str;
8217     
8218     len = len;
8219     curr_offset = offset;
8220
8221     oct = tvb_get_guint8(tvb, curr_offset);
8222
8223     switch(oct&1)
8224     {
8225         case 0: str="no valid TMSI available"; break;
8226         case 1: str="valid TMSI available"; break;
8227         default: str="This should never happen";
8228     }
8229
8230     proto_tree_add_text(tree,
8231         tvb, curr_offset, 1,
8232         "TMSI Status: (%u) %s",
8233         oct&1,
8234         str);
8235
8236     /* curr_offset++;  - It is encoded in the octed before */
8237
8238     /* no length check possible */
8239
8240     return(curr_offset - offset);
8241 }
8242
8243 /*
8244  * [7] 10.5.5.5
8245  */
8246 static guint8
8247 de_gmm_detach_type(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
8248 {
8249     guint8      oct;
8250     guint32     curr_offset;
8251     const gchar *str;
8252     const gchar *str_power;
8253     proto_item  *tf = NULL;
8254     proto_tree      *tf_tree = NULL;
8255     
8256     len = len;
8257     curr_offset = offset;
8258
8259     oct = tvb_get_guint8(tvb, curr_offset);
8260
8261     switch(oct&7)
8262     {
8263         case 1: str="GPRS detach/re-attach required"; break;
8264         case 2: str="IMSI detach/re-attach not required"; break;
8265         case 3: str="Combined GPRS/IMSI detach/IMSI detach (after VLR failure)"; break;
8266         default: str="Combined GPRS/IMSI detach/re-attach not required";
8267     }
8268
8269     switch(oct&8)
8270     {
8271         case 8: str_power="power switched off"; break;
8272         default: str_power="normal detach"; break;
8273     }
8274
8275     tf = proto_tree_add_text(tree,
8276         tvb, curr_offset, 1,
8277         "Detach Type");
8278
8279     tf_tree = proto_item_add_subtree(tf, ett_gmm_detach_type );
8280
8281     proto_tree_add_text(tf_tree,
8282         tvb, curr_offset, 1,
8283         "Type: (%u) %s",
8284         oct&7,
8285         str);
8286
8287     proto_tree_add_text(tf_tree,
8288         tvb, curr_offset, 1,
8289         "Power: (%u) %s",
8290         (oct>>3)&1,
8291         str_power);
8292
8293     curr_offset++;
8294
8295     /* no length check possible */
8296
8297     return(curr_offset - offset);
8298 }
8299
8300 /*
8301  * [7] 10.5.5.6
8302  * 
8303  * SPLIT on CCCH, octet 3 (bit 4)
8304  * 0 Split pg cycle on CCCH is not supported by the mobile station
8305  * 1 Split pg cycle on CCCH is supported by the mobile station
8306  */
8307 static const true_false_string gsm_a_gmm_split_on_ccch_value  = {
8308   "Split pg cycle on CCCH is supported by the mobile station",
8309   "Split pg cycle on CCCH is not supported by the mobile station"
8310 };
8311
8312 /* non-DRX timer, octet 3
8313  * bit
8314  * 3 2 1
8315  */
8316 static const value_string gsm_a_gmm_non_drx_timer_strings[] = {
8317     { 0x00,     "no non-DRX mode after transfer state" },
8318     { 0x01,     "max. 1 sec non-DRX mode after transfer state" },
8319     { 0x02,     "max. 2 sec non-DRX mode after transfer state" },
8320     { 0x03,     "max. 4 sec non-DRX mode after transfer state" },
8321     { 0x04,     "max. 8 sec non-DRX mode after transfer state" },
8322     { 0x05,     "max. 16 sec non-DRX mode after transfer state" },
8323     { 0x06,     "max. 32 sec non-DRX mode after transfer state" },
8324     { 0x07,     "max. 64 sec non-DRX mode after transfer state" },
8325     { 0, NULL },
8326 };
8327 /*
8328  * CN Specific DRX cycle length coefficient, octet 3
8329  * bit
8330  * 8 7 6 5 Iu mode specific
8331  * 0 0 0 0 CN Specific DRX cycle length coefficient not specified by the MS, ie. the
8332  * system information value 'CN domain specific DRX cycle length' is used.
8333  * (Ref 3GPP TS 25.331)
8334  * 0 1 1 0 CN Specific DRX cycle length coefficient 6
8335  * 0 1 1 1 CN Specific DRX cycle length coefficient 7
8336  * 1 0 0 0 CN Specific DRX cycle length coefficient 8
8337  * 1 0 0 1 CN Specific DRX cycle length coefficient 9
8338  * All other values shall be interpreted as "CN Specific DRX cycle length coefficient not
8339  * specified by the MS " by this version of the protocol.
8340  * NOTE: In Iu mode this field (octet 3 bits 8 to 5) is used, but was spare in earlier
8341  * versions of this protocol.
8342  */
8343 static const value_string gsm_a_gmm_cn_spec_drs_cycle_len_coef_strings[] = {
8344     { 0x00,     "CN Specific DRX cycle length coefficient not specified by the MS" },
8345     { 0x01,     "CN Specific DRX cycle length coefficient not specified by the MS" },
8346     { 0x02,     "CN Specific DRX cycle length coefficient not specified by the MS" },
8347     { 0x03,     "CN Specific DRX cycle length coefficient not specified by the MS" },
8348     { 0x04,     "CN Specific DRX cycle length coefficient not specified by the MS" },
8349     { 0x05,     "CN Specific DRX cycle length coefficient not specified by the MS" },
8350     { 0x06,     "CN Specific DRX cycle length coefficient 6" },
8351     { 0x07,     "CN Specific DRX cycle length coefficient 7" },
8352     { 0x08,     "CN Specific DRX cycle length coefficient 8" },
8353     { 0x09,     "CN Specific DRX cycle length coefficient 9" },
8354     { 0x0a,     "CN Specific DRX cycle length coefficient not specified by the MS" },
8355     { 0x0b,     "CN Specific DRX cycle length coefficient not specified by the MS" },
8356     { 0x0c,     "CN Specific DRX cycle length coefficient not specified by the MS" },
8357     { 0x0d,     "CN Specific DRX cycle length coefficient not specified by the MS" },
8358     { 0x0e,     "CN Specific DRX cycle length coefficient not specified by the MS" },
8359     { 0x0f,     "CN Specific DRX cycle length coefficient not specified by the MS" },
8360     { 0, NULL },
8361 };
8362 guint8
8363 de_gmm_drx_param(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
8364 {
8365     guint8      oct;
8366     guint32     curr_offset;
8367     const gchar *str;
8368     gchar       str_val[3];
8369     proto_item  *tf = NULL;
8370     proto_tree  *tf_tree = NULL;
8371     
8372     len = len;
8373     curr_offset = offset;
8374
8375     tf = proto_tree_add_text(tree,
8376         tvb, curr_offset, 2,
8377         "DRX Parameter");
8378
8379     tf_tree = proto_item_add_subtree(tf, ett_gmm_drx );
8380
8381     oct = tvb_get_guint8(tvb, curr_offset);
8382
8383     switch(oct)
8384     {
8385         case 0: str="704"; break;
8386         case 65: str="71"; break;
8387         case 66: str="72"; break;
8388         case 67: str="74"; break;
8389         case 68: str="75"; break;
8390         case 69: str="77"; break;
8391         case 70: str="79"; break;
8392         case 71: str="80"; break;
8393         case 72: str="83"; break;
8394         case 73: str="86"; break;
8395         case 74: str="88"; break;
8396         case 75: str="90"; break;
8397         case 76: str="92"; break;
8398         case 77: str="96"; break;
8399         case 78: str="101"; break;
8400         case 79: str="103"; break;
8401         case 80: str="107"; break;
8402         case 81: str="112"; break;
8403         case 82: str="116"; break;
8404         case 83: str="118"; break;
8405         case 84: str="128"; break;
8406         case 85: str="141"; break;
8407         case 86: str="144"; break;
8408         case 87: str="150"; break;
8409         case 88: str="160"; break;
8410         case 89: str="171"; break;
8411         case 90: str="176"; break;
8412         case 91: str="192"; break;
8413         case 92: str="214"; break;
8414         case 93: str="224"; break;
8415         case 94: str="235"; break;
8416         case 95: str="256"; break;
8417         case 96: str="288"; break;
8418         case 97: str="320"; break;
8419         case 98: str="352"; break;
8420         default:
8421                 str_val[0]=oct/10+'0';
8422                 str_val[1]=oct%10+'0';
8423                 str_val[2]=0;
8424                 str=str_val;
8425     }
8426
8427     proto_tree_add_text(tf_tree,
8428         tvb, curr_offset, 1,
8429         "Split PG Cycle Code: (%u) %s",
8430         oct,
8431         str);
8432
8433     curr_offset++;
8434         proto_tree_add_item(tf_tree, hf_gsm_a_gmm_cn_spec_drs_cycle_len_coef, tvb, curr_offset, 1, FALSE);
8435         proto_tree_add_item(tf_tree, hf_gsm_a_gmm_split_on_ccch, tvb, curr_offset, 1, FALSE);
8436         proto_tree_add_item(tf_tree, hf_gsm_a_gmm_non_drx_timer, tvb, curr_offset, 1, FALSE);
8437
8438     curr_offset++;
8439
8440     /* no length check possible */
8441
8442     return(curr_offset - offset);
8443 }
8444
8445 /*
8446  * [7] 10.5.5.7
8447  */
8448 static guint8
8449 de_gmm_ftostby(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
8450 {
8451     guint8      oct;
8452     guint32     curr_offset;
8453     const gchar *str;
8454     
8455     len = len;
8456     curr_offset = offset;
8457
8458     oct = tvb_get_guint8(tvb, curr_offset);
8459
8460     switch(oct&7)
8461     {
8462         case 1: str="Force to standby indicated"; break;
8463         default: str="force to standby not indicated";
8464     }
8465
8466     proto_tree_add_text(tree,
8467         tvb, curr_offset, 1,
8468         "Force to Standby: (%u) %s",
8469         oct&7,
8470         str);
8471
8472     curr_offset++;
8473
8474     /* no length check possible */
8475
8476     return(curr_offset - offset);
8477 }
8478
8479 /*
8480  * [7] 10.5.5.7
8481  */
8482 static guint8
8483 de_gmm_ftostby_h(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
8484 {
8485     guint8      oct;
8486     guint32     curr_offset;
8487     const gchar *str;
8488     
8489     len = len;
8490     curr_offset = offset;
8491
8492     oct = tvb_get_guint8(tvb, curr_offset);
8493
8494     /* IMPORTANT - IT'S ASSUMED THAT THE INFORMATION IS IN THE HIGHER NIBBLE */
8495     oct >>= 4;
8496
8497     switch(oct&7)
8498     {
8499         case 1: str="Force to standby indicated"; break;
8500         default: str="force to standby not indicated";
8501     }
8502
8503     proto_tree_add_text(tree,
8504         tvb, curr_offset, 1,
8505         "Force to Standby: (%u) %s",
8506         oct&7,
8507         str);
8508
8509     curr_offset++;
8510
8511     /* no length check possible */
8512
8513     return(curr_offset - offset);
8514 }
8515
8516 /*
8517  * [7] 10.5.5.8
8518  */
8519 static guint8
8520 de_gmm_ptmsi_sig(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
8521 {
8522     guint32     curr_offset;
8523     proto_item  *curr_item;
8524     curr_offset = offset;
8525     curr_item= proto_tree_add_item(tree,hf_gsm_a_ptmsi_sig,tvb,curr_offset,3,FALSE);
8526     proto_item_append_text(curr_item,"%s",add_string ? add_string : "");
8527
8528     curr_offset+=3;
8529
8530     /* no length check possible */
8531
8532     return(curr_offset - offset);
8533 }
8534
8535 /*
8536  * [7] 10.5.5.8a
8537  */
8538 static guint8
8539 de_gmm_ptmsi_sig2(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len _U_)
8540 {
8541     guint32     curr_offset;
8542     proto_item  *curr_item;
8543     curr_offset = offset;
8544
8545     curr_item= proto_tree_add_item(tree,hf_gsm_a_ptmsi_sig2,tvb,curr_offset,3,FALSE);
8546     proto_item_append_text(curr_item,"%s",add_string ? add_string : "");
8547     curr_offset+=3;
8548
8549     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
8550
8551     return(curr_offset - offset);
8552 }
8553
8554 /*
8555  * [7] 10.5.5.9
8556  */
8557 static guint8
8558 de_gmm_ident_type2(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
8559 {
8560     guint8      oct;
8561     guint32     curr_offset;
8562     const gchar *str;
8563     
8564     len = len;
8565     curr_offset = offset;
8566
8567     oct = tvb_get_guint8(tvb, curr_offset);
8568
8569     switch ( oct&7 )
8570     {
8571         case 2: str="IMEI"; break;
8572         case 3: str="IMEISV"; break;
8573         case 4: str="TMSI"; break;
8574         default: str="IMSI";
8575     }
8576     
8577     proto_tree_add_text(tree,
8578         tvb, curr_offset, 1,
8579         "Identity Type 2: (%u) %s",
8580         oct&7,
8581         str);
8582
8583     curr_offset++;
8584
8585     /* no length check possible */
8586
8587     return(curr_offset - offset);
8588 }
8589
8590 /*
8591  * [7] 10.5.5.10
8592  */
8593 static guint8
8594 de_gmm_imeisv_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
8595 {
8596     guint8      oct;
8597     guint32     curr_offset;
8598     const gchar *str;
8599     
8600     len = len;
8601     curr_offset = offset;
8602
8603     oct = tvb_get_guint8(tvb, curr_offset);
8604
8605     /* IMPORTANT - IT'S ASSUMED THAT THE INFORMATION IS IN THE HIGHER NIBBLE */
8606     oct >>= 4;
8607
8608     switch ( oct&7 )
8609     {
8610         case 1: str="IMEISV requested"; break;
8611         default: str="IMEISV not requested";
8612     }
8613     
8614     proto_tree_add_text(tree,
8615         tvb, curr_offset, 1,
8616         "IMEISV Request: (%u) %s",
8617         oct&7,
8618         str);
8619
8620     curr_offset++;
8621
8622     /* no length check possible */
8623
8624     return(curr_offset - offset);
8625 }
8626
8627 /*
8628  * [7] 10.5.5.11
8629  */
8630 static guint8
8631 de_gmm_rec_npdu_lst(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
8632 {
8633     guint32     curr_offset;
8634     guint       curr_len;
8635     
8636     curr_len = len;
8637     curr_offset = offset;
8638
8639     if ( len == 0 ) return 0;
8640
8641     do
8642     {
8643             guint32     oct;
8644             oct = tvb_get_guint8(tvb, curr_offset);
8645             oct <<=8;
8646             oct |= tvb_get_guint8(tvb, curr_offset+1);
8647             curr_len -= 2;
8648             oct <<=8;
8649
8650             proto_tree_add_text(tree,
8651                 tvb, curr_offset, 2,
8652                 "NSAPI %d: 0x%02x (%u)",
8653                 oct>>20,
8654                 (oct>>12)&0xff,
8655                 (oct>>12)&0xff);
8656             curr_offset+= 2;
8657
8658             if ( curr_len > 2 )
8659             {
8660                     oct |= tvb_get_guint8(tvb, curr_offset+2);
8661                     curr_len--;
8662                     oct <<= 12;
8663
8664                     proto_tree_add_text(tree,
8665                         tvb, curr_offset-1, 2,
8666                         "NSAPI %d: 0x%02x (%u)",
8667                         oct>>20,
8668                         (oct>>12)&0xff,
8669                         (oct>>12)&0xff);
8670                     curr_offset++;
8671             }
8672
8673
8674     } while ( curr_len > 1 );
8675
8676     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
8677
8678     return(curr_offset - offset);
8679 }
8680
8681 /*
8682  * [7] 10.5.5.12
8683  */
8684 guint8
8685 de_gmm_ms_net_cap(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
8686 {
8687     guint8      oct;
8688     guint32     curr_offset;
8689     guint       curr_len;
8690     guint       gea_val;
8691     
8692     gchar answer_gea[2][40]={ "encryption algorithm not available",
8693                         "encryption algorithm available" };
8694     gchar answer_smdch[2][120]={ "Mobile station does not support mobile terminated point to point SMS via dedicated signalling channels",
8695                         "Mobile station supports mobile terminated point to point SMS via dedicated signalling channels" };
8696     gchar answer_smgprs[2][100]={ "Mobile station does not support mobile terminated point to point SMS via GPRS packet data channels",
8697                         "Mobile station supports mobile terminated point to point SMS via GPRS packet data channels" };
8698     gchar answer_ucs2[2][100]={ "the ME has a preference for the default alphabet (defined in 3GPP TS 23.038 [8b]) over UCS2",
8699                         "the ME has no preference between the use of the default alphabet and the use of UCS2" };
8700     
8701     gchar answer_ssid[4][80]={ "default value of phase 1",
8702                         "capability of handling of ellipsis notation and phase 2 error handling",
8703                         "capability of handling of ellipsis notation and phase 2 error handling",
8704                         "capability of handling of ellipsis notation and phase 2 error handling" };
8705
8706     gchar answer_solsa[2][40]={ "The ME does not support SoLSA",
8707                         "The ME supports SoLSA" };
8708                         
8709     gchar answer_rev[2][80]={ "used by a mobile station not supporting R99 or later versions of the protocol",
8710                         "used by a mobile station supporting R99 or later versions of the protocol" };
8711
8712     gchar answer_pfc[2][80]={ "Mobile station does not support BSS packet flow procedures",
8713                         "Mobile station does support BSS packet flow procedures" };
8714
8715     gchar answer_lcs[2][80]={ "LCS value added location request notification capability not supported" ,
8716                         "LCS value added location request notification capability supported" };
8717     
8718     curr_len = len;
8719     curr_offset = offset;
8720
8721     if ( curr_len == 0 ){ EXTRANEOUS_DATA_CHECK(len, curr_offset - offset); return(curr_offset - offset); }
8722     oct = tvb_get_guint8(tvb, curr_offset);
8723     curr_len--;
8724
8725         /* bit 8 */
8726     proto_tree_add_text(tree,
8727         tvb, curr_offset, 1,
8728         "GEA1: (%u) %s",
8729         oct>>7,
8730         answer_gea[oct>>7]);
8731     oct<<=1;
8732
8733         /* bit 7 */
8734     proto_tree_add_text(tree,
8735         tvb, curr_offset, 1,
8736         "SM capabilities via dedicated channels: (%u) %s",
8737         oct>>7,
8738         answer_smdch[oct>>7]);
8739     oct<<=1;
8740
8741         /* bit 6 */
8742     proto_tree_add_text(tree,
8743         tvb, curr_offset, 1,
8744         "SM capabilities via GPRS channels: (%u) %s",
8745         oct>>7,
8746         answer_smgprs[oct>>7]);
8747     oct<<=1;
8748
8749         /* bit 5 */
8750     proto_tree_add_text(tree,
8751         tvb, curr_offset, 1,
8752         "UCS2 support: (%u) %s",
8753         oct>>7,
8754         answer_ucs2[oct>>7]);
8755     oct<<=1;
8756         
8757         /* bit 4 3 */
8758     proto_tree_add_text(tree,
8759         tvb, curr_offset, 1,
8760         "SS Screening Indicator: (%u) %s",
8761         oct>>6,
8762         answer_ssid[oct>>6]);
8763     oct<<=2;
8764
8765         /* bit 2 */
8766     proto_tree_add_text(tree,
8767         tvb, curr_offset, 1,
8768         "SoLSA Capability: (%u) %s",
8769         oct>>7,
8770         answer_solsa[oct>>7]);
8771     oct<<=1;
8772
8773         /* bit 1 */
8774     proto_tree_add_text(tree,
8775         tvb, curr_offset, 1,
8776         "Revision level indicator: (%u) %s",
8777         oct>>7,
8778         answer_rev[oct>>7]);
8779
8780     curr_offset++;
8781
8782     if ( curr_len == 0 ){ EXTRANEOUS_DATA_CHECK(len, curr_offset - offset); return(curr_offset - offset); }
8783     oct = tvb_get_guint8(tvb, curr_offset);
8784     curr_len--;
8785
8786     proto_tree_add_text(tree,
8787         tvb, curr_offset, 1,
8788         "PFC feature mode: (%u) %s",
8789         oct>>7,
8790         answer_pfc[oct>>7]);
8791     oct<<=1;
8792
8793     for( gea_val=2; gea_val<8 ; gea_val++ )
8794     {
8795             proto_tree_add_text(tree,
8796                 tvb, curr_offset, 1,
8797                 "GEA%d: (%u) %s", gea_val,
8798                 oct>>7,
8799                 answer_gea[oct>>7]);
8800             oct<<=1;
8801     }
8802     
8803     proto_tree_add_text(tree,
8804         tvb, curr_offset, 1,
8805         "LCS VA capability:: (%u) %s",
8806         oct>>7,
8807         answer_lcs[oct>>7]);
8808     
8809     curr_offset++;         
8810                    
8811     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
8812
8813     return(curr_offset - offset);
8814 }
8815
8816 /*
8817  * [7] 10.5.5.12a
8818  */
8819 #define GET_DATA                                /* check if we have enough bits left */ \
8820                 if ( curr_bits_length < bits_needed ) \
8821                         continue; \
8822                 /* check if oct has enougth bits */ \
8823                 if ( bits_in_oct < bits_needed ) \
8824                 { \
8825                         guint32 tmp_oct; \
8826                         if ( curr_len == 0 ) \
8827                         { \
8828                                 proto_tree_add_text(tf_tree, \
8829                                 tvb, curr_offset, 1, \
8830                                 "Not enough data available"); \
8831                         } \
8832                         tmp_oct = tvb_get_guint8(tvb, curr_offset); \
8833                         oct |= tmp_oct<<(32-8-bits_in_oct); \
8834                         curr_len--; \
8835                         curr_offset++; \
8836                         if ( bits_in_oct != 0 ) \
8837                                 add_ocetets = 1; \
8838                         else \
8839                                 add_ocetets = 0; \
8840                         bits_in_oct += 8; \
8841                 } \
8842                 else \
8843                         add_ocetets = 0;
8844
8845
8846 guint8
8847 de_gmm_ms_radio_acc_cap(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
8848 {
8849     guint32     curr_offset;
8850     guint       curr_len;
8851     proto_item  *tf = NULL;
8852     proto_tree      *tf_tree = NULL;
8853     guint32     oct;
8854     guchar      bits_in_oct;
8855     guchar      bits_needed;
8856     guint       bits_length;
8857     guint       add_ocetets;    /* octets which are covered by one element -1 */
8858     guint       curr_bits_length;
8859     guchar      acc_type;
8860     const gchar *str;
8861     gchar       multi_slot_str[64][230] = {
8862         "Not specified", /* 00 */
8863         "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 */
8864         "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 */
8865         "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 */
8866         "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 */
8867         "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 */
8868         "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 */
8869         "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 */
8870         "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 */
8871         "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 */
8872         "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 */
8873         "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 */
8874         "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 */
8875         "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 */
8876         "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 */
8877         "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 */
8878         "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 */
8879         "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 */
8880         "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 */
8881         "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 */     
8882         "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 */
8883         "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 */
8884         "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 */
8885         "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 */
8886         "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 */
8887         "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 */
8888         "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 */
8889         "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 */
8890         "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 */
8891         "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 */
8892         "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 */
8893         "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 */
8894         "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 */
8895         "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 */
8896         "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 */
8897         "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 */
8898         "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 */
8899         "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 */
8900         "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 */
8901         "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 */
8902         "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 */
8903         "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 */
8904         "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 */
8905         "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 */
8906         "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 */
8907         "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 */
8908         "Not specified", /* 46 */
8909         "Not specified", /* 47 */
8910         "Not specified", /* 48 */
8911         "Not specified", /* 49 */
8912         "Not specified", /* 50 */
8913         "Not specified", /* 51 */
8914         "Not specified", /* 52 */
8915         "Not specified", /* 53 */
8916         "Not specified", /* 54 */
8917         "Not specified", /* 55 */
8918         "Not specified", /* 56 */
8919         "Not specified", /* 57 */
8920         "Not specified", /* 58 */
8921         "Not specified", /* 59 */
8922         "Not specified", /* 60 */
8923         "Not specified", /* 61 */
8924         "Not specified", /* 62 */
8925         "Not specified", /* 63 */
8926         };
8927     guint index = 0;
8928     guchar dtm_gprs_mslot = 0;
8929     guchar dtm_egprs_mslot = 4;
8930     gboolean finished = TRUE;
8931     
8932     curr_len = len;
8933     curr_offset = offset;
8934
8935     bits_in_oct = 0;
8936     oct = 0;
8937
8938     do
8939     {
8940         /* check for a new round */
8941         if (( curr_len*8 + bits_in_oct ) < 11 )
8942                 break;
8943
8944         /* now read the first 11 bits */
8945         curr_bits_length = 11;  
8946         /*
8947          *
8948          */
8949         if ( curr_len != len )
8950         {
8951                 bits_needed = 1;
8952                 GET_DATA;
8953
8954                 if (( oct>>(32-bits_needed) ) == 1 )
8955                 {
8956                         curr_bits_length -= bits_needed;
8957                         oct <<= bits_needed;
8958                         bits_in_oct -= bits_needed;
8959                         
8960                         if (( curr_len*8 + bits_in_oct ) < 11 )
8961                                 break;
8962                         curr_bits_length = 11;
8963                 }
8964                 else
8965                 {
8966                         curr_bits_length -= bits_needed;
8967                         oct <<= bits_needed;
8968                         bits_in_oct -= bits_needed;
8969                         break;
8970                 }
8971         }
8972
8973         index++;
8974         tf = proto_tree_add_text(tree,
8975                 tvb, curr_offset, 1,
8976                 "MS RA capability %d",index);
8977
8978         tf_tree = proto_item_add_subtree(tf, ett_gmm_radio_cap );
8979
8980         /*
8981          * Access Technology
8982          */
8983         bits_needed = 4;
8984         GET_DATA;
8985         
8986         acc_type = oct>>(32-bits_needed);
8987         switch ( acc_type )
8988         {
8989                 case 0x00: str="GSM P"; break;
8990                 case 0x01: str="GSM E --note that GSM E covers GSM P"; break;
8991                 case 0x02: str="GSM R --note that GSM R covers GSM E and GSM P"; break;
8992                 case 0x03: str="GSM 1800"; break;
8993                 case 0x04: str="GSM 1900"; break;
8994                 case 0x05: str="GSM 450"; break;
8995                 case 0x06: str="GSM 480"; break;
8996                 case 0x07: str="GSM 850"; break;
8997                 case 0x08: str="GSM 700"; break;
8998                 case 0x0f: str="Indicates the presence of a list of Additional access technologies"; break;
8999                 default: str="unknown";
9000          }
9001
9002         proto_tree_add_text(tf_tree,
9003                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9004                 "Access Technology Type: (%u) %s",acc_type,str);
9005         curr_bits_length -= bits_needed;
9006         oct <<= bits_needed;
9007         bits_in_oct -= bits_needed;
9008         
9009         /*
9010          * get bits_length
9011          */
9012         bits_needed = 7;
9013         GET_DATA;
9014         
9015         bits_length = curr_bits_length = oct>>(32-bits_needed);
9016         proto_tree_add_text(tf_tree,
9017                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9018                 "Length: 0x%02x bits (%u)",bits_length,bits_length);
9019         /* This is already done - length doesn't contain this field
9020          curr_bits_length -= bits_needed;
9021         */
9022         oct <<= bits_needed;
9023         bits_in_oct -= bits_needed;
9024
9025         if ( acc_type == 0x0f )
9026         {
9027                 do 
9028                 {
9029                 /*
9030                  * Additional access technologies:
9031                  */
9032                         finished = TRUE; /* Break out of the loop unless proven unfinished */
9033
9034                         /*
9035                          * Presence bit
9036                          */
9037                         bits_needed = 1;
9038                         GET_DATA;
9039
9040                         /* analyse bits */
9041                         switch ( oct>>(32-bits_needed) )
9042                         {
9043                                 case 0x00: str="Not Present"; finished = TRUE; break;
9044                                 case 0x01: str="Present"; finished = FALSE; break;
9045                                 default: str="This should not happen";
9046                         }
9047
9048                         proto_tree_add_text(tf_tree,
9049                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9050                                 "Presence: (%u) %s",oct>>(32-bits_needed),str);
9051                         curr_bits_length -= bits_needed;
9052                         oct <<= bits_needed;
9053                         bits_in_oct -= bits_needed;
9054
9055                         if (finished)
9056                         {
9057                                 /*
9058                                  * No more valid data, get spare bits if any
9059                                  */
9060                                 while ( curr_bits_length > 0 )
9061                                 {
9062                                         if ( curr_bits_length > 8 )
9063                                                 bits_needed = 8;
9064                                         else
9065                                                 bits_needed = curr_bits_length;
9066                                         GET_DATA;
9067                                         curr_bits_length -= bits_needed;
9068                                         oct <<= bits_needed;
9069                                         bits_in_oct -= bits_needed;
9070                                 }
9071                                 continue;
9072                         }
9073
9074                 /*
9075                  * Access Technology
9076                  */
9077                 bits_needed = 4;
9078                 GET_DATA;
9079         
9080                 acc_type = oct>>(32-bits_needed);
9081                 switch ( acc_type )
9082                 {
9083                         case 0x00: str="GSM P"; break;
9084                         case 0x01: str="GSM E --note that GSM E covers GSM P"; break;
9085                         case 0x02: str="GSM R --note that GSM R covers GSM E and GSM P"; break;
9086                         case 0x03: str="GSM 1800"; break;
9087                         case 0x04: str="GSM 1900"; break;
9088                         case 0x05: str="GSM 450"; break;
9089                         case 0x06: str="GSM 480"; break;
9090                         case 0x07: str="GSM 850"; break;
9091                         case 0x08: str="GSM 700"; break;
9092                         case 0x0f: str="Indicates the presence of a list of Additional access technologies"; break;
9093                         default: str="unknown";
9094                  }
9095
9096                 proto_tree_add_text(tf_tree,
9097                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9098                         "Access Technology Type: (%u) %s",acc_type,str);
9099                 curr_bits_length -= bits_needed;
9100                 oct <<= bits_needed;
9101                 bits_in_oct -= bits_needed;
9102
9103                 /*
9104                  * RF Power
9105                  */
9106                 bits_needed = 3;
9107                 GET_DATA;
9108
9109                 /* analyse bits */
9110                 if ( acc_type == 0x04 ) /* GSM 1900 */
9111                 {
9112                         switch ( oct>>(32-bits_needed) )
9113                         {
9114                                 case 0x01: str="1 W (30 dBm)"; break;
9115                                 case 0x02: str="0,25 W (24 dBm)"; break;
9116                                 case 0x03: str="2 W (33 dBm)"; break;
9117                                 default: str="Not specified";
9118                         }
9119                 }
9120                 else if ( acc_type == 0x03 )
9121                 {
9122                         switch ( oct>>(32-bits_needed) )
9123                         {
9124                                 case 0x01: str="1 W (30 dBm)"; break;
9125                                 case 0x02: str="0,25 W (24 dBm)"; break;
9126                                 case 0x03: str="4 W (36 dBm)"; break;
9127                                 default: str="Not specified";
9128                         }
9129                 }
9130                 else if ( acc_type <= 0x08 )
9131                 {
9132                         switch ( oct>>(32-bits_needed) )
9133                         {
9134                                 case 0x02: str="8 W (39 dBm)"; break;
9135                                 case 0x03: str="5 W (37 dBm)"; break;
9136                                 case 0x04: str="2 W (33 dBm)"; break;
9137                                 case 0x05: str="0,8 W (29 dBm)"; break;
9138                                 default: str="Not specified";
9139                         }
9140                 }
9141                 else
9142                         str="Not specified??";
9143     
9144                 proto_tree_add_text(tf_tree,
9145                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9146                         "RF Power Capability, GMSK Power Class: (%u) %s",oct>>(32-bits_needed),str);
9147                 curr_bits_length -= bits_needed;
9148                 oct <<= bits_needed;
9149                 bits_in_oct -= bits_needed;
9150
9151                 /*
9152                  * 8PSK Power Class
9153                  */
9154                 bits_needed = 2;
9155                 GET_DATA;
9156
9157                 /* analyse bits */
9158                 switch ( oct>>(32-bits_needed) )
9159                 {
9160                         case 0x00: str="8PSK modulation not supported for uplink"; break;
9161                         case 0x01: str="Power class E1"; break;
9162                         case 0x02: str="Power class E2"; break;
9163                         case 0x03: str="Power class E3"; break;
9164                         default: str="This should not happen";
9165                 }
9166     
9167                 proto_tree_add_text(tf_tree,
9168                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9169                         "8PSK Power Class: (%u) %s",oct>>(32-bits_needed),str);
9170                 curr_bits_length -= bits_needed;
9171                 oct <<= bits_needed;
9172                 bits_in_oct -= bits_needed;
9173
9174                 } while (!finished);
9175                 
9176                 /* goto next one */
9177                 continue;
9178         }
9179         /*
9180          * RF Power
9181          */
9182         bits_needed = 3;
9183         GET_DATA;
9184
9185         /* analyse bits */
9186         if ( acc_type == 0x04 ) /* GSM 1900 */
9187         {
9188                 switch ( oct>>(32-bits_needed) )
9189                 {
9190                         case 0x01: str="1 W (30 dBm)"; break;
9191                         case 0x02: str="0,25 W (24 dBm)"; break;
9192                         case 0x03: str="2 W (33 dBm)"; break;
9193                         default: str="Not specified";
9194                 }
9195         }
9196         else if ( acc_type == 0x03 )
9197         {
9198                 switch ( oct>>(32-bits_needed) )
9199                 {
9200                         case 0x01: str="1 W (30 dBm)"; break;
9201                         case 0x02: str="0,25 W (24 dBm)"; break;
9202                         case 0x03: str="4 W (36 dBm)"; break;
9203                         default: str="Not specified";
9204                 }
9205         }
9206         else if ( acc_type <= 0x08 )
9207         {
9208                 switch ( oct>>(32-bits_needed) )
9209                 {
9210                         case 0x02: str="8 W (39 dBm)"; break;
9211                         case 0x03: str="5 W (37 dBm)"; break;
9212                         case 0x04: str="2 W (33 dBm)"; break;
9213                         case 0x05: str="0,8 W (29 dBm)"; break;
9214                         default: str="Not specified";
9215                 }
9216         }
9217         else
9218                 str="Not specified??";
9219     
9220         proto_tree_add_text(tf_tree,
9221                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9222                 "RF Power Capability, GMSK Power Class: (%u) %s",oct>>(32-bits_needed),str);
9223         curr_bits_length -= bits_needed;
9224         oct <<= bits_needed;
9225         bits_in_oct -= bits_needed;
9226
9227         /*
9228          * A5 Bits?
9229          */
9230         bits_needed = 1;
9231         GET_DATA;
9232
9233         /* analyse bits */
9234         if ((oct>>(32-bits_needed))==0)
9235         {
9236                 proto_tree_add_text(tf_tree,
9237                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9238                         "A5 Bits: (%u) same values apply for parameters as in the immediately preceding Access capabilities field within this IE",oct>>(32-bits_needed));
9239                 curr_bits_length -= bits_needed;
9240                 oct <<= bits_needed;
9241                 bits_in_oct -= bits_needed;
9242         }
9243         else
9244         {
9245                 int i;
9246
9247                 proto_tree_add_text(tf_tree,
9248                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9249                         "A5 Bits: (%u) A5 bits follows",oct>>(32-bits_needed));
9250
9251                 curr_bits_length -= bits_needed;
9252                 oct <<= bits_needed;
9253                 bits_in_oct -= bits_needed;
9254                 
9255                 for (i=1; i<= 7 ; i++ )
9256                 {
9257                         /*
9258                          * A5 Bits decoding
9259                          */
9260                         bits_needed = 1;
9261                         GET_DATA;
9262
9263                         /* analyse bits */
9264                         switch ( oct>>(32-bits_needed) )
9265                         {
9266                                 case 0x00: str="encryption algorithm not available"; break;
9267                                 case 0x01: str="encryption algorithm available"; break;
9268                                 default: str="This should not happen";
9269                         }
9270     
9271                         proto_tree_add_text(tf_tree,
9272                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9273                                 "A5/%d: (%u) %s",i,oct>>(32-bits_needed),str);
9274                         curr_bits_length -= bits_needed;
9275                         oct <<= bits_needed;
9276                         bits_in_oct -= bits_needed;
9277                 }
9278         }
9279     
9280         /*
9281          * ES IND
9282          */
9283         bits_needed = 1;
9284         GET_DATA;
9285
9286         /* analyse bits */
9287         switch ( oct>>(32-bits_needed) )
9288         {
9289                 case 0x00: str="controlled early Classmark Sending option is not implemented"; break;
9290                 case 0x01: str="controlled early Classmark Sending option is implemented"; break;
9291                 default: str="This should not happen";
9292         }
9293     
9294         proto_tree_add_text(tf_tree,
9295                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9296                 "Controlled early Classmark Sending: (%u) %s",oct>>(32-bits_needed),str);
9297         curr_bits_length -= bits_needed;
9298         oct <<= bits_needed;
9299         bits_in_oct -= bits_needed;
9300
9301         /*
9302          * PS
9303          */
9304         bits_needed = 1;
9305         GET_DATA;
9306
9307         /* analyse bits */
9308         switch ( oct>>(32-bits_needed) )
9309         {
9310                 case 0x00: str="PS capability not present"; break;
9311                 case 0x01: str="PS capability present"; break;
9312                 default: str="This should not happen";
9313         }
9314     
9315         proto_tree_add_text(tf_tree,
9316                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9317                 "Pseudo Synchronisation: (%u) %s",oct>>(32-bits_needed),str);
9318         curr_bits_length -= bits_needed;
9319         oct <<= bits_needed;
9320         bits_in_oct -= bits_needed;
9321
9322         /*
9323          * VGCS
9324          */
9325         bits_needed = 1;
9326         GET_DATA;
9327
9328         /* analyse bits */
9329         switch ( oct>>(32-bits_needed) )
9330         {
9331                 case 0x00: str="no VGCS capability or no notifications wanted"; break;
9332                 case 0x01: str="VGCS capability and notifications wanted"; break;
9333                 default: str="This should not happen";
9334         }
9335     
9336         proto_tree_add_text(tf_tree,
9337                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9338                 "Voice Group Call Service: (%u) %s",oct>>(32-bits_needed),str);
9339         curr_bits_length -= bits_needed;
9340         oct <<= bits_needed;
9341         bits_in_oct -= bits_needed;
9342
9343         /*
9344          * VBS
9345          */
9346         bits_needed = 1;
9347         GET_DATA;
9348
9349         /* analyse bits */
9350         switch ( oct>>(32-bits_needed) )
9351         {
9352                 case 0x00: str="no VBS capability or no notifications wanted"; break;
9353                 case 0x01: str="VBS capability and notifications wanted"; break;
9354                 default: str="This should not happen";
9355         }
9356     
9357         proto_tree_add_text(tf_tree,
9358                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9359                 "Voice Broadcast Service: (%u) %s",oct>>(32-bits_needed),str);
9360         curr_bits_length -= bits_needed;
9361         oct <<= bits_needed;
9362         bits_in_oct -= bits_needed;
9363
9364         /*
9365          * Multislot capability?
9366          */
9367         bits_needed = 1;
9368         GET_DATA;
9369
9370         /* analyse bits */
9371         if ((oct>>(32-bits_needed))==0)
9372         {
9373                 proto_tree_add_text(tf_tree,
9374                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9375                         "Multislot capability: (%u) same values apply for parameters as in the immediately preceding Access capabilities field within this IE",oct>>(32-bits_needed));
9376                 curr_bits_length -= bits_needed;
9377                 oct <<= bits_needed;
9378                 bits_in_oct -= bits_needed;
9379         }
9380         else
9381         {
9382                 proto_tree_add_text(tf_tree,
9383                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9384                         "Multislot capability: (%u) Multislot capability struct available",oct>>(32-bits_needed));
9385
9386                 curr_bits_length -= bits_needed;
9387                 oct <<= bits_needed;
9388                 bits_in_oct -= bits_needed;
9389
9390                 /*
9391                  * HSCSD multislot class?
9392                  */
9393                 bits_needed = 1;
9394                 GET_DATA;
9395
9396                 /* analyse bits */
9397                 if ((oct>>(32-bits_needed))==0)
9398                 {
9399                         proto_tree_add_text(tf_tree,
9400                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9401                                 "HSCSD multislot class: (%u) Bits are not available",oct>>(32-bits_needed));
9402                         curr_bits_length -= bits_needed;
9403                         oct <<= bits_needed;
9404                         bits_in_oct -= bits_needed;
9405                 }
9406                 else
9407                 {
9408                         curr_bits_length -= bits_needed;
9409                         oct <<= bits_needed;
9410                         bits_in_oct -= bits_needed;
9411
9412                         /*
9413                          * HSCSD multislot class
9414                          */
9415                         bits_needed = 5;
9416                         GET_DATA;
9417
9418                         /* analyse bits */
9419                         proto_tree_add_text(tf_tree,
9420                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9421                                 "HSCSD multislot class: (%u) %s",oct>>(32-bits_needed),multi_slot_str[oct>>(32-bits_needed)]);
9422                         curr_bits_length -= bits_needed;
9423                         oct <<= bits_needed;
9424                         bits_in_oct -= bits_needed;
9425                 }
9426
9427                 /*
9428                  * GPRS multislot class?
9429                  */
9430                 bits_needed = 1;
9431                 GET_DATA;
9432
9433                 /* analyse bits */
9434                 if ((oct>>(32-bits_needed))==0)
9435                 {
9436                         proto_tree_add_text(tf_tree,
9437                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9438                                 "GPRS multislot class: (%u) Bits are not available",oct>>(32-bits_needed));
9439                         curr_bits_length -= bits_needed;
9440                         oct <<= bits_needed;
9441                         bits_in_oct -= bits_needed;
9442                 }
9443                 else
9444                 {
9445                         curr_bits_length -= bits_needed;
9446                         oct <<= bits_needed;
9447                         bits_in_oct -= bits_needed;
9448
9449                         /*
9450                          * GPRS multislot class
9451                          */
9452                         bits_needed = 5;
9453                         GET_DATA;
9454
9455                         /* analyse bits */
9456                         proto_tree_add_text(tf_tree,
9457                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9458                                 "GPRS multislot class: (%u) %s",oct>>(32-bits_needed),multi_slot_str[oct>>(32-bits_needed)]);
9459                         curr_bits_length -= bits_needed;
9460                         oct <<= bits_needed;
9461                         bits_in_oct -= bits_needed;
9462
9463                         /*
9464                          * GPRS Extended Dynamic Allocation Capability
9465                          */
9466                         bits_needed = 1;
9467                         GET_DATA;
9468
9469                         /* analyse bits */
9470                         switch ( oct>>(32-bits_needed) )
9471                         {
9472                                 case 0x00: str="Extended Dynamic Allocation Capability for GPRS is not implemented"; break;
9473                                 case 0x01: str="Extended Dynamic Allocation Capability for GPRS is implemented"; break;
9474                                 default: str="This should not happen";
9475                         }
9476                         proto_tree_add_text(tf_tree,
9477                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9478                                 "GPRS Extended Dynamic Allocation Capability: (%u) %s",oct>>(32-bits_needed),str);
9479                         curr_bits_length -= bits_needed;
9480                         oct <<= bits_needed;
9481                         bits_in_oct -= bits_needed;
9482                 }
9483
9484                 /*
9485                  * SMS/SM values
9486                  */
9487                 bits_needed = 1;
9488                 GET_DATA;
9489
9490                 /* analyse bits */
9491                 if ((oct>>(32-bits_needed))==0)
9492                 {
9493                         proto_tree_add_text(tf_tree,
9494                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9495                                 "SMS/SM values: (%u) Bits are not available",oct>>(32-bits_needed));
9496                         curr_bits_length -= bits_needed;
9497                         oct <<= bits_needed;
9498                         bits_in_oct -= bits_needed;
9499                 }
9500                 else
9501                 {
9502                         curr_bits_length -= bits_needed;
9503                         oct <<= bits_needed;
9504                         bits_in_oct -= bits_needed;
9505
9506                         /*
9507                          * Switch-Measure-Switch value
9508                          */
9509                         bits_needed = 4;
9510                         GET_DATA;
9511
9512                         /* analyse bits */
9513                         proto_tree_add_text(tf_tree,
9514                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9515                                 "Switch-Measure-Switch value: (%u) %d/4 timeslot (~%d microseconds)",
9516                                 oct>>(32-bits_needed),oct>>(32-bits_needed),(oct>>(32-bits_needed))*144);
9517                         curr_bits_length -= bits_needed;
9518                         oct <<= bits_needed;
9519                         bits_in_oct -= bits_needed;
9520
9521                         /*
9522                          * Switch-Measure value
9523                          */
9524                         bits_needed = 4;
9525                         GET_DATA;
9526
9527                         /* analyse bits */
9528                         proto_tree_add_text(tf_tree,
9529                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9530                                 "Switch-Measure value: (%u) %d/4 timeslot (~%d microseconds)",
9531                                 oct>>(32-bits_needed),oct>>(32-bits_needed),(oct>>(32-bits_needed))*144);
9532                         curr_bits_length -= bits_needed;
9533                         oct <<= bits_needed;
9534                         bits_in_oct -= bits_needed;
9535                 }
9536
9537                 /*
9538                  * ECSD multislot class?
9539                  */
9540                 bits_needed = 1;
9541                 GET_DATA;
9542
9543                 /* analyse bits */
9544                 if ((oct>>(32-bits_needed))==0)
9545                 {
9546                         proto_tree_add_text(tf_tree,
9547                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9548                                 "ECSD multislot class: (%u) Bits are not available",oct>>(32-bits_needed));
9549                         curr_bits_length -= bits_needed;
9550                         oct <<= bits_needed;
9551                         bits_in_oct -= bits_needed;
9552                 }
9553                 else
9554                 {
9555                         curr_bits_length -= bits_needed;
9556                         oct <<= bits_needed;
9557                         bits_in_oct -= bits_needed;
9558
9559                         /*
9560                          * ECSD multislot class
9561                          */
9562                         bits_needed = 5;
9563                         GET_DATA;
9564
9565                         /* analyse bits */
9566                         proto_tree_add_text(tf_tree,
9567                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9568                                 "ECSD multislot class: (%u) %s",oct>>(32-bits_needed),multi_slot_str[oct>>(32-bits_needed)]);
9569                         curr_bits_length -= bits_needed;
9570                         oct <<= bits_needed;
9571                         bits_in_oct -= bits_needed;
9572                 }
9573
9574                 /*
9575                  * EGPRS multislot class?
9576                  */
9577                 bits_needed = 1;
9578                 GET_DATA;
9579
9580                 /* analyse bits */
9581                 if ((oct>>(32-bits_needed))==0)
9582                 {
9583                         proto_tree_add_text(tf_tree,
9584                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9585                                 "EGPRS multislot class: (%u) Bits are not available",oct>>(32-bits_needed));
9586                         curr_bits_length -= bits_needed;
9587                         oct <<= bits_needed;
9588                         bits_in_oct -= bits_needed;
9589                 }
9590                 else
9591                 {
9592                         curr_bits_length -= bits_needed;
9593                         oct <<= bits_needed;
9594                         bits_in_oct -= bits_needed;
9595
9596                         /*
9597                          * EGPRS multislot class
9598                          */
9599                         bits_needed = 5;
9600                         GET_DATA;
9601
9602                         /* analyse bits */
9603                         proto_tree_add_text(tf_tree,
9604                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9605                                 "EGPRS multislot class: (%u) %s",oct>>(32-bits_needed),multi_slot_str[oct>>(32-bits_needed)]);
9606                         curr_bits_length -= bits_needed;
9607                         oct <<= bits_needed;
9608                         bits_in_oct -= bits_needed;
9609
9610                         /*
9611                          * EGPRS Extended Dynamic Allocation Capability
9612                          */
9613                         bits_needed = 1;
9614                         GET_DATA;
9615
9616                         /* analyse bits */
9617                         switch ( oct>>(32-bits_needed) )
9618                         {
9619                                 case 0x00: str="Extended Dynamic Allocation Capability for EGPRS is not implemented"; break;
9620                                 case 0x01: str="Extended Dynamic Allocation Capability for EGPRS is implemented"; break;
9621                                 default: str="This should not happen";
9622                         }
9623                         proto_tree_add_text(tf_tree,
9624                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9625                                 "EGPRS Extended Dynamic Allocation Capability: (%u) %s",oct>>(32-bits_needed),str);
9626                         curr_bits_length -= bits_needed;
9627                         oct <<= bits_needed;
9628                         bits_in_oct -= bits_needed;
9629                 }
9630
9631                 /*
9632                  * DTM GPRS Multi Slot Class ?
9633                 */
9634                 bits_needed = 1;
9635                 GET_DATA;
9636
9637                 /* analyse bits */
9638                 if ((oct>>(32-bits_needed))==0)
9639                 {
9640                         proto_tree_add_text(tf_tree,
9641                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9642                                 "DTM GPRS Multi Slot Class: (%u) Bits are not available",oct>>(32-bits_needed));
9643                         curr_bits_length -= bits_needed;
9644                         oct <<= bits_needed;
9645                         bits_in_oct -= bits_needed;
9646                 }
9647                 else
9648                 {
9649                         curr_bits_length -= bits_needed;
9650                         oct <<= bits_needed;
9651                         bits_in_oct -= bits_needed;
9652
9653                         /*
9654                          * DTM GPRS Multi Slot Class
9655                          */
9656                         bits_needed = 2;
9657                         GET_DATA;
9658
9659                         /* analyse bits */
9660                         dtm_gprs_mslot = oct>>(32-bits_needed);
9661
9662                         switch ( oct>>(32-bits_needed) )
9663                         {
9664                                 case 0: str="Unused. If received, the network shall interpret this as Multislot class 5"; break;
9665                                 case 1: str="Multislot class 5 supported"; break;
9666                                 case 2: str="Multislot class 9 supported"; break;
9667                                 case 3: str="Multislot class 11 supported"; break;
9668                                 default: str="This should not happen";
9669                         }
9670                         
9671                         proto_tree_add_text(tf_tree,
9672                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9673                                 "DTM GPRS Multi Slot Class: (%u) %s",oct>>(32-bits_needed),str);
9674                         curr_bits_length -= bits_needed;
9675                         oct <<= bits_needed;
9676                         bits_in_oct -= bits_needed;
9677
9678                         /*
9679                          * Single Slot DTM
9680                          */
9681                         bits_needed = 1;
9682                         GET_DATA;
9683
9684                         /* analyse bits */
9685                         switch ( oct>>(32-bits_needed) )
9686                         {
9687                                 case 0x00: str="Single Slot DTM not supported"; break;
9688                                 case 0x01: str="Single Slot DTM supported"; break;
9689                                 default: str="This should not happen";
9690                         }
9691                         proto_tree_add_text(tf_tree,
9692                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9693                                 "Single Slot DTM: (%u) %s",oct>>(32-bits_needed),str);
9694                         curr_bits_length -= bits_needed;
9695                         oct <<= bits_needed;
9696                         bits_in_oct -= bits_needed;
9697
9698                         /*
9699                          * DTM EGPRS Multi Slot Class ?
9700                         */
9701                         bits_needed = 1;
9702                         GET_DATA;
9703
9704                         /* analyse bits */
9705                         dtm_egprs_mslot = oct>>(32-bits_needed);
9706
9707                         if ((oct>>(32-bits_needed))==0)
9708                         {
9709                                 proto_tree_add_text(tf_tree,
9710                                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9711                                         "DTM EGPRS Multi Slot Class: (%u) Bits are not available",oct>>(32-bits_needed));
9712                                 curr_bits_length -= bits_needed;
9713                                 oct <<= bits_needed;
9714                                 bits_in_oct -= bits_needed;
9715                         }
9716                         else
9717                         {
9718                                 curr_bits_length -= bits_needed;
9719                                 oct <<= bits_needed;
9720                                 bits_in_oct -= bits_needed;
9721
9722                                 /*
9723                                  * DTM EGPRS Multi Slot Class
9724                                  */
9725                                 bits_needed = 2;
9726                                 GET_DATA;
9727
9728                                 /* analyse bits */
9729                                 switch ( oct>>(32-bits_needed) )
9730                                 {
9731                                         case 0: str="Unused. If received, the network shall interpret this as Multislot class 5"; break;
9732                                         case 1: str="Multislot class 5 supported"; break;
9733                                         case 2: str="Multislot class 9 supported"; break;
9734                                         case 3: str="Multislot class 11 supported"; break;
9735                                         default: str="This should not happen";
9736                                 }
9737                         
9738                                 proto_tree_add_text(tf_tree,
9739                                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9740                                         "DTM EGPRS Multi Slot Class: (%u) %s",oct>>(32-bits_needed),str);
9741                                 curr_bits_length -= bits_needed;
9742                                 oct <<= bits_needed;
9743                                 bits_in_oct -= bits_needed;
9744                         }
9745                 }
9746         }
9747
9748         /*
9749          * 8PSK Power Capability?
9750          */
9751         bits_needed = 1;
9752         GET_DATA;
9753
9754         /* analyse bits */
9755         if ((oct>>(32-bits_needed))==0)
9756         {
9757                 proto_tree_add_text(tf_tree,
9758                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9759                         "8PSK Power Capability: (%u) Bits are not available",oct>>(32-bits_needed));
9760                 curr_bits_length -= bits_needed;
9761                 oct <<= bits_needed;
9762                 bits_in_oct -= bits_needed;
9763         }
9764         else
9765         {
9766                 curr_bits_length -= bits_needed;
9767                 oct <<= bits_needed;
9768                 bits_in_oct -= bits_needed;
9769
9770                 /*
9771                  * 8PSK Power Capability
9772                  */
9773                 bits_needed = 2;
9774                 GET_DATA;
9775
9776                 /* analyse bits */
9777                 switch ( oct>>(32-bits_needed) )
9778                 {
9779                         case 0x00: str="Reserved"; break;
9780                         case 0x01: str="Power class E1"; break;
9781                         case 0x02: str="Power class E2"; break;
9782                         case 0x03: str="Power class E3"; break;
9783                         default: str="This should not happen";
9784                 }
9785     
9786                 proto_tree_add_text(tf_tree,
9787                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9788                         "8PSK Power Capability: (%u) %s",oct>>(32-bits_needed),str);
9789                 curr_bits_length -= bits_needed;
9790                 oct <<= bits_needed;
9791                 bits_in_oct -= bits_needed;
9792         }
9793
9794         /*
9795          * COMPACT Interference Measurement Capability
9796          */
9797         bits_needed = 1;
9798         GET_DATA;
9799
9800         /* analyse bits */
9801         switch ( oct>>(32-bits_needed) )
9802         {
9803                 case 0x00: str="COMPACT Interference Measurement Capability is not implemented"; break;
9804                 case 0x01: str="COMPACT Interference Measurement Capability is implemented"; break;
9805                 default: str="This should not happen";
9806         }
9807     
9808         proto_tree_add_text(tf_tree,
9809                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9810                 "COMPACT Interference Measurement Capability: (%u) %s",oct>>(32-bits_needed),str);
9811         curr_bits_length -= bits_needed;
9812         oct <<= bits_needed;
9813         bits_in_oct -= bits_needed;
9814
9815         /*
9816          * Revision Level Indicator
9817          */
9818         bits_needed = 1;
9819         GET_DATA;
9820
9821         /* analyse bits */
9822         switch ( oct>>(32-bits_needed) )
9823         {
9824                 case 0x00: str="The ME is Release 98 or older"; break;
9825                 case 0x01: str="The ME is Release 99 onwards"; break;
9826                 default: str="This should not happen";
9827         }
9828     
9829         proto_tree_add_text(tf_tree,
9830                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9831                 "Revision Level Indicator: (%u) %s",oct>>(32-bits_needed),str);
9832         curr_bits_length -= bits_needed;
9833         oct <<= bits_needed;
9834         bits_in_oct -= bits_needed;
9835
9836         /*
9837          * UMTS FDD Radio Access Technology Capability
9838          */
9839         bits_needed = 1;
9840         GET_DATA;
9841
9842         /* analyse bits */
9843         switch ( oct>>(32-bits_needed) )
9844         {
9845                 case 0x00: str="UMTS FDD not supported"; break;
9846                 case 0x01: str="UMTS FDD supported"; break;
9847                 default: str="This should not happen";
9848         }
9849     
9850         proto_tree_add_text(tf_tree,
9851                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9852                 "UMTS FDD Radio Access Technology Capability: (%u) %s",oct>>(32-bits_needed),str);
9853         curr_bits_length -= bits_needed;
9854         oct <<= bits_needed;
9855         bits_in_oct -= bits_needed;
9856
9857         /*
9858          * UMTS 3.84 Mcps TDD Radio Access Technology Capability
9859          */
9860         bits_needed = 1;
9861         GET_DATA;
9862
9863         /* analyse bits */
9864         switch ( oct>>(32-bits_needed) )
9865         {
9866                 case 0x00: str="UMTS 3.84 Mcps TDD not supported"; break;
9867                 case 0x01: str="UMTS 3.84 Mcps TDD supported"; break;
9868                 default: str="This should not happen";
9869         }
9870     
9871         proto_tree_add_text(tf_tree,
9872                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9873                 "UMTS 3.84 Mcps TDD Radio Access Technology Capability: (%u) %s",oct>>(32-bits_needed),str);
9874         curr_bits_length -= bits_needed;
9875         oct <<= bits_needed;
9876         bits_in_oct -= bits_needed;
9877
9878         /*
9879          * CDMA 2000 Radio Access Technology Capability
9880          */
9881         bits_needed = 1;
9882         GET_DATA;
9883
9884         /* analyse bits */
9885         switch ( oct>>(32-bits_needed) )
9886         {
9887                 case 0x00: str="CDMA 2000 not supported"; break;
9888                 case 0x01: str="CDMA 2000 supported"; break;
9889                 default: str="This should not happen";
9890         }
9891     
9892         proto_tree_add_text(tf_tree,
9893                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9894                 "CDMA 2000 Radio Access Technology Capability: (%u) %s",oct>>(32-bits_needed),str);
9895         curr_bits_length -= bits_needed;
9896         oct <<= bits_needed;
9897         bits_in_oct -= bits_needed;
9898
9899         /*
9900          * UMTS 1.28 Mcps TDD Radio Access Technology Capability
9901          */
9902         bits_needed = 1;
9903         GET_DATA;
9904
9905         /* analyse bits */
9906         switch ( oct>>(32-bits_needed) )
9907         {
9908                 case 0x00: str="UMTS 1.28 Mcps TDD not supported"; break;
9909                 case 0x01: str="UMTS 1.28 Mcps TDD supported"; break;
9910                 default: str="This should not happen";
9911         }
9912     
9913         proto_tree_add_text(tf_tree,
9914                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9915                 "UMTS 1.28 Mcps TDD Radio Access Technology Capability: (%u) %s",oct>>(32-bits_needed),str);
9916         curr_bits_length -= bits_needed;
9917         oct <<= bits_needed;
9918         bits_in_oct -= bits_needed;
9919
9920         /*
9921          * GERAN Feature Package 1
9922          */
9923         bits_needed = 1;
9924         GET_DATA;
9925
9926         /* analyse bits */
9927         switch ( oct>>(32-bits_needed) )
9928         {
9929                 case 0x00: str="GERAN feature package 1 not supported"; break;
9930                 case 0x01: str="GERAN feature package 1 supported"; break;
9931                 default: str="This should not happen";
9932         }
9933     
9934         proto_tree_add_text(tf_tree,
9935                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9936                 "GERAN Feature Package 1: (%u) %s",oct>>(32-bits_needed),str);
9937         curr_bits_length -= bits_needed;
9938         oct <<= bits_needed;
9939         bits_in_oct -= bits_needed;
9940
9941         /*
9942          * Extended DTM (E)GPRS Multi Slot Class
9943          */
9944         bits_needed = 1;
9945         GET_DATA;
9946
9947         /* analyse bits */
9948         if ((oct>>(32-bits_needed))==0)
9949         {
9950                 proto_tree_add_text(tf_tree,
9951                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9952                         "Extended DTM (E)GPRS Multi Slot Class: (%u) Bits are not available",oct>>(32-bits_needed));
9953                 curr_bits_length -= bits_needed;
9954                 oct <<= bits_needed;
9955                 bits_in_oct -= bits_needed;
9956         }
9957         else
9958         {
9959                 curr_bits_length -= bits_needed;
9960                 oct <<= bits_needed;
9961                 bits_in_oct -= bits_needed;
9962
9963                 /*
9964                  * Extended DTM GPRS Multi Slot Class
9965                  */
9966                 bits_needed = 2;
9967                 GET_DATA;
9968
9969                 /* analyse bits */
9970                 switch ( (oct>>(32-bits_needed))|(dtm_gprs_mslot<<4) )
9971                 {
9972                         case 0x00: str="Unused. If received, it shall be interpreted as Multislot class 5 supported"; break;
9973                         case 0x01: str="Unused. If received, it shall be interpreted as Multislot class 5 supported"; break;
9974                         case 0x02: str="Unused. If received, it shall be interpreted as Multislot class 5 supported"; break;
9975                         case 0x03: str="Unused. If received, it shall be interpreted as Multislot class 5 supported"; break;
9976                         case 0x10: str="Multislot class 5 supported"; break;
9977                         case 0x11: str="Multislot class 6 supported"; break;
9978                         case 0x12: str="Unused. If received, it shall be interpreted as Multislot class 5 supported"; break;
9979                         case 0x13: str="Unused. If received, it shall be interpreted as Multislot class 5 supported"; break;
9980                         case 0x20: str="Multislot class 9 supported"; break;
9981                         case 0x21: str="Multislot class 10 supported"; break;
9982                         case 0x22: str="Unused. If received, it shall be interpreted as Multislot class 9 supported"; break;
9983                         case 0x23: str="Unused. If received, it shall be interpreted as Multislot class 9 supported"; break;
9984                         case 0x30: str="Multislot class 11 supported"; break;
9985                         case 0x31: str="Unused. If received, it shall be interpreted as Multislot class 11 supported"; break;
9986                         case 0x32: str="Unused. If received, it shall be interpreted as Multislot class 11 supported"; break;
9987                         case 0x33: str="Unused. If received, it shall be interpreted as Multislot class 11 supported"; break;
9988                         default: str="This should not happen";
9989                 }
9990     
9991                 proto_tree_add_text(tf_tree,
9992                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
9993                         "Extended DTM GPRS Multi Slot Class: (%u) %s",oct>>(32-bits_needed),str);
9994                 curr_bits_length -= bits_needed;
9995                 oct <<= bits_needed;
9996                 bits_in_oct -= bits_needed;
9997
9998                 if ( dtm_egprs_mslot <= 3 )
9999                 {
10000                         /*
10001                          * Extended DTM EGPRS Multi Slot Class
10002                          */
10003                         bits_needed = 2;
10004                         GET_DATA;
10005
10006                         /* analyse bits */
10007                         switch ( (oct>>(32-bits_needed))|(dtm_egprs_mslot<<4) )
10008                         {
10009                                 case 0x00: str="Unused. If received, it shall be interpreted as Multislot class 5 supported"; break;
10010                                 case 0x01: str="Unused. If received, it shall be interpreted as Multislot class 5 supported"; break;
10011                                 case 0x02: str="Unused. If received, it shall be interpreted as Multislot class 5 supported"; break;
10012                                 case 0x03: str="Unused. If received, it shall be interpreted as Multislot class 5 supported"; break;
10013                                 case 0x10: str="Multislot class 5 supported"; break;
10014                                 case 0x11: str="Multislot class 6 supported"; break;
10015                                 case 0x12: str="Unused. If received, it shall be interpreted as Multislot class 5 supported"; break;
10016                                 case 0x13: str="Unused. If received, it shall be interpreted as Multislot class 5 supported"; break;
10017                                 case 0x20: str="Multislot class 9 supported"; break;
10018                                 case 0x21: str="Multislot class 10 supported"; break;
10019                                 case 0x22: str="Unused. If received, it shall be interpreted as Multislot class 9 supported"; break;
10020                                 case 0x23: str="Unused. If received, it shall be interpreted as Multislot class 9 supported"; break;
10021                                 case 0x30: str="Multislot class 11 supported"; break;
10022                                 case 0x31: str="Unused. If received, it shall be interpreted as Multislot class 11 supported"; break;
10023                                 case 0x32: str="Unused. If received, it shall be interpreted as Multislot class 11 supported"; break;
10024                                 case 0x33: str="Unused. If received, it shall be interpreted as Multislot class 11 supported"; break;
10025                                 default: str="This should not happen";
10026                         }
10027     
10028                         proto_tree_add_text(tf_tree,
10029                                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
10030                                 "Extended DTM EGPRS Multi Slot Class: (%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         /*
10038          * Modulation based multislot class support
10039          */
10040         bits_needed = 1;
10041         GET_DATA;
10042
10043         /* analyse bits */
10044         switch ( oct>>(32-bits_needed) )
10045         {
10046                 case 0x00: str="Modulation based multislot class not supported"; break;
10047                 case 0x01: str="Modulation based multislot class supported"; break;
10048                 default: str="This should not happen";
10049         }
10050     
10051         proto_tree_add_text(tf_tree,
10052                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
10053                 "Modulation based multislot class support: (%u) %s",oct>>(32-bits_needed),str);
10054         curr_bits_length -= bits_needed;
10055         oct <<= bits_needed;
10056         bits_in_oct -= bits_needed;
10057
10058         /*
10059          * High Multislot Capability
10060          */
10061         bits_needed = 1;
10062         GET_DATA;
10063
10064         /* analyse bits */
10065         if ((oct>>(32-bits_needed))==0)
10066         {
10067                 proto_tree_add_text(tf_tree,
10068                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
10069                         "High Multislot Capability: (%u) Bits are not available",oct>>(32-bits_needed));
10070                 curr_bits_length -= bits_needed;
10071                 oct <<= bits_needed;
10072                 bits_in_oct -= bits_needed;
10073         }
10074         else
10075         {
10076                 curr_bits_length -= bits_needed;
10077                 oct <<= bits_needed;
10078                 bits_in_oct -= bits_needed;
10079
10080                 /*
10081                  * High Multislot Capability
10082                  */
10083                 bits_needed = 2;
10084                 GET_DATA;
10085
10086                 /* analyse bits */
10087                 proto_tree_add_text(tf_tree,
10088                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
10089                         "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));
10090                 curr_bits_length -= bits_needed;
10091                 oct <<= bits_needed;
10092                 bits_in_oct -= bits_needed;
10093
10094         }
10095
10096         /*
10097          * GERAN Iu Mode Capability
10098          */
10099         bits_needed = 1;
10100         GET_DATA;
10101
10102         /* analyse bits */
10103         switch ( oct>>(32-bits_needed) )
10104         {
10105                 case 0x00: str="GERAN Iu mode not supported"; break;
10106                 case 0x01: str="GERAN Iu mode supported"; break;
10107                 default: str="This should not happen";
10108         }
10109     
10110         proto_tree_add_text(tf_tree,
10111                 tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
10112                 "GERAN Iu Mode Capability: (%u) %s",oct>>(32-bits_needed),str);
10113         curr_bits_length -= bits_needed;
10114         oct <<= bits_needed;
10115         bits_in_oct -= bits_needed;
10116
10117         /*
10118          * GMSK/8-PSK Multislot Power Profile
10119          */
10120         bits_needed = 1;
10121         GET_DATA;
10122
10123         /* analyse bits */
10124         if ((oct>>(32-bits_needed))==0)
10125         {
10126                 proto_tree_add_text(tf_tree,
10127                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
10128                         "GMSK/8-PSK Multislot Power Profile: (%u) Bits are not available",oct>>(32-bits_needed));
10129                 curr_bits_length -= bits_needed;
10130                 oct <<= bits_needed;
10131                 bits_in_oct -= bits_needed;
10132         }
10133         else
10134         {
10135                 curr_bits_length -= bits_needed;
10136                 oct <<= bits_needed;
10137                 bits_in_oct -= bits_needed;
10138
10139                 /*
10140                  * GMSK Multislot Power Profile
10141                  */
10142                 bits_needed = 2;
10143                 GET_DATA;
10144
10145                 /* analyse bits */
10146                 switch ( oct>>(32-bits_needed) )
10147                 {
10148                         case 0x00: str="GMSK_MULTISLOT_POWER_PROFILE 0"; break;
10149                         case 0x01: str="GMSK_MULTISLOT_POWER_PROFILE 1"; break;
10150                         case 0x02: str="GMSK_MULTISLOT_POWER_PROFILE 2"; break;
10151                         case 0x03: str="GMSK_MULTISLOT_POWER_PROFILE 3"; break;
10152                         default: str="This should not happen";
10153                 }
10154                 
10155                 proto_tree_add_text(tf_tree,
10156                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
10157                         "GMSK Multislot Power Profile: (%u) %s",oct>>(32-bits_needed),str);
10158                 curr_bits_length -= bits_needed;
10159                 oct <<= bits_needed;
10160                 bits_in_oct -= bits_needed;
10161
10162                 /*
10163                  * 8-PSK Multislot Power Profile
10164                  */
10165                 bits_needed = 2;
10166                 GET_DATA;
10167
10168                 /* analyse bits */
10169                 switch ( oct>>(32-bits_needed) )
10170                 {
10171                         case 0x00: str="8-PSK_MULTISLOT_POWER_PROFILE 0"; break;
10172                         case 0x01: str="8-PSK_MULTISLOT_POWER_PROFILE 1"; break;
10173                         case 0x02: str="8-PSK_MULTISLOT_POWER_PROFILE 2"; break;
10174                         case 0x03: str="8-PSK_MULTISLOT_POWER_PROFILE 3"; break;
10175                         default: str="This should not happen";
10176                 }
10177                 
10178                 proto_tree_add_text(tf_tree,
10179                         tvb, curr_offset-1-add_ocetets, 1+add_ocetets,
10180                         "8-PSK Multislot Power Profile: (%u) %s",oct>>(32-bits_needed),str);
10181                 curr_bits_length -= bits_needed;
10182                 oct <<= bits_needed;
10183                 bits_in_oct -= bits_needed;
10184
10185         }
10186
10187         /*
10188          * we are too long ... so jump over it
10189          */
10190         while ( curr_bits_length > 0 )
10191         {
10192                 if ( curr_bits_length > 8 )
10193                         bits_needed = 8;
10194                 else
10195                         bits_needed = curr_bits_length;
10196                 GET_DATA;
10197                 curr_bits_length -= bits_needed;
10198                 oct <<= bits_needed;
10199                 bits_in_oct -= bits_needed;
10200         }        
10201         
10202     } while ( 1 );
10203     
10204     curr_offset+= curr_len;        
10205                    
10206     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
10207
10208     return(curr_offset - offset);
10209 }
10210
10211 /*
10212  * [7] 10.5.5.13
10213  */
10214 static guint8
10215 de_gc_spare(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
10216 {
10217     guint32     curr_offset;
10218     
10219     len = len;
10220     curr_offset = offset;
10221
10222     proto_tree_add_text(tree,
10223         tvb, curr_offset, 1,
10224         "Spare Nibble");
10225
10226     curr_offset++;
10227
10228     /* no length check possible */
10229
10230     return(curr_offset - offset);
10231 }
10232
10233 /*
10234  * [7] 10.5.5.14
10235  */
10236 static guint8
10237 de_gmm_cause(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
10238 {
10239     guint8      oct;
10240     guint32     curr_offset;
10241     const gchar *str;
10242     
10243     len = len;
10244     curr_offset = offset;
10245
10246     oct = tvb_get_guint8(tvb, curr_offset);
10247
10248     switch ( oct )
10249     {
10250         /* additional causes can be found in annex g */
10251         case 0x02: str="IMSI unknown in HLR"; break;
10252         case 0x03: str="Illegal MS"; break;
10253         case 0x04: str="IMSI unknown in VLR"; break;
10254         case 0x05: str="IMEI not accepted"; break;
10255         case 0x06: str="Illegal ME"; break;
10256         case 0x07: str="GPRS services not allowed"; break;
10257         case 0x08: str="GPRS services and non-GPRS services not allowed"; break;
10258         case 0x09: str="MS identity cannot be derived by the network"; break;
10259         case 0x0a: str="Implicitly detached"; break;
10260         case 0x0b: str="PLMN not allowed"; break;
10261         case 0x0c: str="Location Area not allowed"; break;
10262         case 0x0d: str="Roaming not allowed in this location area"; break;
10263         case 0x0e: str="GPRS services not allowed in this PLMN"; break;
10264         case 0x0f: str="No Suitable Cells In Location Area"; break;
10265         case 0x10: str="MSC temporarily not reachable"; break;
10266         case 0x11: str="Network failure"; break;
10267         case 0x14: str="MAC failure"; break;
10268         case 0x15: str="Synch failure"; break;
10269         case 0x16: str="Congestion"; break;
10270         case 0x17: str="GSM authentication unacceptable"; break;
10271         case 0x20: str="Service option not supported"; break;
10272         case 0x21: str="Requested service option not subscribed"; break;
10273         case 0x22: str="Service option temporarily out of order"; break;
10274         case 0x26: str="Call cannot be identified"; break;
10275         case 0x28: str="No PDP context activated"; break;
10276         case 0x30: str="retry upon entry into a new cell"; break;
10277         case 0x31: str="retry upon entry into a new cell"; break;
10278         case 0x32: str="retry upon entry into a new cell"; break;
10279         case 0x33: str="retry upon entry into a new cell"; break;
10280         case 0x34: str="retry upon entry into a new cell"; break;
10281         case 0x35: str="retry upon entry into a new cell"; break;
10282         case 0x36: str="retry upon entry into a new cell"; break;
10283         case 0x37: str="retry upon entry into a new cell"; break;
10284         case 0x38: str="retry upon entry into a new cell"; break;
10285         case 0x39: str="retry upon entry into a new cell"; break;
10286         case 0x3a: str="retry upon entry into a new cell"; break;
10287         case 0x3b: str="retry upon entry into a new cell"; break;
10288         case 0x3c: str="retry upon entry into a new cell"; break;
10289         case 0x3d: str="retry upon entry into a new cell"; break;
10290         case 0x3e: str="retry upon entry into a new cell"; break;
10291         case 0x3f: str="retry upon entry into a new cell"; break;
10292         case 0x5f: str="Semantically incorrect message"; break;
10293         case 0x60: str="Invalid mandatory information"; break;
10294         case 0x61: str="Message type non-existent or not implemented"; break;
10295         case 0x62: str="Message type not compatible with the protocol state"; break;
10296         case 0x63: str="Information element non-existent or not implemented"; break;
10297         case 0x64: str="Conditional IE error"; break;
10298         case 0x65: str="Message not compatible with the protocol state"; break;
10299         case 0x6f: str="Protocol error, unspecified"; break;
10300         default: str="Protocol error, unspecified";
10301     }
10302     
10303     proto_tree_add_text(tree,
10304         tvb, curr_offset, 1,
10305         "gmm Cause: (%u) %s",
10306         oct,
10307         str);
10308
10309     curr_offset++;
10310
10311     /* no length check possible */
10312
10313     return(curr_offset - offset);
10314 }
10315
10316 /*
10317  * [7] 10.5.5.15 Routing area identification
10318  */
10319 guint8
10320 de_gmm_rai(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
10321 {
10322     guint32     mcc;
10323     guint32     mnc;
10324     guint32     lac;
10325     guint32     rac;
10326     guint32     curr_offset;
10327     
10328     len = len;
10329     curr_offset = offset;
10330
10331     mcc = (tvb_get_guint8(tvb, curr_offset) & 0x0f) <<8;
10332         mcc |= (tvb_get_guint8(tvb, curr_offset) & 0xf0);
10333         mcc |= (tvb_get_guint8(tvb, curr_offset+1) & 0x0f);
10334         mnc = (tvb_get_guint8(tvb, curr_offset+2) & 0x0f) <<8;
10335         mnc |= (tvb_get_guint8(tvb, curr_offset+2) & 0xf0);
10336         mnc |= (tvb_get_guint8(tvb, curr_offset+1) & 0xf0) >>4;
10337         if ((mnc&0x000f) == 0x000f) 
10338                  mnc = mnc>>4;
10339
10340     lac = tvb_get_guint8(tvb, curr_offset+3);
10341     lac <<= 8;
10342     lac |= tvb_get_guint8(tvb, curr_offset+4);
10343     rac = tvb_get_guint8(tvb, curr_offset+5);
10344
10345         proto_tree_add_text(tree,
10346                 tvb, curr_offset, 6,
10347                 "Routing area identification: %x-%x-%x-%x",
10348                 mcc,mnc,lac,rac);
10349
10350     curr_offset+=6;
10351
10352     /* no length check possible */
10353
10354     return(curr_offset - offset);
10355 }
10356
10357 /*
10358  * [7] 10.5.5.17
10359  */
10360 static guint8
10361 de_gmm_update_res(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
10362 {
10363     guint8      oct;
10364     guint32     curr_offset;
10365     const gchar *str;
10366     
10367     len = len;
10368     curr_offset = offset;
10369
10370     oct = tvb_get_guint8(tvb, curr_offset);
10371
10372     /* IMPORTANT - IT'S ASSUMED THAT THE INFORMATION IS IN THE HIGHER NIBBLE */
10373     oct >>= 4;
10374
10375     switch(oct&7)
10376     {
10377         case 0: str="RA updated"; break;
10378         case 1: str="combined RA/LA updated";   break;
10379         default: str="reserved";
10380     }
10381
10382     proto_tree_add_text(tree,
10383         tvb, curr_offset, 1,
10384         "Update Result: (%u) %s",
10385         oct&7,
10386         str);
10387
10388     curr_offset++;
10389
10390     /* no length check possible */
10391
10392     return(curr_offset - offset);
10393 }
10394
10395 /*
10396  * [7] 10.5.5.18
10397  */
10398 static guint8
10399 de_gmm_update_type(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
10400 {
10401     guint8      oct;
10402     guint8      oct_ciph;
10403     guint32     curr_offset;
10404     const gchar *str_follow;
10405     const gchar *str_update;
10406     proto_item  *tf = NULL;
10407     proto_tree      *tf_tree = NULL;
10408     
10409     len = len;
10410     curr_offset = offset;
10411
10412     oct = tvb_get_guint8(tvb, curr_offset);
10413     oct_ciph = oct>>4;
10414
10415     oct &= 0x0f;
10416
10417     switch(oct&7)
10418     {
10419         case 0: str_update="RA updating"; break;
10420         case 1: str_update="combined RA/LA updating"; break;
10421         case 2: str_update="combined RA/LA updating with IMSI attach"; break;
10422         case 3: str_update="Periodic updating"; break;
10423         default: str_update="reserved";
10424     }
10425     switch(oct&8)
10426     {
10427         case 8: str_follow="Follow-on request pending"; break;
10428         default: str_follow="No follow-on request pending";
10429     }
10430
10431     tf = proto_tree_add_text(tree,
10432         tvb, curr_offset, 1,
10433         "Update Type");
10434
10435     tf_tree = proto_item_add_subtree(tf, ett_gmm_update_type );
10436
10437     proto_tree_add_text(tf_tree,
10438         tvb, curr_offset, 1,
10439         "Type: (%u) %s",
10440         oct&7,
10441         str_update);
10442     proto_tree_add_text(tf_tree,
10443         tvb, curr_offset, 1,
10444         "Follow: (%u) %s",
10445         (oct>>3)&1,
10446         str_follow);
10447
10448     /* The ciphering key sequence number is added here */
10449     proto_tree_add_text(tree,
10450         tvb, curr_offset, 1,
10451         "Ciphering key sequence number: 0x%02x (%u)",
10452         oct_ciph,
10453         oct_ciph);
10454
10455     curr_offset++;
10456
10457     /* no length check possible */
10458
10459     return(curr_offset - offset);
10460 }
10461
10462 /*
10463  * [7] 10.5.5.19
10464  */
10465 static guint8
10466 de_gmm_ac_ref_nr(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
10467 {
10468     guint8      oct;
10469     guint32     curr_offset;
10470     
10471     len = len;
10472     curr_offset = offset;
10473
10474     oct = tvb_get_guint8(tvb, curr_offset);
10475
10476     proto_tree_add_text(tree,
10477         tvb, curr_offset, 1,
10478         "A&C reference number: 0x%02x (%u)",
10479         oct&0xf,
10480         oct&0xf);
10481
10482     curr_offset++;
10483
10484     /* no length check possible */
10485
10486     return(curr_offset - offset);
10487 }
10488
10489 /*
10490  * [7] 10.5.5.19
10491  */
10492 static guint8
10493 de_gmm_ac_ref_nr_h(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
10494 {
10495     guint8      oct;
10496     guint32     curr_offset;
10497     
10498     len = len;
10499     curr_offset = offset;
10500
10501     oct = tvb_get_guint8(tvb, curr_offset);
10502
10503     /* IMPORTANT - IT'S ASSUMED THAT THE INFORMATION IS IN THE HIGHER NIBBLE */
10504     oct >>= 4;
10505
10506     proto_tree_add_text(tree,
10507         tvb, curr_offset, 1,
10508         "A&C reference number: 0x%02x (%u)",
10509         oct,
10510         oct);
10511
10512     curr_offset++;
10513
10514     /* no length check possible */
10515
10516     return(curr_offset - offset);
10517 }
10518
10519 /*
10520  * [8] 10.5.5.20
10521  */
10522 static guint8
10523 de_gmm_service_type(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
10524 {
10525     guint8      oct;
10526     guint8      oct_ciph;
10527     guint32     curr_offset;
10528     const gchar *str;
10529     
10530     len = len;
10531     curr_offset = offset;
10532
10533     oct = tvb_get_guint8(tvb, curr_offset);
10534     oct_ciph = oct;
10535     oct_ciph &= 7;
10536
10537     oct = oct >> 4;
10538
10539     switch ( oct&7 )
10540     {
10541         case 0: str="Signalling"; break;
10542         case 1: str="Data"; break;
10543         case 2: str="Paging Response"; break;
10544         case 3: str="MBMS Notification Response"; break;/* reponse->response*/
10545         default: str="reserved";
10546     }
10547
10548     /* The ciphering key sequence number is added here */
10549     proto_tree_add_text(tree,
10550         tvb, curr_offset, 1,
10551         "Ciphering key sequence number: 0x%02x (%u)",
10552         oct_ciph,
10553         oct_ciph);
10554
10555     proto_tree_add_text(tree,
10556         tvb, curr_offset, 1,
10557         "Service Type: (%u) %s",
10558         oct&7,
10559         str);
10560
10561     curr_offset++;
10562
10563     /* no length check possible */
10564
10565     return(curr_offset - offset);
10566 }
10567
10568 /*
10569  * [7] 10.5.5.21
10570  */
10571 static guint8
10572 de_gmm_cell_notfi(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
10573 {
10574     guint32     curr_offset;
10575
10576     len = len;
10577     curr_offset = offset;
10578
10579     proto_tree_add_text(tree,
10580         tvb, curr_offset, 0,
10581         "Cell Notification");
10582
10583     /* no length check possible */
10584
10585     return(curr_offset - offset);
10586 }
10587
10588 /*
10589  * [7] 10.5.5.22
10590  */
10591 static guint8
10592 de_gmm_ps_lcs_cap(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
10593 {
10594     guint8      oct;
10595     guint32     curr_offset;
10596     
10597     gchar       str_otd[2][40]={ "MS assisted E-OTD not supported",
10598                         "MS assisted E-OTD supported" };
10599     gchar       str_gps[2][40]={ "MS assisted GPS not supported",
10600                         "MS assisted GPS supported" };
10601     
10602     len = len;
10603     curr_offset = offset;
10604
10605     oct = tvb_get_guint8(tvb, curr_offset);
10606
10607     oct <<=3;   /* move away the spare bits */
10608
10609     proto_tree_add_text(tree,
10610         tvb, curr_offset, 1,
10611         "OTD-A: (%u) %s",
10612         oct>>7,
10613         str_otd[oct>>7]);
10614     oct <<=1;
10615     proto_tree_add_text(tree,
10616         tvb, curr_offset, 1,
10617         "OTD-B: (%u) %s",
10618         oct>>7,
10619         str_otd[oct>>7]);
10620     oct <<=1;
10621
10622     proto_tree_add_text(tree,
10623         tvb, curr_offset, 1,
10624         "GPS-A: (%u) %s",
10625         oct>>7,
10626         str_gps[oct>>7]);
10627     oct <<=1;
10628     proto_tree_add_text(tree,
10629         tvb, curr_offset, 1,
10630         "GPS-B: (%u) %s",
10631         oct>>7,
10632         str_gps[oct>>7]);
10633     oct <<=1;
10634     proto_tree_add_text(tree,
10635         tvb, curr_offset, 1,
10636         "GPS-C: (%u) %s",
10637         oct>>7,
10638         str_gps[oct>>7]);
10639
10640     curr_offset++;
10641
10642     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
10643
10644     return(curr_offset - offset);
10645 }
10646
10647 /*
10648  * [7] 10.5.5.23
10649  */
10650 static guint8
10651 de_gmm_net_feat_supp(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
10652 {
10653     guint8      oct;
10654     guint32     curr_offset;
10655     const gchar *str;
10656     
10657     len = len;
10658     curr_offset = offset;
10659
10660     oct = tvb_get_guint8(tvb, curr_offset);
10661
10662     switch(oct&8)
10663     {
10664         case 8: str="LCS-MOLR via PS domain not supported"; break;
10665         default: str="LCS-MOLR via PS domain supported";
10666     }
10667
10668     proto_tree_add_text(tree,
10669         tvb, curr_offset, 1,
10670         "Network Feature Support: (%u) %s",
10671         (oct>>3)&1,
10672         str);
10673
10674     curr_offset++;
10675
10676     /* no length check possible */
10677
10678     return(curr_offset - offset);
10679 }
10680
10681 /* [7] 10.5.24 Inter RAT information container */
10682 static guint8
10683 de_gmm_rat_info_container(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
10684 {
10685         guint32 curr_offset;
10686
10687         len = len;
10688     curr_offset = offset;
10689
10690 /* The value part of the Inter RAT information container information element is the INTER RAT HANDOVER INFO as
10691 defined in 3GPP TS 25.331 [23c]. If this field includes padding bits, they are defined in 3GPP TS 25.331 [23c].*/
10692         proto_tree_add_text(tree, tvb, curr_offset, len,"INTER RAT HANDOVER INFO - Not decoded");
10693
10694         return len;
10695
10696 }
10697
10698 /*
10699  * [7] 10.5.7.1
10700  */
10701 static guint8
10702 de_gc_context_stat(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
10703 {
10704     guint8      oct;
10705     guint16     pdp_nr;
10706     guint32     curr_offset;
10707     proto_item  *tf = NULL;
10708     proto_tree      *tf_tree = NULL;
10709
10710     gchar       str[2][20]={ "PDP-INACTIVE", "PDP-ACTIVE" };
10711     
10712     len = len;
10713     curr_offset = offset;
10714
10715     oct = tvb_get_guint8(tvb, curr_offset);
10716
10717     tf = proto_tree_add_text(tree,
10718         tvb, curr_offset, 1,
10719         "PDP Context Status");
10720
10721     tf_tree = proto_item_add_subtree(tf, ett_gmm_context_stat );
10722     
10723     oct = tvb_get_guint8(tvb, curr_offset);
10724
10725     for ( pdp_nr=0;pdp_nr<16; pdp_nr++ )
10726     {
10727             if ( pdp_nr == 8 )
10728             {
10729                 curr_offset++;
10730                 oct = tvb_get_guint8(tvb, curr_offset);
10731             }
10732             proto_tree_add_text(tf_tree,
10733                 tvb, curr_offset, 1,
10734                 "NSAPI %d: (%u) %s",pdp_nr,
10735                 oct&1,
10736                 str[oct&1]);
10737             oct>>=1;
10738     }
10739
10740     curr_offset++;
10741
10742     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
10743
10744     return(curr_offset - offset);
10745 }
10746
10747 /*
10748  * [7] 10.5.7.2
10749  */
10750 static guint8
10751 de_gc_radio_prio(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
10752 {
10753     guint8      oct;
10754     guint32     curr_offset;
10755     const gchar *str;
10756     
10757     len = len;
10758     curr_offset = offset;
10759
10760     oct = tvb_get_guint8(tvb, curr_offset);
10761
10762     switch ( oct&7 )
10763     {
10764         case 1: str="priority level 1 (highest)"; break;
10765         case 2: str="priority level 2"; break;
10766         case 3: str="priority level 3"; break;
10767         case 4: str="priority level 4 (lowest)"; break;
10768         default: str="priority level 4 (lowest)";
10769     }
10770
10771     proto_tree_add_text(tree,
10772         tvb, curr_offset, 1,
10773         "Radio Priority (PDP or SMS): (%u) %s",
10774         oct&7,
10775         str);
10776
10777     curr_offset++;
10778
10779     return(curr_offset - offset);
10780 }
10781
10782 /*
10783  * [7] 10.5.7.3
10784  */
10785 static guint8
10786 de_gc_timer(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
10787 {
10788     guint8      oct;
10789     guint16     val;
10790     guint32     curr_offset;
10791     const gchar *str;
10792     
10793     len = len;
10794     curr_offset = offset;
10795
10796     oct = tvb_get_guint8(tvb, curr_offset);
10797
10798     val = oct&0x1f;
10799
10800     switch(oct>>5)
10801     {
10802         case 0: str="sec"; val*=2; break;
10803         case 1: str="min"; break;
10804         case 2: str="min"; val*=6; break;
10805         case 7:
10806             proto_tree_add_text(tree,
10807                 tvb, curr_offset, 1,
10808                 "GPRS Timer: timer is deactivated");
10809
10810         default: str="min";
10811     }
10812
10813     proto_tree_add_text(tree,
10814         tvb, curr_offset, 1,
10815         "GPRS Timer: (%u) %u %s",
10816         oct, val,
10817         str);
10818
10819     curr_offset++;
10820
10821     /* no length check possible */
10822
10823     return(curr_offset - offset);
10824 }
10825
10826 /*
10827  * [7] 10.5.7.4
10828  */
10829 static guint8
10830 de_gc_timer2(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len _U_)
10831 {
10832     guint8      oct;
10833     guint16     val;
10834     guint32     curr_offset;
10835     const gchar *str;
10836     
10837     len = len;
10838     curr_offset = offset;
10839
10840     oct = tvb_get_guint8(tvb, curr_offset);
10841
10842     val = oct&0x1f;
10843
10844     switch(oct>>5)
10845     {
10846         case 0: str="sec"; val*=2; break;
10847         case 1: str="min"; break;
10848         case 2: str="min"; val*=6; break;
10849         case 7:
10850             proto_tree_add_text(tree,
10851                 tvb, curr_offset, 1,
10852                 "GPRS Timer: timer is deactivated");
10853
10854         default: str="min";
10855     }
10856
10857     proto_tree_add_text(tree,
10858         tvb, curr_offset, 1,
10859         "GPRS Timer: (%u) %u %s %s",
10860         oct, val,
10861         str, add_string ? add_string : "");
10862
10863     curr_offset++;
10864
10865     return(curr_offset - offset);
10866 }
10867
10868
10869 /*
10870  * [7] 10.5.7.5
10871  */
10872 static guint8
10873 de_gc_radio_prio2(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
10874 {
10875     guint8      oct;
10876     guint32     curr_offset;
10877     const gchar *str;
10878     
10879     len = len;
10880     curr_offset = offset;
10881
10882     oct = tvb_get_guint8(tvb, curr_offset);
10883
10884     /* IMPORTANT - IT'S ASSUMED THAT THE INFORMATION IS IN THE HIGHER NIBBLE */
10885     oct >>= 4;
10886
10887     switch ( oct&7 )
10888     {
10889         case 1: str="priority level 1 (highest)"; break;
10890         case 2: str="priority level 2"; break;
10891         case 3: str="priority level 3"; break;
10892         case 4: str="priority level 4 (lowest)"; break;
10893         default: str="priority level 4 (lowest)";
10894     }
10895
10896     proto_tree_add_text(tree,
10897         tvb, curr_offset, 1,
10898         "Radio Priority (TOM8): (%u) %s",
10899         oct&7,
10900         str);
10901
10902     curr_offset++;
10903
10904     return(curr_offset - offset);
10905 }
10906
10907 /*
10908  * [8] 10.5.7.6 MBMS context status
10909  */
10910 static guint8
10911 de_gc_mbms_context_stat(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
10912 {
10913     guint32     curr_offset;
10914     
10915     len = len;
10916     curr_offset = offset;
10917  
10918         proto_tree_add_text(tree,tvb, curr_offset, len, "MBMS context status - Not decoded");
10919
10920     return(len);
10921 }
10922 /*
10923  * [7] 10.5.6.1
10924  */
10925 #define MAX_APN_LENGTH          50
10926
10927 guint8
10928 de_sm_apn(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len _U_)
10929 {
10930     guint32     curr_offset;
10931     guint       curr_len;
10932     const guint8        *cptr;
10933     guint8      str[MAX_APN_LENGTH+1];
10934
10935     cptr = tvb_get_ptr(tvb, offset, len);
10936
10937     
10938     curr_offset = offset;
10939
10940     /* init buffer and copy it */
10941     memset ( str , 0 , MAX_APN_LENGTH );
10942     memcpy ( str , cptr , len<MAX_APN_LENGTH?len:MAX_APN_LENGTH );
10943
10944     curr_len = 0;
10945     while (( curr_len < len ) && ( curr_len < MAX_APN_LENGTH ))
10946     {
10947         guint step = str[curr_len];
10948         str[curr_len]='.';
10949         curr_len += step+1;
10950     }
10951     
10952     proto_tree_add_text(tree,
10953         tvb, curr_offset, len,
10954         "APN: %s %s", str+1 , add_string ? add_string : "");
10955
10956     curr_offset+= len;
10957
10958     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
10959
10960     return(curr_offset - offset);
10961 }
10962
10963 /*
10964  * [7] 10.5.6.2
10965  */
10966 static guint8
10967 de_sm_nsapi(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len _U_)
10968 {
10969     guint8      oct;
10970     guint32     curr_offset;
10971     
10972     len = len;
10973     curr_offset = offset;
10974
10975     oct = tvb_get_guint8(tvb, curr_offset);
10976
10977     proto_tree_add_text(tree,
10978         tvb, curr_offset, 1,
10979         "NSAPI: 0x%02x (%u) %s",
10980         oct&0x0f, oct&0x0f,add_string ? add_string : "");
10981
10982     curr_offset++;
10983
10984     return(curr_offset - offset);
10985 }
10986
10987 /*
10988  * [7] 10.5.6.3
10989  */
10990 static guint8
10991 de_sm_pco(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
10992 {
10993     guint32     curr_offset;
10994     guint       curr_len;
10995     guchar      oct;
10996     struct e_in6_addr ipv6_addr;
10997     
10998     curr_len = len;
10999     curr_offset = offset;
11000
11001     oct = tvb_get_guint8(tvb, curr_offset);
11002     curr_len--;
11003     curr_offset++;
11004
11005     proto_tree_add_text(tree,tvb, curr_offset, 1, "Ext: 0x%02x (%u)",oct>>7,oct>>7);
11006     proto_tree_add_text(tree,tvb, curr_offset, 1, "Configuration Protocol: PPP (%u)",oct&0x0f);
11007
11008     while ( curr_len > 0 )
11009     {
11010         guchar e_len;
11011         guint16 prot;
11012         tvbuff_t *l3_tvb;
11013         dissector_handle_t handle = NULL;
11014         static packet_info p_info;
11015         
11016         prot = tvb_get_guint8(tvb, curr_offset);
11017         prot <<= 8;
11018         prot |= tvb_get_guint8(tvb, curr_offset+1);
11019         e_len = tvb_get_guint8(tvb, curr_offset+2);
11020         curr_len-=3;
11021         curr_offset+=3;
11022
11023         switch ( prot )
11024         {
11025                 case 0x0001:
11026                 {
11027                     proto_tree_add_text(tree,tvb, curr_offset-3, 2, "Parameter: (%u) P-CSCF Address" , prot );
11028                     proto_tree_add_text(tree,tvb, curr_offset-1, 1, "Length: 0x%02x (%u)", e_len , e_len);
11029
11030                     tvb_get_ipv6(tvb, curr_offset, &ipv6_addr);
11031                     proto_tree_add_text(tree,
11032                         tvb, curr_offset, 16,
11033                         "IPv6: %s", ip6_to_str(&ipv6_addr));
11034                     break;
11035                 }
11036                 case 0x0002:
11037                     proto_tree_add_text(tree,tvb, curr_offset-3, 2, "Parameter: (%u) IM CN Subsystem Signaling Flag" , prot );
11038                     proto_tree_add_text(tree,tvb, curr_offset-1, 1, "Length: 0x%02x (%u)", e_len , e_len);
11039                     break;
11040                 case 0x0003:
11041                 {
11042                     proto_tree_add_text(tree,tvb, curr_offset-3, 2, "Parameter: (%u) DNS Server Address" , prot );
11043                     proto_tree_add_text(tree,tvb, curr_offset-1, 1, "Length: 0x%02x (%u)", e_len , e_len);
11044
11045                     tvb_get_ipv6(tvb, curr_offset, &ipv6_addr);
11046                     proto_tree_add_text(tree,
11047                         tvb, curr_offset, 16,
11048                         "IPv6: %s", ip6_to_str(&ipv6_addr));
11049                     break;
11050                 }
11051                 case 0x0004:
11052                     proto_tree_add_text(tree,tvb, curr_offset-3, 2, "Parameter: (%u) Policy Control rejection code" , prot );
11053                     proto_tree_add_text(tree,tvb, curr_offset-1, 1, "Length: 0x%02x (%u)", e_len , e_len);
11054                     oct = tvb_get_guint8(tvb, curr_offset);
11055                     proto_tree_add_text(tree,tvb, curr_offset, 1, "Reject Code: 0x%02x (%u)", e_len , e_len);
11056                     break;
11057                 default:
11058                         handle = dissector_get_port_handle ( gprs_sm_pco_subdissector_table , prot );
11059                         if ( handle != NULL )
11060                         {
11061                                 proto_tree_add_text(tree,tvb, curr_offset-3, 2, "Protocol: (%u) %s" , 
11062                                         prot , val_to_str(prot, ppp_vals, "Unknown"));
11063                                 proto_tree_add_text(tree,tvb, curr_offset-1, 1, "Length: 0x%02x (%u)", e_len , e_len);
11064                                 /*
11065                                  * dissect the embedded message
11066                                  */
11067                                 l3_tvb = tvb_new_subset(tvb, curr_offset, e_len, e_len);
11068                                 call_dissector(handle, l3_tvb ,  &p_info  , tree );
11069                         }
11070                         else
11071                         {
11072                                 proto_tree_add_text(tree,tvb, curr_offset-3, 2, "Protocol/Parameter: (%u) unknwown" , prot );
11073                                 proto_tree_add_text(tree,tvb, curr_offset-1, 1, "Length: 0x%02x (%u)", e_len , e_len);
11074                                 /*
11075                                 * dissect the embedded DATA message
11076                                 */
11077                                 l3_tvb = tvb_new_subset(tvb, curr_offset, e_len, e_len);
11078                                 call_dissector(data_handle, l3_tvb, &p_info , tree);
11079                         }
11080         }
11081
11082         curr_len-= e_len;
11083         curr_offset+= e_len;
11084     }    
11085     curr_offset+= curr_len;        
11086                    
11087     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11088
11089     return(curr_offset - offset);
11090 }
11091
11092 /*
11093  * [7] 10.5.6.4
11094  */
11095 static guint8
11096 de_sm_pdp_addr(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
11097 {
11098     guint32     curr_offset;
11099     guint       curr_len;
11100     const gchar *str;
11101     guchar      oct;
11102     guchar      oct2;
11103     struct e_in6_addr ipv6_addr;
11104
11105     curr_len = len;
11106     curr_offset = offset;
11107
11108     oct = tvb_get_guint8(tvb, curr_offset);
11109
11110     switch ( oct&0x0f )
11111     {
11112         case 0x00: str="ETSI allocated address"; break;
11113         case 0x01: str="IETF allocated address"; break;
11114         case 0x0f: str="Empty PDP type";
11115         default: str="reserved";
11116     }
11117
11118     proto_tree_add_text(tree,
11119         tvb, curr_offset, 1,
11120         "PDP type organisation: (%u) %s",oct&0x0f,str);
11121
11122     oct2 = tvb_get_guint8(tvb, curr_offset+1);
11123
11124     if (( oct&0x0f ) == 0 )
11125     {
11126             switch ( oct2 )
11127             {
11128                 case 0x00: str="Reserved, used in earlier version of this protocol"; break;
11129                 case 0x01: str="PDP-type PPP"; break;
11130                 default: str="reserved";
11131             }
11132     }
11133     else if (( oct&0x0f) == 1 )
11134     {
11135             switch ( oct2 )
11136             {
11137                 case 0x21: str="IPv4 address"; break;
11138                 case 0x57: str="IPv6 address"; break;
11139                 default: str="IPv4 address";
11140             }
11141     }
11142     else if ((oct2==0) && (( oct&0x0f) == 0x0f ))    
11143             str="Empty"; 
11144     else
11145             str="Not specified";        
11146     
11147     proto_tree_add_text(tree,
11148         tvb, curr_offset+1, 1,
11149         "PDP type number: (%u) %s",oct2,str);
11150
11151     if (( len == 2 ) && (( oct2 == 0x21 ) || ( oct2 == 0x57 )))
11152     {
11153             proto_tree_add_text(tree,
11154                 tvb, curr_offset+1, 1,
11155                 "Dynamic addressing");
11156         
11157             curr_offset+= curr_len;        
11158
11159             EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11160
11161            return(curr_offset - offset);
11162     }
11163     else if ( len == 2 )
11164     {
11165             proto_tree_add_text(tree,
11166                 tvb, curr_offset+1, 1,
11167                 "No PDP address is included");
11168         
11169             curr_offset+= curr_len;        
11170
11171             EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11172
11173            return(curr_offset - offset);
11174     }
11175     else if ( len < 2 )
11176     {
11177             proto_tree_add_text(tree,
11178                 tvb, curr_offset+1, 1,
11179                 "Length is bogus - should be >= 2");
11180         
11181             curr_offset+= curr_len;        
11182
11183             EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11184
11185            return(curr_offset - offset);
11186     }
11187
11188     if ((( oct2 == 0x21 ) && ( len != 6 )) ||
11189        (( oct2 == 0x57 ) && ( len != 18 )))
11190     {
11191             proto_tree_add_text(tree,
11192                 tvb, curr_offset+2, len-2,
11193                 "Can't display address");
11194     }
11195
11196
11197     switch ( oct2 )
11198     {
11199         case 0x21:
11200             if (len-2 != 4) {
11201                 proto_tree_add_text(tree,
11202                     tvb, curr_offset+2, 0,
11203                     "IPv4: length is wrong");
11204             } else {
11205                 proto_tree_add_text(tree,
11206                     tvb, curr_offset+2, len-2,
11207                     "IPv4: %s", ip_to_str(tvb_get_ptr(tvb, offset+2, 4)));
11208             }
11209             break;
11210
11211         case 0x57:
11212             if (len-2 != 16) {
11213                 proto_tree_add_text(tree,
11214                     tvb, curr_offset+2, 0,
11215                     "IPv6: length is wrong");
11216             } else {
11217                 tvb_get_ipv6(tvb, curr_offset+2, &ipv6_addr);
11218                 proto_tree_add_text(tree,
11219                     tvb, curr_offset+2, len-2,
11220                     "IPv6: %s", ip6_to_str(&ipv6_addr));
11221             }
11222             break;
11223     }
11224     
11225     curr_offset+= curr_len;        
11226                    
11227     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11228
11229     return(curr_offset - offset);
11230 }
11231
11232 /*
11233  * [7] 10.5.6.5
11234  */
11235  /* Delivery of erroneous SDUs, octet 6 (see 3GPP TS 23.107) Bits 3 2 1 */
11236 const value_string gsm_a_qos_del_of_err_sdu_vals[] = {
11237         { 0, "Subscribed delivery of erroneous SDUs/Reserved" },
11238         { 1, "No detect('-')" },
11239         { 2, "Erroneous SDUs are delivered('yes')" },
11240         { 3, "Erroneous SDUs are not delivered('No')" },
11241         { 7, "Reserved" },
11242         { 0, NULL }
11243 };
11244
11245  /* Delivery order, octet 6 (see 3GPP TS 23.107) Bits 5 4 3 */
11246 const value_string gsm_a_qos_del_order_vals[] = {
11247         { 0, "Subscribed delivery order/Reserved" },
11248         { 1, "With delivery order ('yes')" },
11249         { 2, "Without delivery order ('no')" },
11250         { 3, "Reserved" },
11251         { 0, NULL }
11252 };
11253 /* Traffic class, octet 6 (see 3GPP TS 23.107) Bits 8 7 6 */
11254 const value_string gsm_a_qos_traffic_cls_vals[] = {
11255         { 0, "Subscribed traffic class/Reserved" },
11256         { 1, "Conversational class" },
11257         { 2, "Streaming class" },
11258         { 3, "Interactive class" },
11259         { 4, "Background class" },
11260         { 7, "Reserved" },
11261         { 0, NULL }
11262 };
11263
11264 /* Residual Bit Error Rate (BER), octet 10 (see 3GPP TS 23.107) Bits 8 7 6 5 */
11265 const value_string gsm_a_qos_ber_vals[] = {
11266         { 0, "Subscribed residual BER/Reserved" },
11267         { 1, "5*10-2" },
11268         { 2, "1*10-2" },
11269         { 3, "5*10-3" },
11270         { 4, "4*10-3" },
11271         { 5, "1*10-3" },
11272         { 6, "1*10-4" },
11273         { 7, "1*10-5" },
11274         { 8, "1*10-6" },
11275         { 9, "6*10-8" },
11276         { 10, "Reserved" },
11277         { 0, NULL }
11278 };
11279
11280 /* SDU error ratio, octet 10 (see 3GPP TS 23.107) Bits 4 3 2 1 */
11281 const value_string gsm_a_qos_sdu_err_rat_vals[] = {
11282         { 0, "Subscribed SDU error ratio/Reserved" },
11283         { 1, "1*10-2" },
11284         { 2, "7*10-3" },
11285         { 3, "1*10-3" },
11286         { 4, "1*10-4" },
11287         { 5, "1*10-5" },
11288         { 6, "1*10-6" },
11289         { 7, "1*10-1" },
11290         { 15, "Reserved" },
11291         { 0, NULL }
11292 };
11293
11294 /* Traffic handling priority, octet 11 (see 3GPP TS 23.107) Bits 2 1 */
11295 const value_string gsm_a_qos_traff_hdl_pri_vals[] = {
11296         { 0, "Subscribed traffic handling priority/Reserved" },
11297         { 1, "Priority level 1" },
11298         { 2, "Priority level 2" },
11299         { 3, "Priority level 3" },
11300         { 0, NULL }
11301 };
11302
11303  guint8
11304 de_sm_qos(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
11305 {
11306     guint32     curr_offset;
11307     guint       curr_len;
11308     guchar       oct, tmp_oct;
11309     const gchar *str;
11310     
11311     curr_len = len;
11312     curr_offset = offset;
11313
11314     oct = tvb_get_guint8(tvb, curr_offset);
11315
11316     switch ( (oct>>3)&7 )
11317     {
11318         case 0x00: str="Subscribed delay class/reserved"; break;
11319         case 0x01: str="Delay class 1"; break;
11320         case 0x02: str="Delay class 2"; break;
11321         case 0x03: str="Delay class 3"; break;
11322         case 0x04: str="Delay class 4 (best effort)"; break;
11323         case 0x07: str="Reserved"; break;
11324         default: str="Delay class 4 (best effort)";
11325     }
11326
11327     proto_tree_add_text(tree,
11328         tvb, curr_offset, 1,
11329         "Delay class: (%u) %s",(oct>>3)&7,str);
11330
11331     switch ( oct&0x7 )
11332     {
11333         case 0x00: str="Subscribed reliability class/reserved"; break;
11334         case 0x01: str="Acknowledged GTP, LLC, and RLC; Protected data"; break;
11335         case 0x02: str="Unacknowledged GTP; Acknowledged LLC and RLC, Protected data"; break;
11336         case 0x03: str="Unacknowledged GTP and LLC; Acknowledged RLC, Protected data"; break;
11337         case 0x04: str="Unacknowledged GTP, LLC, and RLC, Protected data"; break;
11338         case 0x05: str="Unacknowledged GTP, LLC, and RLC, Unprotected data"; break;
11339         case 0x07: str="Reserved"; break;
11340         default: str="Unacknowledged GTP and LLC; Acknowledged RLC, Protected data";
11341     }
11342
11343     proto_tree_add_text(tree,
11344         tvb, curr_offset, 1,
11345         "Reliability class: (%u) %s",oct&7,str);
11346
11347     curr_offset+= 1;       
11348     curr_len-= 1;
11349     
11350     if ( curr_len == 0 )
11351     {
11352             EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11353
11354             return(curr_offset - offset);
11355     }
11356
11357     oct = tvb_get_guint8(tvb, curr_offset);
11358
11359     switch ( oct>>4 )
11360     {
11361         case 0x00: str="Subscribed peak throughput/reserved"; break;
11362         case 0x01: str="Up to 1 000 octet/s"; break;
11363         case 0x02: str="Up to 2 000 octet/s"; break;
11364         case 0x03: str="Up to 4 000 octet/s"; break;
11365         case 0x04: str="Up to 8 000 octet/s"; break;
11366         case 0x05: str="Up to 16 000 octet/s"; break;
11367         case 0x06: str="Up to 32 000 octet/s"; break;
11368         case 0x07: str="Up to 64 000 octet/s"; break;
11369         case 0x08: str="Up to 128 000 octet/s"; break;
11370         case 0x09: str="Up to 256 000 octet/s"; break;
11371         case 0x0f: str="Reserved"; break;
11372         default: str="Up to 1 000 octet/s";
11373     }
11374
11375     proto_tree_add_text(tree,
11376         tvb, curr_offset, 1,
11377         "Peak throughput: (%u) %s",oct>>4,str);
11378
11379     switch ( oct&0x7 )
11380     {
11381         case 0x00: str="Subscribed precedence/reserved"; break;
11382         case 0x01: str="High priority"; break;
11383         case 0x02: str="Normal priority"; break;
11384         case 0x03: str="Low priority"; break;
11385         case 0x07: str="Reserved"; break;
11386         default: str="Normal priority";
11387     }
11388
11389     proto_tree_add_text(tree,
11390         tvb, curr_offset, 1,
11391         "Precedence class: (%u) %s",oct&7,str);
11392
11393     curr_offset+= 1;       
11394     curr_len-= 1;
11395     
11396     if ( curr_len == 0 )
11397     {
11398             EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11399
11400             return(curr_offset - offset);
11401     }
11402
11403     oct = tvb_get_guint8(tvb, curr_offset);
11404
11405     switch ( oct&0x1f )
11406     {
11407         case 0x00: str="Subscribed peak throughput/reserved"; break;
11408         case 0x01: str="100 octet/h"; break;
11409         case 0x02: str="200 octet/h"; break;
11410         case 0x03: str="500 octet/h"; break;
11411         case 0x04: str="1 000 octet/h"; break;
11412         case 0x05: str="2 000 octet/h"; break;
11413         case 0x06: str="5 000 octet/h"; break;
11414         case 0x07: str="10 000 octet/h"; break;
11415         case 0x08: str="20 000 octet/h"; break;
11416         case 0x09: str="50 000 octet/h"; break;
11417         case 0x0a: str="100 000 octet/h"; break;
11418         case 0x0b: str="200 000 octet/h"; break;
11419         case 0x0c: str="500 000 octet/h"; break;
11420         case 0x0d: str="1 000 000 octet/h"; break;
11421         case 0x0e: str="2 000 000 octet/h"; break;
11422         case 0x0f: str="5 000 000 octet/h"; break;
11423         case 0x10: str="10 000 000 octet/h"; break;
11424         case 0x11: str="20 000 000 octet/h"; break;
11425         case 0x12: str="50 000 000 octet/h"; break;
11426         case 0x1e: str="Reserved"; break;
11427         case 0x1f: str="Best effort"; break;
11428         default: str="Best effort";
11429     }
11430
11431     proto_tree_add_text(tree,
11432         tvb, curr_offset, 1,
11433         "Mean throughput: (%u) %s",oct&0x1f,str);
11434
11435     curr_offset+= 1;       
11436     curr_len-= 1;
11437     
11438     if ( curr_len == 0 )
11439     {
11440             EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11441
11442             return(curr_offset - offset);
11443     }
11444
11445     proto_tree_add_item(tree, hf_gsm_a_qos_traffic_cls, tvb, curr_offset, 1, FALSE);
11446         proto_tree_add_item(tree, hf_gsm_a_qos_del_order, tvb, curr_offset, 1, FALSE);
11447     proto_tree_add_item(tree, hf_gsm_a_qos_del_of_err_sdu, tvb, curr_offset, 1, FALSE);
11448
11449     curr_offset+= 1;       
11450     curr_len-= 1;
11451     
11452     if ( curr_len == 0 )
11453     {
11454             EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11455
11456             return(curr_offset - offset);
11457     }
11458
11459     oct = tvb_get_guint8(tvb, curr_offset);
11460
11461     switch ( oct )
11462     {
11463         case 0x00: str="Subscribed maximum SDU size/reserved"; break;
11464         case 0x97: str="1502 octets"; break;
11465         case 0x98: str="1510 octets"; break;
11466         case 0x99: str="1520 octets"; break;
11467         case 0xff: str="Reserved"; break;
11468         default: str="Unspecified";
11469     }
11470
11471     if (( oct >= 1 ) && ( oct <= 0x96 ))
11472             proto_tree_add_text(tree,
11473                 tvb, curr_offset, 1,
11474                 "Maximum SDU size: (%u) %u octets",oct,oct*10);
11475     else
11476             proto_tree_add_text(tree,
11477                 tvb, curr_offset, 1,
11478                 "Maximum SDU size: (%u) %s",oct,str);
11479
11480     curr_offset+= 1;       
11481     curr_len-= 1;
11482     
11483     if ( curr_len == 0 )
11484     {
11485             EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11486
11487             return(curr_offset - offset);
11488     }
11489
11490     oct = tvb_get_guint8(tvb, curr_offset);
11491
11492     switch ( oct )
11493     {
11494         case 0x00: str="Subscribed maximum bit rate for uplink/reserved"; break;
11495         case 0xff: str="0kbps"; break;
11496         default: str="This should not happen - BUG";
11497     }
11498
11499     if (( oct >= 1 ) && ( oct <= 0x3f ))
11500             proto_tree_add_text(tree,
11501                 tvb, curr_offset, 1,
11502                 "Maximum bit rate for uplink: (%u) %ukbps",oct,oct);
11503     else if (( oct >= 0x40 ) && ( oct <= 0x7f ))
11504             proto_tree_add_text(tree,
11505                 tvb, curr_offset, 1,
11506                 "Maximum bit rate for uplink: (%u) %ukbps",oct,(oct-0x40)*8+64); /* - was (oct-0x40)*8  */
11507     else if (( oct >= 0x80 ) && ( oct <= 0xfe ))
11508             proto_tree_add_text(tree,
11509                 tvb, curr_offset, 1,
11510                 "Maximum bit rate for uplink: (%u) %ukbps",oct,(oct-0x80)*64+576); /* - was (oct-0x80)*64 */
11511     else
11512             proto_tree_add_text(tree,
11513                 tvb, curr_offset, 1,
11514                 "Maximum bit rate for uplink: (%u) %s",oct,str);
11515
11516     curr_offset+= 1;       
11517     curr_len-= 1;
11518     
11519     if ( curr_len == 0 )
11520     {
11521             EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11522
11523             return(curr_offset - offset);
11524     }
11525
11526     oct = tvb_get_guint8(tvb, curr_offset);
11527
11528     switch ( oct )
11529     {
11530         case 0x00: str="Subscribed maximum bit rate for uplink/reserved"; break;
11531         case 0xff: str="0kbps"; break;
11532         default: str="This should not happen - BUG";
11533     }
11534
11535     if (( oct >= 1 ) && ( oct <= 0x3f ))
11536             proto_tree_add_text(tree,
11537                 tvb, curr_offset, 1,
11538                 "Maximum bit rate for downlink: (%u) %ukbps",oct,oct);
11539     else if (( oct >= 0x40 ) && ( oct <= 0x7f ))
11540             proto_tree_add_text(tree,
11541                 tvb, curr_offset, 1,
11542                 "Maximum bit rate for downlink: (%u) %ukbps",oct,(oct-0x40)*8+64);/*same as above*/
11543     else if (( oct >= 0x80 ) && ( oct <= 0xfe ))
11544             proto_tree_add_text(tree,
11545                 tvb, curr_offset, 1,
11546                 "Maximum bit rate for downlink: (%u) %ukbps",oct,(oct-0x80)*64+576);/*same as above*/
11547     else
11548             proto_tree_add_text(tree,
11549                 tvb, curr_offset, 1,
11550                 "Maximum bit rate for downlink: (%u) %s",oct,str);
11551
11552     curr_offset+= 1;       
11553     curr_len-= 1;
11554     
11555     if ( curr_len == 0 )
11556     {
11557             EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11558
11559             return(curr_offset - offset);
11560     }
11561
11562     proto_tree_add_item(tree, hf_gsm_a_qos_ber, tvb, curr_offset, 1, FALSE);
11563         proto_tree_add_item(tree, hf_gsm_a_qos_sdu_err_rat, tvb, curr_offset, 1, FALSE);
11564
11565     curr_offset+= 1;       
11566     curr_len-= 1;
11567     
11568     if ( curr_len == 0 )
11569     {
11570             EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11571
11572             return(curr_offset - offset);
11573     }
11574
11575     oct = tvb_get_guint8(tvb, curr_offset);
11576
11577     switch ( oct>>2 )
11578     {
11579         case 0x00: str="Subscribed transfer delay/reserved"; break;
11580         case 0x3f: str="Reserved"; break;
11581         default: str="This should not happen - BUG";
11582     }
11583
11584     tmp_oct = oct>>2;
11585
11586     if (( tmp_oct >= 1 ) && ( tmp_oct <= 0x0f ))
11587             proto_tree_add_text(tree,
11588                 tvb, curr_offset, 1,
11589                 "Transfer Delay: (%u) %ums",oct>>2,(oct>>2)*10);
11590     else if (( tmp_oct >= 0x10 ) && ( tmp_oct <= 0x1f ))
11591             proto_tree_add_text(tree,
11592                 tvb, curr_offset, 1,
11593                 "Transfer Delay: (%u) %ums",oct>>2,((oct>>2)-0x10)*50+200);
11594     else if (( tmp_oct >= 0x20 ) && ( tmp_oct <= 0x3e ))
11595             proto_tree_add_text(tree,
11596                 tvb, curr_offset, 1,
11597                 "Transfer Delay: (%u) %ums",oct>>2,((oct>>2)-0x20)*100+1000);
11598     else
11599             proto_tree_add_text(tree,
11600                 tvb, curr_offset, 1,
11601                 "Transfer Delay: (%u) %s",oct>>2,str);
11602
11603     switch ( oct&0x03 )
11604     {
11605         case 0x00: str="Subscribed traffic handling priority/reserved"; break;
11606         case 0x01: str="Priority level 1"; break;
11607         case 0x02: str="Priority level 2"; break;
11608         case 0x03: str="Priority level 3"; break;
11609         default: str="This should not happen - BUG";
11610     }
11611
11612     proto_tree_add_text(tree,
11613         tvb, curr_offset, 1,
11614         "Traffic Handling priority: (%u) %s",oct&0x03,str);
11615
11616     curr_offset+= 1;       
11617     curr_len-= 1;
11618     
11619     if ( curr_len == 0 )
11620     {
11621             EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11622
11623             return(curr_offset - offset);
11624     }
11625
11626     oct = tvb_get_guint8(tvb, curr_offset);
11627
11628     switch ( oct )
11629     {
11630         case 0x00: str="Subscribed guaranteed bit rate for uplink/reserved"; break;
11631         case 0xff: str="0kbps"; break;
11632         default: str="This should not happen - BUG";
11633     }
11634
11635     if (( oct >= 1 ) && ( oct <= 0x3f ))
11636             proto_tree_add_text(tree,
11637                 tvb, curr_offset, 1,
11638                 "Guaranteed bit rate for uplink: (%u) %ukbps",oct,oct);
11639     else if (( oct >= 0x40 ) && ( oct <= 0x7f ))
11640             proto_tree_add_text(tree,
11641                 tvb, curr_offset, 1,
11642                 "Guaranteed bit rate for uplink: (%u) %ukbps",oct,(oct-0x40)*8+64);/*same as for max bit rate*/
11643     else if (( oct >= 0x80 ) && ( oct <= 0xfe ))
11644             proto_tree_add_text(tree,
11645                 tvb, curr_offset, 1,
11646                 "Guaranteed bit rate for uplink: (%u) %ukbps",oct,(oct-0x80)*64+576);/*same as for max bit rate*/
11647     else
11648             proto_tree_add_text(tree,
11649                 tvb, curr_offset, 1,
11650                 "Guaranteed bit rate for uplink: (%u) %s",oct,str);
11651
11652     curr_offset+= 1;       
11653     curr_len-= 1;
11654     
11655     if ( curr_len == 0 )
11656     {
11657             EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11658
11659             return(curr_offset - offset);
11660     }
11661
11662     oct = tvb_get_guint8(tvb, curr_offset);
11663
11664     switch ( oct )
11665     {
11666         case 0x00: str="Subscribed guaranteed bit rate for uplink/reserved"; break;
11667         case 0xff: str="0kbps"; break;
11668         default: str="This should not happen - BUG";
11669     }
11670
11671     if (( oct >= 1 ) && ( oct <= 0x3f ))
11672             proto_tree_add_text(tree,
11673                 tvb, curr_offset, 1,
11674                 "Guaranteed bit rate for downlink: (%u) %ukbps",oct,oct);
11675     else if (( oct >= 0x40 ) && ( oct <= 0x7f ))
11676             proto_tree_add_text(tree,
11677                 tvb, curr_offset, 1,
11678                 "Guaranteed bit rate for downlink: (%u) %ukbps",oct,(oct-0x40)*8+64);/*same as above*/
11679     else if (( oct >= 0x80 ) && ( oct <= 0xfe ))
11680             proto_tree_add_text(tree,
11681                 tvb, curr_offset, 1,
11682                 "Guaranteed bit rate for downlink: (%u) %ukbps",oct,(oct-0x80)*64+576);/*same as above*/
11683     else
11684             proto_tree_add_text(tree,
11685                 tvb, curr_offset, 1,
11686                 "Guaranteed bit rate for downlink: (%u) %s",oct,str);
11687
11688     curr_offset+= 1;       
11689     curr_len-= 1;
11690     
11691     if ( curr_len == 0 )
11692     {
11693             EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11694
11695             return(curr_offset - offset);
11696     }
11697
11698     oct = tvb_get_guint8(tvb, curr_offset);
11699
11700     switch ( (oct>>4)&1 )
11701     {
11702         case 0x00: str="Not optimised for signalling traffic"; break;
11703         case 0x01: str="Optimised for signalling traffic"; break;
11704         default: str="This should not happen - BUG";
11705     }
11706
11707     proto_tree_add_text(tree,
11708         tvb, curr_offset, 1,
11709         "Signalling Indication: (%u) %s",(oct>>4)&1,str);
11710
11711     switch ( oct&7 )
11712     {
11713         case 0x00: str="unknown"; break;
11714         case 0x01: str="speech"; break;
11715         default: str="unknown";
11716     }
11717
11718     proto_tree_add_text(tree,
11719         tvb, curr_offset, 1,
11720         "Source Statistics Descriptor: (%u) %s",oct&7,str);
11721
11722     curr_offset+= 1;       
11723     curr_len-= 1;
11724     
11725     if ( curr_len == 0 )
11726     {
11727             EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11728
11729             return(curr_offset - offset);
11730     }
11731
11732
11733     oct = tvb_get_guint8(tvb, curr_offset);
11734
11735     switch ( oct )
11736     {
11737         case 0x00: str="Use the value indicated by the Maximum bit rate for downlink"; break;
11738         default: str="Unspecified";
11739     }
11740
11741     if (( oct >= 1 ) && ( oct <= 0x3f ))
11742             proto_tree_add_text(tree,
11743                 tvb, curr_offset, 1,
11744                 "Maximum bit rate for downlink (extended): (%u) %ukbps",oct,oct*100);
11745     else
11746             proto_tree_add_text(tree,
11747                 tvb, curr_offset, 1,
11748                 "Maximum bit rate for downlink (extended): (%u) %s",oct,str);
11749
11750     curr_offset+= 1;       
11751     curr_len-= 1;
11752     
11753     if ( curr_len == 0 )
11754     {
11755             EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11756
11757             return(curr_offset - offset);
11758     }
11759
11760     oct = tvb_get_guint8(tvb, curr_offset);
11761
11762     switch ( oct )
11763     {
11764         case 0x00: str="Use the value indicated by the Guaranteed bit rate for downlink"; break;
11765         default: str="Unspecified";
11766     }
11767
11768     if (( oct >= 1 ) && ( oct <= 0x4a ))
11769             proto_tree_add_text(tree,
11770                 tvb, curr_offset, 1,
11771                 "Guaranteed bit rate for downlink (extended): (%u) %ukbps",oct,oct*100);
11772     else
11773             proto_tree_add_text(tree,
11774                 tvb, curr_offset, 1,
11775                 "Guaranteed bit rate for downlink (extended): (%u) %s",oct,str);
11776
11777     curr_offset+= 1;       
11778     curr_len-= 1;
11779     
11780     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11781
11782     return(curr_offset - offset);
11783 }
11784
11785 /*
11786  * [8] 10.5.6.6 SM cause
11787  */
11788 static guint8
11789 de_sm_cause(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len _U_)
11790 {
11791     guint8      oct;
11792     guint32     curr_offset;
11793     const gchar *str;
11794     
11795     len = len;
11796     curr_offset = offset;
11797
11798     oct = tvb_get_guint8(tvb, curr_offset);
11799
11800     switch ( oct )
11801     {
11802         case 0x08: str="Operator Determined Barring"; break;
11803         case 0x18: str="MBMS bearer capabilities insufficient for the service"; break;
11804         case 0x19: str="LLC or SNDCP failure(GSM only)"; break;
11805         case 0x1a: str="Insufficient resources"; break;
11806         case 0x1b: str="Missing or unknown APN"; break;
11807         case 0x1c: str="Unknown PDP address or PDP type"; break;
11808         case 0x1d: str="User Aauthentication failed"; break;
11809         case 0x1e: str="Activation rejected by GGSN"; break;
11810         case 0x1f: str="Activation rejected, unspecified"; break;
11811         case 0x20: str="Service option not supported"; break;
11812         case 0x21: str="Requested service option not subscribed"; break;
11813         case 0x22: str="Service option temporarily out of order"; break;
11814         case 0x23: str="NSAPI already used (not sent)"; break;
11815         case 0x24: str="Regular deactivation"; break;
11816         case 0x25: str="QoS not accepted"; break;
11817         case 0x26: str="Network failure"; break;
11818         case 0x27: str="Reactivation required"; break;
11819         case 0x28: str="Feature not supported"; break;
11820         case 0x29: str="Semantic error in the TFT operation"; break;
11821         case 0x2a: str="Syntactical error in the TFT operation"; break;
11822         case 0x2b: str="Unknown PDP context"; break;
11823         case 0x2e: str="PDP context without TFT already activated"; break;
11824         case 0x2f: str="Multicast group membership time-out"; break;
11825         case 0x2c: str="Semantic errors in packet filter(s)"; break;
11826         case 0x2d: str="Syntactical errors in packet filter(s)"; break;
11827         case 0x51: str="Invalid transaction identifier value"; break;
11828         case 0x5f: str="Semantically incorrect message"; break;
11829         case 0x60: str="Invalid mandatory information"; break;
11830         case 0x61: str="Message type non-existent or not implemented"; break;
11831         case 0x62: str="Message type not compatible with the protocol state"; break;
11832         case 0x63: str="Information element non-existent or not implemented"; break;
11833         case 0x64: str="Conditional IE error"; break;
11834         case 0x65: str="Message not compatible with the protocol state"; break;
11835         case 0x6f: str="Protocol error, unspecified"; break;
11836         case 0x70: str="APN restriction value incompatible with active PDP context"; break;
11837         default: str="Protocol error, unspecified"; break;
11838     }
11839
11840     proto_tree_add_text(tree,
11841         tvb, curr_offset, 1,
11842         "Cause: (%u) %s %s",
11843         oct, str,add_string ? add_string : "");
11844
11845     curr_offset++;
11846
11847     return(curr_offset - offset);
11848 }
11849
11850 /*
11851  * [7] 10.5.6.7
11852  */
11853 static guint8
11854 de_sm_linked_ti(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
11855 {
11856     guint32     curr_offset;
11857     guint       curr_len;
11858     gchar       oct;
11859
11860     gchar       ti_flag[2][80]={ "The message is sent from the side that originates the TI" ,
11861                         "The message is sent to the side that originates the TI" };
11862     
11863     curr_len = len;
11864     curr_offset = offset;
11865
11866     oct = tvb_get_guint8(tvb, curr_offset);
11867
11868     proto_tree_add_text(tree,
11869         tvb, curr_offset, 1,
11870         "TI flag: (%u) %s",oct>>7,ti_flag[oct>>7]);
11871
11872     if ( curr_len > 1 )
11873     {
11874         oct = tvb_get_guint8(tvb, curr_offset);
11875         
11876         proto_tree_add_text(tree,
11877         tvb, curr_offset, 1,
11878         "TI value: 0x%02x (%u)",oct&0x7f,oct&0x7f);
11879
11880         proto_tree_add_text(tree,
11881         tvb, curr_offset, 1,
11882         "ext: 0x%02x (%u)",oct>>7,oct>>7);
11883
11884     }
11885     else
11886     {
11887         proto_tree_add_text(tree,
11888         tvb, curr_offset, 1,
11889         "TI value: 0x%02x (%u)",(oct>>4)&7,(oct>>4)&7);
11890     }
11891
11892     curr_offset+= curr_len;        
11893                    
11894     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11895
11896     return(curr_offset - offset);
11897 }
11898
11899 /*
11900  * [7] 10.5.6.9
11901  */
11902 static guint8
11903 de_sm_sapi(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len _U_)
11904 {
11905     guint8      oct;
11906     guint32     curr_offset;
11907     
11908     len = len;
11909     curr_offset = offset;
11910
11911     oct = tvb_get_guint8(tvb, curr_offset);
11912
11913     proto_tree_add_text(tree,
11914         tvb, curr_offset, 1,
11915         "LLC SAPI: 0x%02x (%u) %s",
11916         oct&0x0f, oct&0x0f,add_string ? add_string : "");
11917
11918     curr_offset++;
11919
11920     return(curr_offset - offset);
11921 }
11922
11923 /*
11924  * [7] 10.5.6.10
11925  */
11926 static guint8
11927 de_sm_tear_down(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len _U_)
11928 {
11929     guint8      oct;
11930     guint32     curr_offset;
11931     gchar       str[2][30] = { "tear down not requested" , "tear down requested" };
11932     
11933     len = len;
11934     curr_offset = offset;
11935
11936     oct = tvb_get_guint8(tvb, curr_offset);
11937
11938     proto_tree_add_text(tree,
11939         tvb, curr_offset, 1,
11940         "Tear Down Indicator: (%u) %s %s",
11941         oct&1, str[oct&1],add_string ? add_string : "");
11942
11943     curr_offset++;
11944
11945     return(curr_offset - offset);
11946 }
11947
11948 /*
11949  * [7] 10.5.6.11
11950  */
11951 /* Packet Flow Identifier value (octet 3) */
11952 static const value_string gsm_a_packet_flow_id_vals[] = {
11953         { 0,            "Best Effort"},
11954         { 1,            "Signaling"},
11955         { 2,            "SMS"},
11956         { 3,            "TOM8"},
11957         { 4,            "reserved"},
11958         { 5,            "reserved"},
11959         { 6,            "reserved"},
11960         { 7,            "reserved"},
11961         { 0,    NULL }
11962 };
11963 guint8
11964 de_sm_pflow_id(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
11965 {
11966     guint32     curr_offset;
11967     guint       curr_len;
11968     guchar      oct;
11969     
11970     curr_len = len;
11971     curr_offset = offset;
11972
11973     oct = tvb_get_guint8(tvb, curr_offset);
11974
11975     proto_tree_add_text(tree,
11976         tvb, curr_offset, 1,
11977         "Packet Flow Identifier: (%u) %s",oct&0x7f,
11978                 val_to_str(oct&0x7f, gsm_a_packet_flow_id_vals, "dynamically assigned (%u)"));
11979
11980     curr_offset+= curr_len;        
11981                    
11982     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
11983
11984     return(curr_offset - offset);
11985 }
11986
11987 /*
11988  * [7] 10.5.6.12     TFT - Traffic Flow Template
11989  */
11990 /* TFT operation code (octet 3) */
11991 static const value_string gsm_a_tft_op_code_vals[] = {
11992         { 0,            "Spare"},
11993         { 1,            "Create new TFT"},
11994         { 2,            "Delete existing TFT"},
11995         { 3,            "Add packet filters to existing TFT"},
11996         { 4,            "Replace packet filters in existing TFT"},
11997         { 5,            "Delete packet filters from existing TFT"},
11998         { 6,            "No TFT operation"},
11999         { 7,            "Reserved"},
12000         { 0,    NULL }
12001 };
12002
12003 static const true_false_string gsm_a_tft_e_bit  = {
12004   "parameters list is included",
12005   "parameters list is not included"
12006 };
12007
12008
12009 static guint8
12010 de_sm_tflow_temp(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
12011 {
12012     guint32     curr_offset;
12013     guint       curr_len;
12014     proto_item  *tf = NULL;
12015     proto_tree      *tf_tree = NULL;
12016     proto_tree  *comp_tree = NULL;
12017     guchar      op_code;
12018     guchar      pkt_fil_count;
12019     guchar      e_bit;
12020     const gchar *str;
12021     guchar      count;
12022     guchar      oct;
12023     gint pf_length;
12024     gint pf_identifier;
12025     gint pack_component_type;
12026     
12027     curr_len = len;
12028     curr_offset = offset;
12029
12030     /*
12031      * parse first octet. It contain TFT operation code, E bit and Number of packet filters
12032      */
12033     oct = tvb_get_guint8(tvb, curr_offset);
12034
12035     op_code = oct>>5;
12036     pkt_fil_count = oct&0x0f;
12037     e_bit = (oct>>4)&1;
12038
12039         proto_tree_add_item(tree,hf_gsm_a_tft_op_code,tvb,curr_offset,1,FALSE);
12040         proto_tree_add_item(tree,hf_gsm_a_tft_e_bit,tvb,curr_offset,1,FALSE);
12041         proto_tree_add_item(tree,hf_gsm_a_tft_pkt_flt,tvb,curr_offset,1,FALSE);
12042
12043     curr_offset++;
12044     curr_len--;
12045
12046     /* Packet filter list dissect */
12047
12048     count = 0;
12049     if ( op_code == 2 )                 /* delete TFT contains no packet filters. so we will jump over it */
12050         count = pkt_fil_count;
12051     while ( count < pkt_fil_count )
12052     {
12053         tf = proto_tree_add_text(tree,
12054                 tvb, curr_offset, 1,
12055                 "Packet filter %d",count);   /* 0-> 7 */
12056
12057         tf_tree = proto_item_add_subtree(tf, ett_sm_tft );
12058
12059         if ( op_code == 5 )  /* Delete packet filters from existing TFT - just a list of identifiers */
12060
12061         {
12062                 if ((curr_offset-offset)<1) { 
12063                         proto_tree_add_text(tf_tree,tvb, curr_offset, 1,"Not enough data");
12064                         return(curr_offset-offset);
12065                 }
12066                 oct = tvb_get_guint8(tvb, curr_offset);
12067                 curr_offset++;
12068                 curr_len--;
12069
12070                 proto_tree_add_text(tf_tree,
12071                         tvb, curr_offset-1, 1,
12072                         "Packet filter identifier: 0x%02x (%u)",oct,oct );              
12073         }
12074         else                            /* create new, Add packet filters or Replace packet filters */
12075         {
12076                 
12077                 if ((curr_offset-offset)<1) { 
12078                         proto_tree_add_text(tf_tree,tvb, curr_offset, 1,"Not enough data"); 
12079                         return(curr_offset-offset);
12080                 }
12081                 pf_identifier = tvb_get_guint8(tvb, curr_offset);
12082                 curr_offset++;
12083                 curr_len--;
12084
12085                 proto_tree_add_text(tf_tree,
12086                         tvb, curr_offset-1, 1,
12087                         "Packet filter identifier: %u (%u)",pf_identifier, pf_identifier);              
12088
12089                 if ((curr_offset-offset)<1) { 
12090                         proto_tree_add_text(tf_tree,tvb, curr_offset, 1,"Not enough data"); 
12091                         return(curr_offset-offset);
12092                 }
12093                 oct = tvb_get_guint8(tvb, curr_offset);
12094                 curr_offset++;
12095                 curr_len--;
12096
12097                 proto_tree_add_text(tf_tree,
12098                         tvb, curr_offset-1, 1,
12099                         "Packet evaluation precedence: 0x%02x (%u)",oct,oct );          
12100
12101                 if ((curr_offset-offset)<1) { proto_tree_add_text(tf_tree,tvb, curr_offset, 1,"Not enough data"); return(curr_offset-offset);}
12102                 pf_length = tvb_get_guint8(tvb, curr_offset);
12103                 curr_offset++;
12104                 curr_len--;
12105
12106                 proto_tree_add_text(tf_tree,
12107                         tvb, curr_offset-1, 1,
12108                         "Packet filter length: 0x%02x (%u)",pf_length,pf_length );              
12109                 /* New tree for component */
12110
12111         /* Dissect Packet filter Component */
12112                 /* while ( filter_len > 1 ) */
12113                 /* packet filter component type identifier: */
12114
12115                 if (pf_length > 0 ){
12116                         if ((curr_offset-offset)<1) {
12117                                 proto_tree_add_text(tf_tree,tvb, curr_offset, 1,"Not enough data"); 
12118                                 return(curr_offset-offset);
12119                         }
12120                         pack_component_type = tvb_get_guint8(tvb, curr_offset);
12121                         curr_offset++;
12122                         curr_len--;
12123
12124                         tf=proto_tree_add_text(tf_tree,tvb, curr_offset-1, 1,"Packet filter component type identifier: ");
12125                 comp_tree = proto_item_add_subtree(tf, ett_sm_tft );
12126                         
12127                         switch ( pack_component_type ){
12128                                 
12129                                 case 0x10: 
12130                                         str="IPv4 source address type";
12131                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_ip4_address,tvb,curr_offset,4,FALSE);
12132                         curr_offset+=4;
12133                         curr_len-=4;
12134                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_ip4_mask,tvb,curr_offset,4,FALSE);
12135                         curr_offset+=4;
12136                         curr_len-=4;
12137                                         break;
12138  
12139         
12140                                 case 0x20: 
12141                                         str="IPv6 source address type"; 
12142                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_ip6_address,tvb,curr_offset,16,FALSE);
12143                                         curr_offset+=16;
12144                                         curr_len-=16;
12145                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_ip6_mask,tvb,curr_offset,16,FALSE);
12146                                         curr_offset+=16;
12147                                         curr_len-=16;
12148                                         break;
12149
12150                                 case 0x30: 
12151                                         str="Protocol identifier/Next header type";
12152                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_protocol_header,tvb,curr_offset,1,FALSE);
12153                                         curr_offset+=1;
12154                                         curr_len-=1;
12155                                         break;
12156
12157                                 case 0x40: 
12158                                         str="Single destination port type";
12159                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_port,tvb,curr_offset,2,FALSE);
12160                                         curr_offset+=2;
12161                                         curr_len-=2;
12162
12163                                 case 0x41: 
12164                                         str="Destination port range type";
12165                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_port_low,tvb,curr_offset,2,FALSE);
12166                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_port_high,tvb,curr_offset,2,FALSE);
12167                                         curr_offset+=4;
12168                                         curr_len-=4;
12169                                         break;
12170
12171                                 case 0x50: 
12172                                         str="Single source port type";
12173                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_port,tvb,curr_offset,2,FALSE);
12174                                         curr_offset+=2;
12175                                         curr_len-=2;
12176                                         break;
12177
12178                                 case 0x51: 
12179                                         str="Source port range type";
12180                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_port_low,tvb,curr_offset,2,FALSE);
12181                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_port_high,tvb,curr_offset,2,FALSE);
12182                                         curr_offset+=4;
12183                                         curr_len-=4;
12184                                         break;
12185
12186                                 case 0x60: 
12187                                         str="Security parameter index type";
12188                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_security,tvb,curr_offset,4,FALSE);
12189                                         curr_offset+=4;
12190                                         curr_len-=4;
12191                                         break;
12192
12193
12194                                 case 0x70: 
12195                                         str="Type of service/Traffic class type";
12196                                         proto_tree_add_item(comp_tree,hf_gsm_a_qos_traffic_cls,tvb,curr_offset,1,FALSE);
12197                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_traffic_mask,tvb,curr_offset,1,FALSE);
12198                                         curr_offset+=2;
12199                                         curr_len-=2;
12200                                         break;
12201
12202                                 case 0x80: 
12203                                         str="Flow label type";
12204                                         proto_tree_add_item(comp_tree,hf_gsm_a_tft_traffic_mask,tvb,curr_offset,1,FALSE);
12205                                         curr_offset+=3;
12206                                         curr_len-=3;
12207                                         break;
12208
12209                                 default: 
12210                                         str="not specified";
12211                         }
12212                         proto_item_append_text(tf, "(%u) %s", pack_component_type, str );
12213             count++;
12214                         }
12215                 }
12216         }
12217
12218
12219         /* The parameters list contains a variable number of parameters that might need to be
12220          * transferred in addition to the packet filters. If the parameters list is included, the E
12221          * bit is set to 1; otherwise, the E bit is set to 0.
12222          */
12223          if (e_bit == 1){
12224                  proto_tree_add_text(tf_tree, tvb, curr_offset, 1, "Note: Possible Authorizaton Token/Flow Identifier not decoded yet");
12225          }
12226  return(curr_offset - offset);
12227 }
12228
12229 static guint8 (*bssmap_elem_fcn[])(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len) = {
12230     be_cic,     /* Circuit Identity Code */
12231     NULL,       /* Reserved */
12232     NULL,       /* Resource Available */
12233     be_cause,   /* Cause */
12234     be_cell_id, /* Cell Identifier */
12235     be_prio,    /* Priority */
12236     be_l3_header_info,  /* Layer 3 Header Information */
12237     de_mid,     /* IMSI */
12238     be_tmsi,    /* TMSI */
12239     be_enc_info,        /* Encryption Information */
12240     be_chan_type,       /* Channel Type */
12241     NULL,       /* Periodicity */
12242     NULL,       /* Extended Resource Indicator */
12243     NULL,       /* Number Of MSs */
12244     NULL,       /* Reserved */
12245     NULL,       /* Reserved */
12246     NULL,       /* Reserved */
12247     de_ms_cm_2, /* Classmark Information Type 2 */
12248     NULL,       /* Classmark Information Type 3 */
12249     NULL,       /* Interference Band To Be Used */
12250     de_rr_cause,        /* RR Cause */
12251     NULL,       /* Reserved */
12252     be_l3_info, /* Layer 3 Information */
12253     be_dlci,    /* DLCI */
12254     be_down_dtx_flag,   /* Downlink DTX Flag */
12255     be_cell_id_list,    /* Cell Identifier List */
12256     NULL /* no associated data */,      /* Response Request */
12257     NULL,       /* Resource Indication Method */
12258     de_ms_cm_1, /* Classmark Information Type 1 */
12259     NULL,       /* Circuit Identity Code List */
12260     NULL,       /* Diagnostic */
12261     be_l3_msg,  /* Layer 3 Message Contents */
12262     be_chosen_chan,     /* Chosen Channel */
12263     NULL,       /* Total Resource Accessible */
12264     be_ciph_resp_mode,  /* Cipher Response Mode */
12265     be_cha_needed,      /* Channel Needed */
12266     NULL,       /* Trace Type */
12267     NULL,       /* TriggerID */
12268     NULL,       /* Trace Reference */
12269     NULL,       /* TransactionID */
12270     de_mid,     /* Mobile Identity */
12271     NULL,       /* OMCID */
12272     be_for_ind, /* Forward Indicator */
12273     be_chosen_enc_alg,  /* Chosen Encryption Algorithm */
12274     be_cct_pool,        /* Circuit Pool */
12275     NULL,       /* Circuit Pool List */
12276     NULL,       /* Time Indication */
12277     NULL,       /* Resource Situation */
12278     be_curr_chan_1,     /* Current Channel Type 1 */
12279     be_que_ind, /* Queueing Indicator */
12280     be_speech_ver,      /* Speech Version */
12281     NULL,       /* Assignment Requirement */
12282     NULL /* no associated data */,      /* Talker Flag */
12283     NULL /* no associated data */,      /* Connection Release Requested */
12284     NULL,       /* Group Call Reference */
12285     NULL,       /* eMLPP Priority */
12286     NULL,       /* Configuration Evolution Indication */
12287     NULL /* no decode required */,      /* Old BSS to New BSS Information */
12288     NULL,       /* LSA Identifier */
12289     NULL,       /* LSA Identifier List */
12290     NULL,       /* LSA Information */
12291     NULL,       /* LCS QoS */
12292     NULL,       /* LSA access control suppression */
12293     NULL,       /* LCS Priority */
12294     NULL,       /* Location Type */
12295     NULL,       /* Location Estimate */
12296     NULL,       /* Positioning Data */
12297     NULL,       /* LCS Cause */
12298     NULL,       /* LCS Client Type */
12299     be_apdu,    /* APDU */
12300     NULL,       /* Network Element Identity */
12301     NULL,       /* GPS Assistance Data */
12302     NULL,       /* Deciphering Keys */
12303     NULL,       /* Return Error Request */
12304     NULL,       /* Return Error Cause */
12305     NULL,       /* Segmentation */
12306     NULL,       /* NONE */
12307 };
12308
12309 static guint8 (*dtap_elem_fcn[])(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len) = {
12310     /* Common Information Elements 10.5.1 */
12311     de_cell_id, /* Cell Identity */
12312     NULL /* handled inline */,  /* Ciphering Key Sequence Number */
12313     de_lai,     /* Location Area Identification */
12314     de_mid,     /* Mobile Identity */
12315     de_ms_cm_1, /* Mobile Station Classmark 1 */
12316     de_ms_cm_2, /* Mobile Station Classmark 2 */
12317     NULL,               /* Mobile Station Classmark 3 */
12318     de_d_gb_call_ref,   /* Descriptive group or broadcast call reference */
12319     NULL /* handled inline */,  /* Group Cipher Key Number */
12320     de_pd_sapi, /* PD and SAPI $(CCBS)$ */
12321         /* Pos 10 */
12322     de_prio /* handled inline */,       /* Priority Level */
12323     de_plmn_list,       /* PLMN List */
12324     /* Radio Resource Management  Information Elements 10.5.2, most are from 10.5.1 */
12325 /*
12326  * [3]  10.5.2.1a       BA Range
12327  */
12328         de_rr_cell_ch_dsc,                              /* [3]  10.5.2.1b       Cell Channel Description        */
12329 /* [3]  10.5.2.1c       BA List Pref
12330  * [3]  10.5.2.1d       UTRAN Frequency List
12331  * [3]  10.5.2.1e       Cell selection indicator after release of all TCH and SDCCH IE
12332  */
12333         de_rr_cell_dsc,                                 /* 10.5.2.2   RR Cell Description                               */
12334 /*
12335  * [3]  10.5.2.3        Cell Options (BCCH)     
12336  * [3]  10.5.2.3a       Cell Options (SACCH)
12337  * [3]  10.5.2.4        Cell Selection Parameters
12338  * [3]  10.5.2.4a       (void)
12339  */
12340         de_rr_ch_dsc,                                   /* [3]  10.5.2.5        Channel Description                     */
12341         de_rr_ch_dsc2,                                  /* [3]  10.5.2.5a   RR Channel Description 2    */
12342         de_rr_ch_mode,                                  /* [3]  10.5.2.6        Channel Mode                            */
12343         de_rr_ch_mode2,                                 /* [3]  10.5.2.7        Channel Mode 2                          */
12344 /*
12345  * [3]  10.5.2.7a       UTRAN predefined configuration status information / START-CS / UE CapabilityUTRAN Classmark information element 218
12346  * [3]  10.5.2.7b       (void) */
12347
12348         de_rr_cm_enq_mask,                              /* [3]  10.5.2.7c       Classmark Enquiry Mask          */
12349 /* [3]  10.5.2.7d       GERAN Iu Mode Classmark information element                                             */
12350         de_rr_chnl_needed,                              /* [3]  10.5.2.8        Channel Needed
12351  * [3]  10.5.2.8a       (void)  
12352  * [3]  10.5.2.8b       Channel Request Description 2 */
12353         /* Pos 20 */
12354         de_rr_cip_mode_set,                                     /* [3]  10.5.2.9        Cipher Mode Setting             */
12355 /* [3]  10.5.2.10       Cipher Response
12356  * [3]  10.5.2.11       Control Channel Description
12357  * [3]  10.5.2.11a      DTM Information Details */
12358         de_rr_dyn_arfcn_map,                            /* [3]  10.5.2.11b      Dynamic ARFCN Mapping           */
12359         de_rr_freq_ch_seq,                                      /* [3]  10.5.2.12       Frequency Channel Sequence      */
12360         de_rr_freq_list,                                        /* [3]  10.5.2.13       Frequency List                          */
12361         de_rr_freq_short_list,                          /* [3]  10.5.2.14       Frequency Short List            */
12362         de_rr_freq_short_list2,                         /* [3]  10.5.2.14a      Frequency Short List 2          */
12363 /* [3]  10.5.2.14b      Group Channel Description
12364  * [3]  10.5.2.14c      GPRS Resumption
12365  * [3]  10.5.2.14d      GPRS broadcast information
12366  * [3]  10.5.2.14e      Enhanced DTM CS Release Indication
12367  */
12368         de_rr_ho_ref,                                   /* 10.5.2.15  Handover Reference                                */
12369 /*
12370  * [3] 10.5.2.16 IA Rest Octets
12371  * [3] 10.5.2.17 IAR Rest Octets
12372  * [3] 10.5.2.18 IAX Rest Octets
12373  * [3] 10.5.2.19 L2 Pseudo Length
12374  * [3] 10.5.2.20 Measurement Results
12375  * [3] 10.5.2.20a GPRS Measurement Results
12376  */
12377         de_rr_mob_all,                                  /* [3] 10.5.2.21 Mobile Allocation                              */
12378         de_rr_mob_time_diff,                    /* [3] 10.5.2.21a Mobile Time Difference                */
12379         de_rr_multirate_conf,                   /* [3] 10.5.2.21aa MultiRate configuration              */
12380         /* Pos 30 */
12381         de_rr_mult_all,                                 /* [3] 10.5.2.21b Multislot Allocation                  */
12382 /*
12383  * [3] 10.5.2.21c NC mode
12384  * [3] 10.5.2.22 Neighbour Cell Description
12385  * [3] 10.5.2.22a Neighbour Cell Description 2
12386  * [3] 10.5.2.22b (void)
12387  * [3] 10.5.2.22c NT/N Rest Octets
12388  * [3] 10.5.2.23 P1 Rest Octets
12389  * [3] 10.5.2.24 P2 Rest Octets
12390  * [3] 10.5.2.25 P3 Rest Octets
12391  * [3] 10.5.2.25a Packet Channel Description
12392  * [3] 10.5.2.25b Dedicated mode or TBF
12393  * [3] 10.5.2.25c RR Packet Uplink Assignment
12394  * [3] 10.5.2.25d RR Packet Downlink Assignment
12395  * [3] 10.5.2.26 Page Mode
12396  * [3] 10.5.2.26a (void)
12397  * [3] 10.5.2.26b (void)
12398  * [3] 10.5.2.26c (void)
12399  * [3] 10.5.2.26d (void)
12400  * [3] 10.5.2.27 NCC Permitted
12401  */
12402         de_rr_pow_cmd,                                  /* 10.5.2.28  Power Command                                             */
12403         de_rr_pow_cmd_and_acc_type,             /* 10.5.2.28a Power Command and access type             */
12404 /*
12405  * [3] 10.5.2.29 RACH Control Parameters
12406  * [3] 10.5.2.30 Request Reference
12407  */
12408     de_rr_cause,                                        /* 10.5.2.31  RR Cause                                                  */
12409         de_rr_sync_ind,                                 /* 10.5.2.39  Synchronization Indication                */
12410 /* [3] 10.5.2.32 SI 1 Rest Octets
12411  * [3] 10.5.2.33 SI 2bis Rest Octets 
12412  * [3] 10.5.2.33a SI 2ter Rest Octets
12413  * [3] 10.5.2.33b SI 2quater Rest Octets
12414  * [3] 10.5.2.34 SI 3 Rest Octets
12415  * [3] 10.5.2.35 SI 4 Rest Octets
12416  * [3] 10.5.2.35a SI 6 Rest Octets
12417  * [3] 10.5.2.36 SI 7 Rest Octets
12418  * [3] 10.5.2.37 SI 8 Rest Octets
12419  * [3] 10.5.2.37a SI 9 Rest Octets
12420  * [3] 10.5.2.37b SI 13 Rest Octets
12421  * [3] 10.5.2.37c (void)
12422  * [3] 10.5.2.37d (void)
12423  * [3] 10.5.2.37e SI 16 Rest Octets
12424  * [3] 10.5.2.37f SI 17 Rest Octets
12425  * [3] 10.5.2.37g SI 19 Rest Octets
12426  * [3] 10.5.2.37h SI 18 Rest Octets
12427  * [3] 10.5.2.37i SI 20 Rest Octets */
12428         de_rr_starting_time,                            /* [3] 10.5.2.38 Starting Time                                  */
12429         de_rr_timing_adv,                                       /* [3] 10.5.2.40 Timing Advance                                 */ 
12430         de_rr_time_diff,                                        /* [3] 10.5.2.41 Time Difference                                */
12431         de_rr_tlli,                                                     /* [3] 10.5.2.41a TLLI                                                  */
12432 /*
12433  * [3] 10.5.2.42 TMSI/P-TMSI */
12434         de_rr_vgcs_tar_mode_ind,                        /* [3] 10.5.2.42a VGCS target mode Indication   */
12435         /* Pos 40 */
12436         de_rr_vgcs_cip_par,                                     /* [3] 10.5.2.42b       VGCS Ciphering Parameters       */
12437 /* [3] 10.5.2.43 Wait Indication
12438  * [3] 10.5.2.44 SI10 rest octets $(ASCI)$
12439  * [3] 10.5.2.45 EXTENDED MEASUREMENT RESULTS
12440  * [3] 10.5.2.46 Extended Measurement Frequency List */
12441         de_rr_sus_cau,                                          /* [3] 10.5.2.47 Suspension Cause                               */
12442 /* [3] 10.5.2.48 APDU ID 
12443  * [3] 10.5.2.49 APDU Flags
12444  * [3] 10.5.2.50 APDU Data
12445  * [3] 10.5.2.51 Handover To UTRAN Command
12446  * [3] 10.5.2.52 Handover To cdma2000 Command 
12447  * [3] 10.5.2.53 (void)
12448  * [3] 10.5.2.54 (void)
12449  * [3] 10.5.2.55 (void)
12450  * [3] 10.5.2.56 3G Target Cell
12451 */
12452         de_rr_ded_serv_inf,                                     /* [3] 10.5.2.59        Dedicated Service Information */
12453
12454         /* Mobility Management Information Elements 10.5.3 */
12455     de_auth_param_rand, /* Authentication Parameter RAND */
12456     de_auth_param_autn, /* Authentication Parameter AUTN (UMTS authentication challenge only) */
12457     de_auth_resp_param, /* Authentication Response Parameter */
12458     de_auth_resp_param_ext,     /* Authentication Response Parameter (extension) (UMTS authentication challenge only) */
12459     de_auth_fail_param, /* Authentication Failure Parameter (UMTS authentication challenge only) */
12460     NULL /* handled inline */,  /* CM Service Type */
12461     NULL /* handled inline */,  /* Identity Type */
12462         /* Pos 50 */
12463     NULL /* handled inline */,  /* Location Updating Type */
12464     de_network_name,    /* Network Name */
12465     de_rej_cause,       /* Reject Cause */
12466     NULL /* no associated data */,      /* Follow-on Proceed */
12467     de_time_zone,       /* Time Zone */
12468     de_time_zone_time,  /* Time Zone and Time */
12469     NULL /* no associated data */,      /* CTS Permission */
12470     de_lsa_id,  /* LSA Identifier */
12471     de_day_saving_time, /* Daylight Saving Time */
12472     NULL, /* Emergency Number List */
12473     /* Call Control Information Elements 10.5.4 */
12474         /* Pos 60 */
12475     de_aux_states,      /* Auxiliary States */
12476     de_bearer_cap,      /* Bearer Capability */
12477     de_cc_cap,  /* Call Control Capabilities */
12478     de_call_state,      /* Call State */
12479     de_cld_party_bcd_num,       /* Called Party BCD Number */
12480     de_cld_party_sub_addr,      /* Called Party Subaddress */
12481     de_clg_party_bcd_num,       /* Calling Party BCD Number */
12482     de_clg_party_sub_addr,      /* Calling Party Subaddress */
12483     de_cause,   /* Cause */
12484     NULL /* no associated data */,      /* CLIR Suppression */
12485     NULL /* no associated data */,      /* CLIR Invocation */
12486     NULL /* handled inline */,  /* Congestion Level */
12487     NULL,       /* Connected Number */
12488     NULL,       /* Connected Subaddress */
12489     de_facility,        /* Facility */
12490     NULL,       /* High Layer Compatibility */
12491     de_keypad_facility, /* Keypad Facility */
12492     de_llc,                                                     /* 10.5.4.18 Low layer compatibility */
12493     NULL,       /* More Data */
12494     NULL,       /* Notification Indicator */
12495     de_prog_ind,        /* Progress Indicator */
12496     NULL,       /* Recall type $(CCBS)$ */
12497     NULL,       /* Redirecting Party BCD Number */
12498     NULL,       /* Redirecting Party Subaddress */
12499     de_repeat_ind,      /* Repeat Indicator */
12500     NULL /* no associated data */,      /* Reverse Call Setup Direction */
12501     NULL,       /* SETUP Container $(CCBS)$ */
12502     NULL,       /* Signal */
12503     de_ss_ver_ind,      /* SS Version Indicator */
12504     NULL,       /* User-user */
12505     NULL,       /* Alerting Pattern $(NIA)$ */
12506     NULL,       /* Allowed Actions $(CCBS)$ */
12507     NULL,       /* Stream Identifier */
12508     NULL,       /* Network Call Control Capabilities */
12509     NULL,       /* Cause of No CLI */
12510     NULL,       /* Immediate Modification Indicator */
12511     NULL,       /* Supported Codec List */
12512     NULL,       /* Service Category */
12513     /* GPRS Mobility Management Information Elements 10.5.5 */
12514     de_gmm_attach_res,  /* Attach Result */
12515     de_gmm_attach_type, /* Attach Type */
12516     de_gmm_ciph_alg,    /* Cipher Algorithm */
12517     de_gmm_tmsi_stat,   /* TMSI Status */
12518     de_gmm_detach_type, /* Detach Type */
12519     de_gmm_drx_param,   /* DRX Parameter */
12520     de_gmm_ftostby,     /* Force to Standby */
12521     de_gmm_ftostby_h,   /* Force to Standby - Info is in the high nibble */
12522     de_gmm_ptmsi_sig,   /* P-TMSI Signature */
12523     de_gmm_ptmsi_sig2,  /* P-TMSI Signature 2 */
12524     de_gmm_ident_type2, /* Identity Type 2 */
12525     de_gmm_imeisv_req,  /* IMEISV Request */
12526     de_gmm_rec_npdu_lst,        /* Receive N-PDU Numbers List */
12527     de_gmm_ms_net_cap,  /* MS Network Capability */
12528     de_gmm_ms_radio_acc_cap,    /* MS Radio Access Capability */
12529     de_gmm_cause,       /* GMM Cause */
12530     de_gmm_rai, /* Routing Area Identification */
12531     de_gmm_update_res,  /* Update Result */
12532     de_gmm_update_type, /* Update Type */
12533     de_gmm_ac_ref_nr,   /* A&C Reference Number */
12534     de_gmm_ac_ref_nr_h, /* A&C Reference Numer - Info is in the high nibble */
12535     de_gmm_service_type,        /* Service Type */
12536     de_gmm_cell_notfi,  /* Cell Notification */
12537     de_gmm_ps_lcs_cap,  /* PS LCS Capability */
12538     de_gmm_net_feat_supp,       /* Network Feature Support */
12539         de_gmm_rat_info_container, /* Inter RAT information container */
12540     /* Short Message Service Information Elements [5] 8.1.4 */
12541     de_cp_user_data,    /* CP-User Data */
12542     de_cp_cause,        /* CP-Cause */
12543     /* Short Message Service Information Elements [5] 8.2 */
12544     de_rp_message_ref,  /* RP-Message Reference */
12545     de_rp_orig_addr,    /* RP-Origination Address */
12546     de_rp_dest_addr,    /* RP-Destination Address */
12547     de_rp_user_data,    /* RP-User Data */
12548     de_rp_cause,        /* RP-Cause */
12549     /* Session Management Information Elements 10.5.6 */
12550     de_sm_apn,  /* Access Point Name */
12551     de_sm_nsapi,        /* Network Service Access Point Identifier */
12552     de_sm_pco,  /* Protocol Configuration Options */
12553     de_sm_pdp_addr,     /* Packet Data Protocol Address */
12554     de_sm_qos,  /* Quality Of Service */
12555     de_sm_cause,        /* SM Cause */
12556     de_sm_linked_ti,    /* Linked TI */
12557     de_sm_sapi, /* LLC Service Access Point Identifier */
12558     de_sm_tear_down,    /* Tear Down Indicator */
12559     de_sm_pflow_id,     /* Packet Flow Identifier */
12560     de_sm_tflow_temp,   /* Traffic Flow Template */
12561     /* GPRS Common Information Elements 10.5.7 */
12562     de_gc_context_stat, /* PDP Context Status */
12563     de_gc_radio_prio,   /* Radio Priority */
12564     de_gc_timer,        /* GPRS Timer */
12565     de_gc_timer2,       /* GPRS Timer 2 */
12566     de_gc_radio_prio2,  /* Radio Priority 2 */
12567         de_gc_mbms_context_stat, /* 10.5.7.6 MBMS context status */
12568     de_gc_spare,        /* Spare Nibble */
12569     NULL,       /* NONE */
12570 };
12571
12572 #define SET_ELEM_VARS(SEV_pdu_type, SEV_elem_names, SEV_elem_ett, SEV_elem_funcs) \
12573     switch (SEV_pdu_type) \
12574     { \
12575     case BSSAP_PDU_TYPE_BSSMAP: \
12576         SEV_elem_names = gsm_bssmap_elem_strings; \
12577         SEV_elem_ett = ett_gsm_bssmap_elem; \
12578         SEV_elem_funcs = bssmap_elem_fcn; \
12579         break; \
12580     case BSSAP_PDU_TYPE_DTAP: \
12581         SEV_elem_names = gsm_dtap_elem_strings; \
12582         SEV_elem_ett = ett_gsm_dtap_elem; \
12583         SEV_elem_funcs = dtap_elem_fcn; \
12584         break; \
12585     default: \
12586         proto_tree_add_text(tree, \
12587             tvb, curr_offset, -1, \
12588             "Unknown PDU type (%u)", SEV_pdu_type); \
12589         return(consumed); \
12590     }
12591
12592 /*
12593  * Type Length Value (TLV) element dissector
12594  */
12595 static guint8
12596 elem_tlv(tvbuff_t *tvb, proto_tree *tree, guint8 iei, gint pdu_type, int idx, guint32 offset, guint len, const gchar *name_add)
12597 {
12598     guint8              oct, parm_len;
12599     guint8              consumed;
12600     guint32             curr_offset;
12601     proto_tree          *subtree;
12602     proto_item          *item;
12603     const value_string  *elem_names;
12604     gint                *elem_ett;
12605     guint8 (**elem_funcs)(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
12606
12607     len = len;
12608     curr_offset = offset;
12609     consumed = 0;
12610
12611     SET_ELEM_VARS(pdu_type, elem_names, elem_ett, elem_funcs);
12612
12613     oct = tvb_get_guint8(tvb, curr_offset);
12614
12615     if (oct == iei)
12616     {
12617         parm_len = tvb_get_guint8(tvb, curr_offset + 1);
12618
12619         item =
12620             proto_tree_add_text(tree,
12621                 tvb, curr_offset, parm_len + 2,
12622                 "%s%s",
12623                 elem_names[idx].strptr,
12624                 (name_add == NULL) || (name_add[0] == '\0') ? "" : name_add);
12625
12626         subtree = proto_item_add_subtree(item, elem_ett[idx]);
12627
12628         proto_tree_add_uint(subtree,
12629             (BSSAP_PDU_TYPE_BSSMAP == pdu_type) ? hf_gsm_a_bssmap_elem_id : hf_gsm_a_dtap_elem_id, tvb,
12630             curr_offset, 1, oct);
12631
12632         proto_tree_add_uint(subtree, hf_gsm_a_length, tvb,
12633             curr_offset + 1, 1, parm_len);
12634
12635         if (parm_len > 0)
12636         {
12637             if (elem_funcs[idx] == NULL)
12638             {
12639                 proto_tree_add_text(subtree,
12640                     tvb, curr_offset + 2, parm_len,
12641                     "Element Value");
12642
12643                 consumed = parm_len;
12644             }
12645             else
12646             {
12647                 gchar *a_add_string;
12648
12649                 a_add_string=ep_alloc(1024);
12650                 a_add_string[0] = '\0';
12651                 consumed =
12652                     (*elem_funcs[idx])(tvb, subtree, curr_offset + 2,
12653                         parm_len, a_add_string, 1024);
12654
12655                 if (a_add_string[0] != '\0')
12656                 {
12657                     proto_item_append_text(item, "%s", a_add_string);
12658                 }
12659             }
12660         }
12661
12662         consumed += 2;
12663     }
12664
12665     return(consumed);
12666 }
12667
12668 /*
12669  * Type Value (TV) element dissector
12670  *
12671  * Length cannot be used in these functions, big problem if a element dissector
12672  * is not defined for these.
12673  */
12674 static guint8
12675 elem_tv(tvbuff_t *tvb, proto_tree *tree, guint8 iei, gint pdu_type, int idx, guint32 offset, const gchar *name_add)
12676 {
12677     guint8              oct;
12678     guint8              consumed;
12679     guint32             curr_offset;
12680     proto_tree          *subtree;
12681     proto_item          *item;
12682     const value_string  *elem_names;
12683     gint                *elem_ett;
12684     guint8 (**elem_funcs)(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
12685
12686     curr_offset = offset;
12687     consumed = 0;
12688
12689     SET_ELEM_VARS(pdu_type, elem_names, elem_ett, elem_funcs);
12690
12691     oct = tvb_get_guint8(tvb, curr_offset);
12692
12693     if (oct == iei)
12694     {
12695         item =
12696             proto_tree_add_text(tree,
12697                 tvb, curr_offset, -1,
12698                 "%s%s",
12699                 elem_names[idx].strptr,
12700                 (name_add == NULL) || (name_add[0] == '\0') ? "" : name_add);
12701
12702         subtree = proto_item_add_subtree(item, elem_ett[idx]);
12703
12704         proto_tree_add_uint(subtree,
12705             (BSSAP_PDU_TYPE_BSSMAP == pdu_type) ? hf_gsm_a_bssmap_elem_id : hf_gsm_a_dtap_elem_id, tvb,
12706             curr_offset, 1, oct);
12707
12708         if (elem_funcs[idx] == NULL)
12709         {
12710             /* BAD THING, CANNOT DETERMINE LENGTH */
12711
12712             proto_tree_add_text(subtree,
12713                 tvb, curr_offset + 1, 1,
12714                 "No element dissector, rest of dissection may be incorrect");
12715
12716             consumed = 1;
12717         }
12718         else
12719         {
12720             gchar *a_add_string;
12721
12722             a_add_string=ep_alloc(1024);
12723             a_add_string[0] = '\0';
12724             consumed = (*elem_funcs[idx])(tvb, subtree, curr_offset + 1, -1, a_add_string, 1024);
12725
12726             if (a_add_string[0] != '\0')
12727             {
12728                 proto_item_append_text(item, "%s", a_add_string);
12729             }
12730         }
12731
12732         consumed++;
12733
12734         proto_item_set_len(item, consumed);
12735     }
12736
12737     return(consumed);
12738 }
12739
12740 /*
12741  * Type Value (TV) element dissector
12742  * Where top half nibble is IEI and bottom half nibble is value.
12743  *
12744  * Length cannot be used in these functions, big problem if a element dissector
12745  * is not defined for these.
12746  */
12747 static guint8
12748 elem_tv_short(tvbuff_t *tvb, proto_tree *tree, guint8 iei, gint pdu_type, int idx, guint32 offset, const gchar *name_add)
12749 {
12750     guint8              oct;
12751     guint8              consumed;
12752     guint32             curr_offset;
12753     proto_tree          *subtree;
12754     proto_item          *item;
12755     const value_string  *elem_names;
12756     gint                *elem_ett;
12757     guint8 (**elem_funcs)(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
12758
12759     curr_offset = offset;
12760     consumed = 0;
12761
12762     SET_ELEM_VARS(pdu_type, elem_names, elem_ett, elem_funcs);
12763
12764     oct = tvb_get_guint8(tvb, curr_offset);
12765
12766     if ((oct & 0xf0) == (iei & 0xf0))
12767     {
12768         item =
12769             proto_tree_add_text(tree,
12770                 tvb, curr_offset, -1,
12771                 "%s%s",
12772                 elem_names[idx].strptr,
12773                 (name_add == NULL) || (name_add[0] == '\0') ? "" : name_add);
12774
12775         subtree = proto_item_add_subtree(item, elem_ett[idx]);
12776
12777         other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
12778         proto_tree_add_text(subtree,
12779             tvb, curr_offset, 1,
12780             "%s :  Element ID",
12781             a_bigbuf);
12782
12783         if (elem_funcs[idx] == NULL)
12784         {
12785             /* BAD THING, CANNOT DETERMINE LENGTH */
12786
12787             proto_tree_add_text(subtree,
12788                 tvb, curr_offset, 1,
12789                 "No element dissector, rest of dissection may be incorrect");
12790
12791             consumed++;
12792         }
12793         else
12794         {
12795             gchar *a_add_string;
12796
12797             a_add_string=ep_alloc(1024);
12798             a_add_string[0] = '\0';
12799             consumed = (*elem_funcs[idx])(tvb, subtree, curr_offset, -1, a_add_string, 1024);
12800
12801             if (a_add_string[0] != '\0')
12802             {
12803                 proto_item_append_text(item, "%s", a_add_string);
12804             }
12805         }
12806
12807         proto_item_set_len(item, consumed);
12808     }
12809
12810     return(consumed);
12811 }
12812
12813 /*
12814  * Type (T) element dissector
12815  */
12816 static guint8
12817 elem_t(tvbuff_t *tvb, proto_tree *tree, guint8 iei, gint pdu_type, int idx, guint32 offset, const gchar *name_add)
12818 {
12819     guint8              oct;
12820     guint32             curr_offset;
12821     guint8              consumed;
12822     const value_string  *elem_names;
12823     gint                *elem_ett;
12824     guint8 (**elem_funcs)(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
12825
12826     curr_offset = offset;
12827     consumed = 0;
12828
12829     SET_ELEM_VARS(pdu_type, elem_names, elem_ett, elem_funcs);
12830
12831     oct = tvb_get_guint8(tvb, curr_offset);
12832
12833     if (oct == iei)
12834     {
12835         proto_tree_add_uint_format(tree,
12836             (BSSAP_PDU_TYPE_BSSMAP == pdu_type) ? hf_gsm_a_bssmap_elem_id : hf_gsm_a_dtap_elem_id, tvb,
12837             curr_offset, 1, oct,
12838             "%s%s",
12839             elem_names[idx].strptr,
12840             (name_add == NULL) || (name_add[0] == '\0') ? "" : name_add);
12841
12842         consumed = 1;
12843     }
12844
12845     return(consumed);
12846 }
12847
12848 /*
12849  * Length Value (LV) element dissector
12850  */
12851 static guint8
12852 elem_lv(tvbuff_t *tvb, proto_tree *tree, gint pdu_type, int idx, guint32 offset, guint len, const gchar *name_add)
12853 {
12854     guint8              parm_len;
12855     guint8              consumed;
12856     guint32             curr_offset;
12857     proto_tree          *subtree;
12858     proto_item          *item;
12859     const value_string  *elem_names;
12860     gint                *elem_ett;
12861     guint8 (**elem_funcs)(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
12862
12863     len = len;
12864     curr_offset = offset;
12865     consumed = 0;
12866
12867     SET_ELEM_VARS(pdu_type, elem_names, elem_ett, elem_funcs);
12868
12869     parm_len = tvb_get_guint8(tvb, curr_offset);
12870
12871     item =
12872         proto_tree_add_text(tree,
12873             tvb, curr_offset, parm_len + 1,
12874             "%s%s",
12875             elem_names[idx].strptr,
12876             (name_add == NULL) || (name_add[0] == '\0') ? "" : name_add);
12877
12878     subtree = proto_item_add_subtree(item, elem_ett[idx]);
12879
12880     proto_tree_add_uint(subtree, hf_gsm_a_length, tvb,
12881         curr_offset, 1, parm_len);
12882
12883     if (parm_len > 0)
12884     {
12885         if (elem_funcs[idx] == NULL)
12886         {
12887             proto_tree_add_text(subtree,
12888                 tvb, curr_offset + 1, parm_len,
12889                 "Element Value");
12890
12891             consumed = parm_len;
12892         }
12893         else
12894         {
12895             gchar *a_add_string;
12896
12897             a_add_string=ep_alloc(1024);
12898             a_add_string[0] = '\0';
12899             consumed =
12900                 (*elem_funcs[idx])(tvb, subtree, curr_offset + 1,
12901                     parm_len, a_add_string, 1024);
12902
12903             if (a_add_string[0] != '\0')
12904             {
12905                 proto_item_append_text(item, "%s", a_add_string);
12906             }
12907         }
12908     }
12909
12910     return(consumed + 1);
12911 }
12912
12913 /*
12914  * Value (V) element dissector
12915  *
12916  * Length cannot be used in these functions, big problem if a element dissector
12917  * is not defined for these.
12918  */
12919 static guint8
12920 elem_v(tvbuff_t *tvb, proto_tree *tree, gint pdu_type, int idx, guint32 offset)
12921 {
12922     guint8              consumed;
12923     guint32             curr_offset;
12924     const value_string  *elem_names;
12925     gint                *elem_ett;
12926     guint8 (**elem_funcs)(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
12927
12928     curr_offset = offset;
12929     consumed = 0;
12930
12931     SET_ELEM_VARS(pdu_type, elem_names, elem_ett, elem_funcs);
12932
12933     if (elem_funcs[idx] == NULL)
12934     {
12935         /* BAD THING, CANNOT DETERMINE LENGTH */
12936
12937         proto_tree_add_text(tree,
12938             tvb, curr_offset, 1,
12939             "No element dissector, rest of dissection may be incorrect");
12940
12941         consumed = 1;
12942     }
12943     else
12944     {
12945         gchar *a_add_string;
12946
12947         a_add_string=ep_alloc(1024);
12948         a_add_string[0] = '\0';
12949         consumed = (*elem_funcs[idx])(tvb, tree, curr_offset, -1, a_add_string, 1024);
12950     }
12951
12952     return(consumed);
12953 }
12954
12955 #define ELEM_MAND_TLV(EMT_iei, EMT_pdu_type, EMT_elem_idx, EMT_elem_name_addition) \
12956 {\
12957     if ((consumed = elem_tlv(tvb, tree, (guint8) EMT_iei, EMT_pdu_type, EMT_elem_idx, curr_offset, curr_len, EMT_elem_name_addition)) > 0) \
12958     { \
12959         curr_offset += consumed; \
12960         curr_len -= consumed; \
12961     } \
12962     else \
12963     { \
12964         proto_tree_add_text(tree, \
12965             tvb, curr_offset, 0, \
12966             "Missing Mandatory element (0x%02x) %s%s, rest of dissection is suspect", \
12967                 EMT_iei, \
12968                 (EMT_pdu_type == BSSAP_PDU_TYPE_BSSMAP) ? \
12969                     gsm_bssmap_elem_strings[EMT_elem_idx].strptr : gsm_dtap_elem_strings[EMT_elem_idx].strptr, \
12970                 (EMT_elem_name_addition == NULL) || (EMT_elem_name_addition[0] == '\0') ? "" : EMT_elem_name_addition \
12971             ); \
12972     } \
12973     if (curr_len <= 0) return; \
12974 }
12975
12976 #define ELEM_OPT_TLV(EOT_iei, EOT_pdu_type, EOT_elem_idx, EOT_elem_name_addition) \
12977 {\
12978     if ((consumed = elem_tlv(tvb, tree, (guint8) EOT_iei, EOT_pdu_type, EOT_elem_idx, curr_offset, curr_len, EOT_elem_name_addition)) > 0) \
12979     { \
12980         curr_offset += consumed; \
12981         curr_len -= consumed; \
12982     } \
12983     if (curr_len <= 0) return; \
12984 }
12985
12986 #define ELEM_MAND_TV(EMT_iei, EMT_pdu_type, EMT_elem_idx, EMT_elem_name_addition) \
12987 {\
12988     if ((consumed = elem_tv(tvb, tree, (guint8) EMT_iei, EMT_pdu_type, EMT_elem_idx, curr_offset, EMT_elem_name_addition)) > 0) \
12989     { \
12990         curr_offset += consumed; \
12991         curr_len -= consumed; \
12992     } \
12993     else \
12994     { \
12995         proto_tree_add_text(tree, \
12996             tvb, curr_offset, 0, \
12997             "Missing Mandatory element (0x%02x) %s%s, rest of dissection is suspect", \
12998                 EMT_iei, \
12999                 (EMT_pdu_type == BSSAP_PDU_TYPE_BSSMAP) ? \
13000                     gsm_bssmap_elem_strings[EMT_elem_idx].strptr : gsm_dtap_elem_strings[EMT_elem_idx].strptr, \
13001                 (EMT_elem_name_addition == NULL) || (EMT_elem_name_addition[0] == '\0') ? "" : EMT_elem_name_addition \
13002             ); \
13003     } \
13004     if (curr_len <= 0) return; \
13005 }
13006
13007 #define ELEM_OPT_TV(EOT_iei, EOT_pdu_type, EOT_elem_idx, EOT_elem_name_addition) \
13008 {\
13009     if ((consumed = elem_tv(tvb, tree, (guint8) EOT_iei, EOT_pdu_type, EOT_elem_idx, curr_offset, EOT_elem_name_addition)) > 0) \
13010     { \
13011         curr_offset += consumed; \
13012         curr_len -= consumed; \
13013     } \
13014     if (curr_len <= 0) return; \
13015 }
13016
13017 #define ELEM_OPT_TV_SHORT(EOT_iei, EOT_pdu_type, EOT_elem_idx, EOT_elem_name_addition) \
13018 {\
13019     if ((consumed = elem_tv_short(tvb, tree, EOT_iei, EOT_pdu_type, EOT_elem_idx, curr_offset, EOT_elem_name_addition)) > 0) \
13020     { \
13021         curr_offset += consumed; \
13022         curr_len -= consumed; \
13023     } \
13024     if (curr_len <= 0) return; \
13025 }
13026
13027 #define ELEM_OPT_T(EOT_iei, EOT_pdu_type, EOT_elem_idx, EOT_elem_name_addition) \
13028 {\
13029     if ((consumed = elem_t(tvb, tree, (guint8) EOT_iei, EOT_pdu_type, EOT_elem_idx, curr_offset, EOT_elem_name_addition)) > 0) \
13030     { \
13031         curr_offset += consumed; \
13032         curr_len -= consumed; \
13033     } \
13034     if (curr_len <= 0) return; \
13035 }
13036
13037 #define ELEM_MAND_LV(EML_pdu_type, EML_elem_idx, EML_elem_name_addition) \
13038 {\
13039     if ((consumed = elem_lv(tvb, tree, EML_pdu_type, EML_elem_idx, curr_offset, curr_len, EML_elem_name_addition)) > 0) \
13040     { \
13041         curr_offset += consumed; \
13042         curr_len -= consumed; \
13043     } \
13044     else \
13045     { \
13046         /* Mandatory, but nothing we can do */ \
13047     } \
13048     if (curr_len <= 0) return; \
13049 }
13050
13051 #define ELEM_MAND_V(EMV_pdu_type, EMV_elem_idx) \
13052 {\
13053     if ((consumed = elem_v(tvb, tree, EMV_pdu_type, EMV_elem_idx, curr_offset)) > 0) \
13054     { \
13055         curr_offset += consumed; \
13056         curr_len -= consumed; \
13057     } \
13058     else \
13059     { \
13060         /* Mandatory, but nothing we can do */ \
13061     } \
13062     if (curr_len <= 0) return; \
13063 }
13064
13065
13066 /* MESSAGE FUNCTIONS */
13067
13068 /*
13069  *  [2] 3.2.1.1
13070  */
13071 static void
13072 bssmap_ass_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13073 {
13074     guint32     curr_offset;
13075     guint32     consumed;
13076     guint       curr_len;
13077
13078     curr_offset = offset;
13079     curr_len = len;
13080
13081     is_uplink = IS_UPLINK_FALSE;
13082
13083     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CHAN_TYPE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CHAN_TYPE, "");
13084
13085     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_L3_HEADER_INFO].value, BSSAP_PDU_TYPE_BSSMAP, BE_L3_HEADER_INFO, "");
13086
13087     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_PRIO].value, BSSAP_PDU_TYPE_BSSMAP, BE_PRIO, "");
13088
13089     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CIC].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC, "");
13090
13091     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_DOWN_DTX_FLAG].value, BSSAP_PDU_TYPE_BSSMAP, BE_DOWN_DTX_FLAG, "");
13092
13093     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_INT_BAND].value, BSSAP_PDU_TYPE_BSSMAP, BE_INT_BAND, "");
13094
13095     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_CM_INFO_2].value, BSSAP_PDU_TYPE_BSSMAP, BE_CM_INFO_2, "");
13096
13097     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_GROUP_CALL_REF].value, BSSAP_PDU_TYPE_BSSMAP, BE_GROUP_CALL_REF, "");
13098
13099     ELEM_OPT_T(gsm_bssmap_elem_strings[BE_TALKER_FLAG].value, BSSAP_PDU_TYPE_BSSMAP, BE_TALKER_FLAG, "");
13100
13101     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_LSA_ACC_CTRL].value, BSSAP_PDU_TYPE_BSSMAP, BE_LSA_ACC_CTRL, "");
13102
13103     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13104 }
13105
13106 /*
13107  *  [2] 3.2.1.2
13108  */
13109 static void
13110 bssmap_ass_complete(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13111 {
13112     guint32     curr_offset;
13113     guint32     consumed;
13114     guint       curr_len;
13115
13116     curr_offset = offset;
13117     curr_len = len;
13118
13119     is_uplink = IS_UPLINK_TRUE;
13120
13121     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_RR_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_RR_CAUSE, "");
13122
13123     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CIC].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC, "");
13124
13125     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_CELL_ID].value, BSSAP_PDU_TYPE_BSSMAP, BE_CELL_ID, "");
13126
13127     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CHOSEN_CHAN].value, BSSAP_PDU_TYPE_BSSMAP, BE_CHOSEN_CHAN, "");
13128
13129     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CHOSEN_ENC_ALG].value, BSSAP_PDU_TYPE_BSSMAP, BE_CHOSEN_ENC_ALG, "");
13130
13131     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CCT_POOL].value, BSSAP_PDU_TYPE_BSSMAP, BE_CCT_POOL, "");
13132
13133     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_SPEECH_VER].value, BSSAP_PDU_TYPE_BSSMAP, BE_SPEECH_VER, " (Chosen)");
13134
13135     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_LSA_ID].value, BSSAP_PDU_TYPE_BSSMAP, BE_LSA_ID, "");
13136
13137     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13138 }
13139
13140 /*
13141  *  [2] 3.2.1.3
13142  */
13143 static void
13144 bssmap_ass_failure(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13145 {
13146     guint32     curr_offset;
13147     guint32     consumed;
13148     guint       curr_len;
13149
13150     curr_offset = offset;
13151     curr_len = len;
13152
13153     is_uplink = IS_UPLINK_TRUE;
13154
13155     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
13156
13157     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_RR_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_RR_CAUSE, "");
13158
13159     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CCT_POOL].value, BSSAP_PDU_TYPE_BSSMAP, BE_CCT_POOL, "");
13160
13161     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_CCT_POOL_LIST].value, BSSAP_PDU_TYPE_BSSMAP, BE_CCT_POOL_LIST, "");
13162
13163     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13164 }
13165
13166 /*
13167  *  [2] 3.2.1.4
13168  */
13169 static void
13170 bssmap_block(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13171 {
13172     guint32     curr_offset;
13173     guint32     consumed;
13174     guint       curr_len;
13175
13176     curr_offset = offset;
13177     curr_len = len;
13178
13179     is_uplink = IS_UPLINK_TRUE;
13180
13181     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
13182
13183     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_CIC].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC, "");
13184
13185     ELEM_OPT_T(gsm_bssmap_elem_strings[BE_CONN_REL_REQ].value, BSSAP_PDU_TYPE_BSSMAP, BE_CONN_REL_REQ, "");
13186
13187     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13188 }
13189
13190 /*
13191  *  [2] 3.2.1.5
13192  */
13193 static void
13194 bssmap_block_ack(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13195 {
13196     guint32     curr_offset;
13197     guint32     consumed;
13198     guint       curr_len;
13199
13200     curr_offset = offset;
13201     curr_len = len;
13202
13203     is_uplink = IS_UPLINK_TRUE;
13204
13205     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_CIC].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC, "");
13206
13207     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13208 }
13209
13210 /*
13211  *  [2] 3.2.1.6
13212  */
13213 static void
13214 bssmap_unblock(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13215 {
13216     guint32     curr_offset;
13217     guint32     consumed;
13218     guint       curr_len;
13219
13220     curr_offset = offset;
13221     curr_len = len;
13222
13223     is_uplink = IS_UPLINK_TRUE;
13224
13225     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_CIC].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC, "");
13226
13227     ELEM_OPT_T(gsm_bssmap_elem_strings[BE_CONN_REL_REQ].value, BSSAP_PDU_TYPE_BSSMAP, BE_CONN_REL_REQ, "");
13228
13229     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13230 }
13231
13232 /*
13233  *  [2] 3.2.1.7
13234  */
13235 static void
13236 bssmap_unblock_ack(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13237 {
13238     guint32     curr_offset;
13239     guint32     consumed;
13240     guint       curr_len;
13241
13242     curr_offset = offset;
13243     curr_len = len;
13244
13245     is_uplink = IS_UPLINK_TRUE;
13246
13247     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_CIC].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC, "");
13248
13249     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13250 }
13251
13252 /*
13253  *  [2] 3.2.1.8
13254  */
13255 static void
13256 bssmap_ho_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13257 {
13258     guint32     curr_offset;
13259     guint32     consumed;
13260     guint       curr_len;
13261
13262     curr_offset = offset;
13263     curr_len = len;
13264
13265     is_uplink = IS_UPLINK_FALSE;
13266
13267     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CHAN_TYPE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CHAN_TYPE, "");
13268
13269     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_ENC_INFO].value, BSSAP_PDU_TYPE_BSSMAP, BE_ENC_INFO, "");
13270
13271     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CM_INFO_1].value, BSSAP_PDU_TYPE_BSSMAP, BE_CM_INFO_1, "");
13272
13273     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_CM_INFO_2].value, BSSAP_PDU_TYPE_BSSMAP, BE_CM_INFO_2, "");
13274
13275     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CELL_ID].value, BSSAP_PDU_TYPE_BSSMAP, BE_CELL_ID, " (Serving)");
13276
13277     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_PRIO].value, BSSAP_PDU_TYPE_BSSMAP, BE_PRIO, "");
13278
13279     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CIC].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC, "");
13280
13281     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_DOWN_DTX_FLAG].value, BSSAP_PDU_TYPE_BSSMAP, BE_DOWN_DTX_FLAG, "");
13282
13283     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CELL_ID].value, BSSAP_PDU_TYPE_BSSMAP, BE_CELL_ID, " (Target)");
13284
13285     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_INT_BAND].value, BSSAP_PDU_TYPE_BSSMAP, BE_INT_BAND, "");
13286
13287     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
13288
13289     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_CM_INFO_3].value, BSSAP_PDU_TYPE_BSSMAP, BE_CM_INFO_3, "");
13290
13291     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CURR_CHAN_1].value, BSSAP_PDU_TYPE_BSSMAP, BE_CURR_CHAN_1, "");
13292
13293     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_SPEECH_VER].value, BSSAP_PDU_TYPE_BSSMAP, BE_SPEECH_VER, " (Used)");
13294
13295     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_GROUP_CALL_REF].value, BSSAP_PDU_TYPE_BSSMAP, BE_GROUP_CALL_REF, "");
13296
13297     ELEM_OPT_T(gsm_bssmap_elem_strings[BE_TALKER_FLAG].value, BSSAP_PDU_TYPE_BSSMAP, BE_TALKER_FLAG, "");
13298
13299     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CONF_EVO_IND].value, BSSAP_PDU_TYPE_BSSMAP, BE_CONF_EVO_IND, "");
13300
13301     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CHOSEN_ENC_ALG].value, BSSAP_PDU_TYPE_BSSMAP, BE_CHOSEN_ENC_ALG, " (Serving)");
13302
13303     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_OLD2NEW_INFO].value, BSSAP_PDU_TYPE_BSSMAP, BE_OLD2NEW_INFO, "");
13304
13305     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_LSA_INFO].value, BSSAP_PDU_TYPE_BSSMAP, BE_LSA_INFO, "");
13306
13307     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_LSA_ACC_CTRL].value, BSSAP_PDU_TYPE_BSSMAP, BE_LSA_ACC_CTRL, "");
13308
13309     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13310 }
13311
13312 /*
13313  *  [2] 3.2.1.9
13314  */
13315 static void
13316 bssmap_ho_reqd(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13317 {
13318     guint32     curr_offset;
13319     guint32     consumed;
13320     guint       curr_len;
13321
13322     curr_offset = offset;
13323     curr_len = len;
13324
13325     is_uplink = IS_UPLINK_TRUE;
13326
13327     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
13328
13329     ELEM_OPT_T(gsm_bssmap_elem_strings[BE_RESP_REQ].value, BSSAP_PDU_TYPE_BSSMAP, BE_RESP_REQ, "");
13330
13331     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CELL_ID_LIST].value, BSSAP_PDU_TYPE_BSSMAP, BE_CELL_ID_LIST, " (Preferred)");
13332
13333     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_CCT_POOL_LIST].value, BSSAP_PDU_TYPE_BSSMAP, BE_CCT_POOL_LIST, "");
13334
13335     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CURR_CHAN_1].value, BSSAP_PDU_TYPE_BSSMAP, BE_CURR_CHAN_1, "");
13336
13337     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_SPEECH_VER].value, BSSAP_PDU_TYPE_BSSMAP, BE_SPEECH_VER, " (Used)");
13338
13339     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_QUE_IND].value, BSSAP_PDU_TYPE_BSSMAP, BE_QUE_IND, "");
13340
13341     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_OLD2NEW_INFO].value, BSSAP_PDU_TYPE_BSSMAP, BE_OLD2NEW_INFO, "");
13342
13343     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13344 }
13345
13346 /*
13347  *  [2] 3.2.1.10
13348  */
13349 static void
13350 bssmap_ho_req_ack(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13351 {
13352     guint32     curr_offset;
13353     guint32     consumed;
13354     guint       curr_len;
13355
13356     curr_offset = offset;
13357     curr_len = len;
13358
13359     is_uplink = IS_UPLINK_TRUE;
13360
13361     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_L3_INFO].value, BSSAP_PDU_TYPE_BSSMAP, BE_L3_INFO, "");
13362
13363     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CHOSEN_CHAN].value, BSSAP_PDU_TYPE_BSSMAP, BE_CHOSEN_CHAN, "");
13364
13365     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CHOSEN_ENC_ALG].value, BSSAP_PDU_TYPE_BSSMAP, BE_CHOSEN_ENC_ALG, "");
13366
13367     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CCT_POOL].value, BSSAP_PDU_TYPE_BSSMAP, BE_CCT_POOL, "");
13368
13369     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_SPEECH_VER].value, BSSAP_PDU_TYPE_BSSMAP, BE_SPEECH_VER, " (Chosen)");
13370
13371     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CIC].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC, "");
13372
13373     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_LSA_ID].value, BSSAP_PDU_TYPE_BSSMAP, BE_LSA_ID, "");
13374
13375     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13376 }
13377
13378 /*
13379  *  [2] 3.2.1.11
13380  */
13381 static void
13382 bssmap_ho_cmd(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13383 {
13384     guint32     curr_offset;
13385     guint32     consumed;
13386     guint       curr_len;
13387
13388     curr_offset = offset;
13389     curr_len = len;
13390
13391     is_uplink = IS_UPLINK_FALSE;
13392
13393     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_L3_INFO].value, BSSAP_PDU_TYPE_BSSMAP, BE_L3_INFO, "");
13394
13395     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_CELL_ID].value, BSSAP_PDU_TYPE_BSSMAP, BE_CELL_ID, "");
13396
13397     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13398 }
13399
13400 /*
13401  *  [2] 3.2.1.12
13402  */
13403 static void
13404 bssmap_ho_complete(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13405 {
13406     guint32     curr_offset;
13407     guint32     consumed;
13408     guint       curr_len;
13409
13410     curr_offset = offset;
13411     curr_len = len;
13412
13413     is_uplink = IS_UPLINK_TRUE;
13414
13415     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_RR_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_RR_CAUSE, "");
13416
13417     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13418 }
13419
13420 /*
13421  *  [2] 3.2.1.14
13422  */
13423 static void
13424 bssmap_ho_cand_enq(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13425 {
13426     guint32     curr_offset;
13427     guint32     consumed;
13428     guint       curr_len;
13429
13430     curr_offset = offset;
13431     curr_len = len;
13432
13433     is_uplink = IS_UPLINK_FALSE;
13434
13435     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_NUM_MS].value, BSSAP_PDU_TYPE_BSSMAP, BE_NUM_MS, "");
13436
13437     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CELL_ID_LIST].value, BSSAP_PDU_TYPE_BSSMAP, BE_CELL_ID_LIST, "");
13438
13439     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CELL_ID].value, BSSAP_PDU_TYPE_BSSMAP, BE_CELL_ID, "");
13440
13441     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13442 }
13443
13444 /*
13445  *  [2] 3.2.1.15
13446  */
13447 static void
13448 bssmap_ho_cand_resp(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13449 {
13450     guint32     curr_offset;
13451     guint32     consumed;
13452     guint       curr_len;
13453
13454     curr_offset = offset;
13455     curr_len = len;
13456
13457     is_uplink = IS_UPLINK_TRUE;
13458
13459     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_NUM_MS].value, BSSAP_PDU_TYPE_BSSMAP, BE_NUM_MS, "");
13460
13461     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CELL_ID].value, BSSAP_PDU_TYPE_BSSMAP, BE_CELL_ID, "");
13462
13463     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13464 }
13465
13466 /*
13467  *  [2] 3.2.1.16
13468  */
13469 static void
13470 bssmap_ho_failure(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13471 {
13472     guint32     curr_offset;
13473     guint32     consumed;
13474     guint       curr_len;
13475
13476     curr_offset = offset;
13477     curr_len = len;
13478
13479     is_uplink = IS_UPLINK_TRUE;
13480
13481     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
13482
13483     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_RR_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_RR_CAUSE, "");
13484
13485     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CCT_POOL].value, BSSAP_PDU_TYPE_BSSMAP, BE_CCT_POOL, "");
13486
13487     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_CCT_POOL_LIST].value, BSSAP_PDU_TYPE_BSSMAP, BE_CCT_POOL_LIST, "");
13488
13489     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13490 }
13491
13492 /*
13493  *  [2] 3.2.1.19
13494  */
13495 static void
13496 bssmap_paging(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13497 {
13498     guint32     curr_offset;
13499     guint32     consumed;
13500     guint       curr_len;
13501
13502     curr_offset = offset;
13503     curr_len = len;
13504
13505     is_uplink = IS_UPLINK_FALSE;
13506
13507     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_IMSI].value, BSSAP_PDU_TYPE_BSSMAP, BE_IMSI, "");
13508
13509     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_TMSI].value, BSSAP_PDU_TYPE_BSSMAP, BE_TMSI, "");
13510
13511     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CELL_ID_LIST].value, BSSAP_PDU_TYPE_BSSMAP, BE_CELL_ID_LIST, "");
13512
13513     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CHAN_NEEDED].value, BSSAP_PDU_TYPE_BSSMAP, BE_CHAN_NEEDED, "");
13514
13515     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_EMLPP_PRIO].value, BSSAP_PDU_TYPE_BSSMAP, BE_EMLPP_PRIO, "");
13516
13517     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13518 }
13519
13520 /*
13521  *  [2] 3.2.1.20
13522  */
13523 static void
13524 bssmap_clear_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13525 {
13526     guint32     curr_offset;
13527     guint32     consumed;
13528     guint       curr_len;
13529
13530     curr_offset = offset;
13531     curr_len = len;
13532
13533     is_uplink = IS_UPLINK_TRUE;
13534
13535     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
13536
13537     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13538 }
13539
13540 /*
13541  *  [2] 3.2.1.21
13542  */
13543 static void
13544 bssmap_clear_cmd(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13545 {
13546     guint32     curr_offset;
13547     guint32     consumed;
13548     guint       curr_len;
13549
13550     curr_offset = offset;
13551     curr_len = len;
13552
13553     is_uplink = IS_UPLINK_FALSE;
13554
13555     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_L3_HEADER_INFO].value, BSSAP_PDU_TYPE_BSSMAP, BE_L3_HEADER_INFO, "");
13556
13557     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
13558
13559     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13560 }
13561
13562 /*
13563  *  [2] 3.2.1.23
13564  */
13565 static void
13566 bssmap_reset(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13567 {
13568     guint32     curr_offset;
13569     guint32     consumed;
13570     guint       curr_len;
13571
13572     curr_offset = offset;
13573     curr_len = len;
13574
13575     is_uplink = IS_UPLINK_UNKNOWN;
13576
13577     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
13578
13579     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13580 }
13581
13582 /*
13583  *  [2] 3.2.1.25
13584  */
13585 static void
13586 bssmap_ho_performed(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13587 {
13588     guint32     curr_offset;
13589     guint32     consumed;
13590     guint       curr_len;
13591
13592     curr_offset = offset;
13593     curr_len = len;
13594
13595     is_uplink = IS_UPLINK_TRUE;
13596
13597     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
13598
13599     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CELL_ID].value, BSSAP_PDU_TYPE_BSSMAP, BE_CELL_ID, "");
13600
13601     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CHOSEN_CHAN].value, BSSAP_PDU_TYPE_BSSMAP, BE_CHOSEN_CHAN, "");
13602
13603     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CHOSEN_ENC_ALG].value, BSSAP_PDU_TYPE_BSSMAP, BE_CHOSEN_ENC_ALG, "");
13604
13605     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_SPEECH_VER].value, BSSAP_PDU_TYPE_BSSMAP, BE_SPEECH_VER, " (Chosen)");
13606
13607     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_LSA_ID].value, BSSAP_PDU_TYPE_BSSMAP, BE_LSA_ID, "");
13608
13609     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13610 }
13611
13612 /*
13613  *  [2] 3.2.1.26
13614  */
13615 static void
13616 bssmap_overload(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13617 {
13618     guint32     curr_offset;
13619     guint32     consumed;
13620     guint       curr_len;
13621
13622     curr_offset = offset;
13623     curr_len = len;
13624
13625     is_uplink = IS_UPLINK_TRUE;
13626
13627     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
13628
13629     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_CELL_ID].value, BSSAP_PDU_TYPE_BSSMAP, BE_CELL_ID, "");
13630
13631     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13632 }
13633
13634 /*
13635  *  [2] 3.2.1.29
13636  */
13637 static void
13638 bssmap_cm_upd(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13639 {
13640     guint32     curr_offset;
13641     guint32     consumed;
13642     guint       curr_len;
13643
13644     curr_offset = offset;
13645     curr_len = len;
13646
13647     is_uplink = IS_UPLINK_FALSE;
13648
13649     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CM_INFO_2].value, BSSAP_PDU_TYPE_BSSMAP, BE_CM_INFO_2, "");
13650
13651     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_CM_INFO_3].value, BSSAP_PDU_TYPE_BSSMAP, BE_CM_INFO_3, "");
13652
13653     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13654 }
13655
13656 /*
13657  *  [2] 3.2.1.30
13658  */
13659 static void
13660 bssmap_ciph_mode_cmd(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13661 {
13662     guint32     curr_offset;
13663     guint32     consumed;
13664     guint       curr_len;
13665
13666     curr_offset = offset;
13667     curr_len = len;
13668
13669     is_uplink = IS_UPLINK_FALSE;
13670
13671     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_L3_HEADER_INFO].value, BSSAP_PDU_TYPE_BSSMAP, BE_L3_HEADER_INFO, "");
13672
13673     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_ENC_INFO].value, BSSAP_PDU_TYPE_BSSMAP, BE_ENC_INFO, "");
13674
13675     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CIPH_RESP_MODE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIPH_RESP_MODE, "");
13676
13677     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13678 }
13679
13680 /*
13681  *  [2] 3.2.1.31
13682  */
13683 static void
13684 bssmap_ciph_mode_complete(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13685 {
13686     guint32     curr_offset;
13687     guint32     consumed;
13688     guint       curr_len;
13689
13690     curr_offset = offset;
13691     curr_len = len;
13692
13693     is_uplink = IS_UPLINK_TRUE;
13694
13695     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_L3_MSG].value, BSSAP_PDU_TYPE_BSSMAP, BE_L3_MSG, "");
13696
13697     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CHOSEN_ENC_ALG].value, BSSAP_PDU_TYPE_BSSMAP, BE_CHOSEN_ENC_ALG, "");
13698
13699     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13700 }
13701
13702 /*
13703  * [2] 3.2.1.32
13704  */
13705 static void
13706 bssmap_cl3_info(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13707 {
13708     guint8      consumed;
13709     guint32     curr_offset;
13710     guint       curr_len;
13711
13712     curr_offset = offset;
13713     curr_len = len;
13714
13715     is_uplink = IS_UPLINK_TRUE;
13716
13717     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CELL_ID].value, BSSAP_PDU_TYPE_BSSMAP, BE_CELL_ID, "");
13718
13719     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_L3_INFO].value, BSSAP_PDU_TYPE_BSSMAP, BE_L3_INFO, "");
13720
13721     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CHOSEN_CHAN].value, BSSAP_PDU_TYPE_BSSMAP, BE_CHOSEN_CHAN, "");
13722
13723     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_LSA_ID_LIST].value, BSSAP_PDU_TYPE_BSSMAP, BE_LSA_ID_LIST, "");
13724
13725     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_APDU].value, BSSAP_PDU_TYPE_BSSMAP, BE_APDU, "");
13726
13727     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13728 }
13729
13730 /*
13731  * [2] 3.2.1.34
13732  */
13733 static void
13734 bssmap_sapi_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13735 {
13736     guint8      consumed;
13737     guint32     curr_offset;
13738     guint       curr_len;
13739
13740     curr_offset = offset;
13741     curr_len = len;
13742
13743     is_uplink = IS_UPLINK_TRUE;
13744
13745     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_DLCI].value, BSSAP_PDU_TYPE_BSSMAP, BE_DLCI, "");
13746
13747     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
13748
13749     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13750 }
13751
13752 /*
13753  *  [2] 3.2.1.37
13754  */
13755 static void
13756 bssmap_ho_reqd_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13757 {
13758     guint32     curr_offset;
13759     guint32     consumed;
13760     guint       curr_len;
13761
13762     curr_offset = offset;
13763     curr_len = len;
13764
13765     is_uplink = IS_UPLINK_FALSE;
13766
13767     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
13768
13769     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13770 }
13771
13772 /*
13773  *  [2] 3.2.1.38
13774  */
13775 static void
13776 bssmap_reset_cct(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13777 {
13778     guint32     curr_offset;
13779     guint32     consumed;
13780     guint       curr_len;
13781
13782     curr_offset = offset;
13783     curr_len = len;
13784
13785     is_uplink = IS_UPLINK_TRUE;
13786
13787     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_CIC].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC, "");
13788
13789     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
13790
13791     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13792 }
13793
13794 /*
13795  *  [2] 3.2.1.39
13796  */
13797 static void
13798 bssmap_reset_cct_ack(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13799 {
13800     guint32     curr_offset;
13801     guint32     consumed;
13802     guint       curr_len;
13803
13804     curr_offset = offset;
13805     curr_len = len;
13806
13807     is_uplink = IS_UPLINK_TRUE;
13808
13809     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_CIC].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC, "");
13810
13811     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13812 }
13813
13814 /*
13815  *  [2] 3.2.1.41
13816  */
13817 static void
13818 bssmap_cct_group_block(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13819 {
13820     guint32     curr_offset;
13821     guint32     consumed;
13822     guint       curr_len;
13823
13824     curr_offset = offset;
13825     curr_len = len;
13826
13827     is_uplink = IS_UPLINK_TRUE;
13828
13829     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
13830
13831     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_CIC].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC, "");
13832
13833     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_CIC_LIST].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC_LIST, "");
13834
13835     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13836 }
13837
13838 /*
13839  *  [2] 3.2.1.42
13840  */
13841 static void
13842 bssmap_cct_group_block_ack(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13843 {
13844     guint32     curr_offset;
13845     guint32     consumed;
13846     guint       curr_len;
13847
13848     curr_offset = offset;
13849     curr_len = len;
13850
13851     is_uplink = IS_UPLINK_TRUE;
13852
13853     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_CIC].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC, "");
13854
13855     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_CIC_LIST].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC_LIST, "");
13856
13857     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13858 }
13859
13860 /*
13861  *  [2] 3.2.1.43
13862  */
13863 static void
13864 bssmap_cct_group_unblock(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13865 {
13866     guint32     curr_offset;
13867     guint32     consumed;
13868     guint       curr_len;
13869
13870     curr_offset = offset;
13871     curr_len = len;
13872
13873     is_uplink = IS_UPLINK_TRUE;
13874
13875     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_CIC].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC, "");
13876
13877     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_CIC_LIST].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC_LIST, "");
13878
13879     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13880 }
13881
13882 /*
13883  *  [2] 3.2.1.44
13884  */
13885 static void
13886 bssmap_cct_group_unblock_ack(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13887 {
13888     guint32     curr_offset;
13889     guint32     consumed;
13890     guint       curr_len;
13891
13892     curr_offset = offset;
13893     curr_len = len;
13894
13895     is_uplink = IS_UPLINK_TRUE;
13896
13897     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_CIC].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC, "");
13898
13899     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_CIC_LIST].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC_LIST, "");
13900
13901     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13902 }
13903
13904 /*
13905  *  [2] 3.2.1.45
13906  */
13907 static void
13908 bssmap_confusion(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13909 {
13910     guint32     curr_offset;
13911     guint32     consumed;
13912     guint       curr_len;
13913
13914     curr_offset = offset;
13915     curr_len = len;
13916
13917     is_uplink = IS_UPLINK_TRUE;
13918
13919     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
13920
13921     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_DIAG].value, BSSAP_PDU_TYPE_BSSMAP, BE_DIAG, "");
13922
13923     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13924 }
13925
13926 /*
13927  *  [2] 3.2.1.47
13928  */
13929 static void
13930 bssmap_unequipped_cct(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13931 {
13932     guint32     curr_offset;
13933     guint32     consumed;
13934     guint       curr_len;
13935
13936     curr_offset = offset;
13937     curr_len = len;
13938
13939     is_uplink = IS_UPLINK_TRUE;
13940
13941     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_CIC].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC, "");
13942
13943     ELEM_OPT_TV(gsm_bssmap_elem_strings[BE_CIC_LIST].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC_LIST, "");
13944
13945     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13946 }
13947
13948 /*
13949  *  [2] 3.2.1.48
13950  */
13951 static void
13952 bssmap_ciph_mode_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13953 {
13954     guint32     curr_offset;
13955     guint32     consumed;
13956     guint       curr_len;
13957
13958     curr_offset = offset;
13959     curr_len = len;
13960
13961     is_uplink = IS_UPLINK_TRUE;
13962
13963     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
13964
13965     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13966 }
13967
13968 /*
13969  *  [2] 3.2.1.49
13970  */
13971 static void
13972 bssmap_load_ind(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
13973 {
13974     guint32     curr_offset;
13975     guint32     consumed;
13976     guint       curr_len;
13977
13978     curr_offset = offset;
13979     curr_len = len;
13980
13981     is_uplink = IS_UPLINK_TRUE;
13982
13983     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_TIME_IND].value, BSSAP_PDU_TYPE_BSSMAP, BE_TIME_IND, "");
13984
13985     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CELL_ID].value, BSSAP_PDU_TYPE_BSSMAP, BE_CELL_ID, "");
13986
13987     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CELL_ID_LIST].value, BSSAP_PDU_TYPE_BSSMAP, BE_CELL_ID_LIST, " (Target)");
13988
13989     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_RES_SIT].value, BSSAP_PDU_TYPE_BSSMAP, BE_RES_SIT, "");
13990
13991     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
13992
13993     EXTRANEOUS_DATA_CHECK(curr_len, 0);
13994 }
13995
13996 /*
13997  *  [2] 3.2.1.66
13998  */
13999 static void
14000 bssmap_change_cct(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14001 {
14002     guint32     curr_offset;
14003     guint32     consumed;
14004     guint       curr_len;
14005
14006     curr_offset = offset;
14007     curr_len = len;
14008
14009     is_uplink = IS_UPLINK_FALSE;
14010
14011     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_CAUSE].value, BSSAP_PDU_TYPE_BSSMAP, BE_CAUSE, "");
14012
14013     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14014 }
14015
14016 /*
14017  *  [2] 3.2.1.67
14018  */
14019 static void
14020 bssmap_change_cct_ack(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14021 {
14022     guint32     curr_offset;
14023     guint32     consumed;
14024     guint       curr_len;
14025
14026     curr_offset = offset;
14027     curr_len = len;
14028
14029     is_uplink = IS_UPLINK_TRUE;
14030
14031     ELEM_MAND_TV(gsm_bssmap_elem_strings[BE_CIC].value, BSSAP_PDU_TYPE_BSSMAP, BE_CIC, "");
14032
14033     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14034 }
14035
14036 /*
14037  *  [2] 3.2.1.68
14038  */
14039 static void
14040 bssmap_common_id(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14041 {
14042     guint32     curr_offset;
14043     guint32     consumed;
14044     guint       curr_len;
14045
14046     curr_offset = offset;
14047     curr_len = len;
14048
14049     is_uplink = IS_UPLINK_FALSE;
14050
14051     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_IMSI].value, BSSAP_PDU_TYPE_BSSMAP, BE_IMSI, "");
14052
14053     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14054 }
14055
14056 /*
14057  *  [2] 3.2.1.69
14058  */
14059 static void
14060 bssmap_lsa_info(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14061 {
14062     guint32     curr_offset;
14063     guint32     consumed;
14064     guint       curr_len;
14065
14066     curr_offset = offset;
14067     curr_len = len;
14068
14069     is_uplink = IS_UPLINK_FALSE;
14070
14071     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_LSA_INFO].value, BSSAP_PDU_TYPE_BSSMAP, BE_LSA_INFO, "");
14072
14073     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14074 }
14075
14076 /*
14077  *  [2] 3.2.1.70
14078  */
14079 static void
14080 bssmap_conn_oriented(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14081 {
14082     guint32     curr_offset;
14083     guint32     consumed;
14084     guint       curr_len;
14085
14086     curr_offset = offset;
14087     curr_len = len;
14088
14089     is_uplink = IS_UPLINK_FALSE;
14090
14091     ELEM_MAND_TLV(gsm_bssmap_elem_strings[BE_APDU].value, BSSAP_PDU_TYPE_BSSMAP, BE_APDU, "");
14092
14093     ELEM_OPT_TLV(gsm_bssmap_elem_strings[BE_SEG].value, BSSAP_PDU_TYPE_BSSMAP, BE_SEG, "");
14094
14095     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14096 }
14097
14098
14099 #define NUM_GSM_BSSMAP_MSG (sizeof(gsm_a_bssmap_msg_strings)/sizeof(value_string))
14100 static gint ett_gsm_bssmap_msg[NUM_GSM_BSSMAP_MSG];
14101 static void (*bssmap_msg_fcn[])(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len) = {
14102     bssmap_ass_req,     /* Assignment Request */
14103     bssmap_ass_complete,        /* Assignment Complete */
14104     bssmap_ass_failure, /* Assignment Failure */
14105     bssmap_ho_req,      /* Handover Request */
14106     bssmap_ho_reqd,     /* Handover Required */
14107     bssmap_ho_req_ack,  /* Handover Request Acknowledge */
14108     bssmap_ho_cmd,      /* Handover Command */
14109     bssmap_ho_complete, /* Handover Complete */
14110     NULL /* no associated data */,      /* Handover Succeeded */
14111     bssmap_ho_failure,  /* Handover Failure */
14112     bssmap_ho_performed,        /* Handover Performed */
14113     bssmap_ho_cand_enq, /* Handover Candidate Enquire */
14114     bssmap_ho_cand_resp,        /* Handover Candidate Response */
14115     bssmap_ho_reqd_rej, /* Handover Required Reject */
14116     NULL /* no associated data */,      /* Handover Detect */
14117     bssmap_clear_cmd,   /* Clear Command */
14118     NULL /* no associated data */,      /* Clear Complete */
14119     bssmap_clear_req,   /* Clear Request */
14120     NULL,       /* Reserved */
14121     NULL,       /* Reserved */
14122     bssmap_sapi_rej,    /* SAPI 'n' Reject */
14123     bssmap_confusion,   /* Confusion */
14124     NULL,       /* Suspend */
14125     NULL,       /* Resume */
14126     bssmap_conn_oriented,       /* Connection Oriented Information */
14127     NULL,       /* Perform Location Request */
14128     bssmap_lsa_info,    /* LSA Information */
14129     NULL,       /* Perform Location Response */
14130     NULL,       /* Perform Location Abort */
14131     bssmap_common_id,   /* Common Id */
14132     bssmap_reset,       /* Reset */
14133     NULL /* no associated data */,      /* Reset Acknowledge */
14134     bssmap_overload,    /* Overload */
14135     NULL,       /* Reserved */
14136     bssmap_reset_cct,   /* Reset Circuit */
14137     bssmap_reset_cct_ack,       /* Reset Circuit Acknowledge */
14138     NULL,       /* MSC Invoke Trace */
14139     NULL,       /* BSS Invoke Trace */
14140     NULL,       /* Connectionless Information */
14141     bssmap_block,       /* Block */
14142     bssmap_block_ack,   /* Blocking Acknowledge */
14143     bssmap_unblock,     /* Unblock */
14144     bssmap_unblock_ack, /* Unblocking Acknowledge */
14145     bssmap_cct_group_block,     /* Circuit Group Block */
14146     bssmap_cct_group_block_ack, /* Circuit Group Blocking Acknowledge */
14147     bssmap_cct_group_unblock,   /* Circuit Group Unblock */
14148     bssmap_cct_group_unblock_ack,       /* Circuit Group Unblocking Acknowledge */
14149     bssmap_unequipped_cct,      /* Unequipped Circuit */
14150     bssmap_change_cct,  /* Change Circuit */
14151     bssmap_change_cct_ack,      /* Change Circuit Acknowledge */
14152     NULL,       /* Resource Request */
14153     NULL,       /* Resource Indication */
14154     bssmap_paging,      /* Paging */
14155     bssmap_ciph_mode_cmd,       /* Cipher Mode Command */
14156     bssmap_cm_upd,      /* Classmark Update */
14157     bssmap_ciph_mode_complete,  /* Cipher Mode Complete */
14158     NULL /* no associated data */,      /* Queuing Indication */
14159     bssmap_cl3_info,    /* Complete Layer 3 Information */
14160     NULL /* no associated data */,      /* Classmark Request */
14161     bssmap_ciph_mode_rej,       /* Cipher Mode Reject */
14162     bssmap_load_ind,    /* Load Indication */
14163     NULL,       /* VGCS/VBS Setup */
14164     NULL,       /* VGCS/VBS Setup Ack */
14165     NULL,       /* VGCS/VBS Setup Refuse */
14166     NULL,       /* VGCS/VBS Assignment Request */
14167     NULL,       /* VGCS/VBS Assignment Result */
14168     NULL,       /* VGCS/VBS Assignment Failure */
14169     NULL,       /* VGCS/VBS Queuing Indication */
14170     NULL,       /* Uplink Request */
14171     NULL,       /* Uplink Request Acknowledge */
14172     NULL,       /* Uplink Request Confirmation */
14173     NULL,       /* Uplink Release Indication */
14174     NULL,       /* Uplink Reject Command */
14175     NULL,       /* Uplink Release Command */
14176     NULL,       /* Uplink Seized Command */
14177     NULL,       /* NONE */
14178 };
14179
14180 /*
14181  * [4] 9.2.2
14182  */
14183 static void
14184 dtap_mm_auth_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14185 {
14186     guint32     curr_offset;
14187     guint32     consumed;
14188     guint       curr_len;
14189     guint8      oct;
14190     proto_tree  *subtree;
14191     proto_item  *item;
14192
14193     curr_offset = offset;
14194     curr_len = len;
14195
14196     is_uplink = IS_UPLINK_FALSE;
14197
14198     /*
14199      * special dissection for Cipher Key Sequence Number
14200      */
14201     oct = tvb_get_guint8(tvb, curr_offset);
14202
14203     other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
14204     proto_tree_add_text(tree,
14205         tvb, curr_offset, 1,
14206         "%s :  Spare",
14207         a_bigbuf);
14208
14209     item =
14210         proto_tree_add_text(tree,
14211             tvb, curr_offset, 1,
14212             gsm_dtap_elem_strings[DE_CIPH_KEY_SEQ_NUM].strptr);
14213
14214     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_CIPH_KEY_SEQ_NUM]);
14215
14216     other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
14217     proto_tree_add_text(subtree,
14218         tvb, curr_offset, 1,
14219         "%s :  Spare",
14220         a_bigbuf);
14221
14222     other_decode_bitfield_value(a_bigbuf, oct, 0x07, 8);
14223
14224     switch (oct & 0x07)
14225     {
14226     case 0x07:
14227         proto_tree_add_text(subtree,
14228             tvb, curr_offset, 1,
14229             "%s :  Ciphering Key Sequence Number: No key is available",
14230             a_bigbuf);
14231         break;
14232
14233     default:
14234         proto_tree_add_text(subtree,
14235             tvb, curr_offset, 1,
14236             "%s :  Ciphering Key Sequence Number: %u",
14237             a_bigbuf,
14238             oct & 0x07);
14239         break;
14240     }
14241
14242     curr_offset++;
14243     curr_len--;
14244
14245     if (curr_len <= 0) return;
14246
14247     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_AUTH_PARAM_RAND);
14248
14249     ELEM_OPT_TLV(0x20, BSSAP_PDU_TYPE_DTAP, DE_AUTH_PARAM_AUTN, "");
14250
14251     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14252 }
14253
14254 /*
14255  * [4] 9.2.3
14256  */
14257 static void
14258 dtap_mm_auth_resp(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14259 {
14260     guint32     curr_offset;
14261     guint32     consumed;
14262     guint       curr_len;
14263
14264     curr_offset = offset;
14265     curr_len = len;
14266
14267     is_uplink = IS_UPLINK_TRUE;
14268
14269     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_AUTH_RESP_PARAM);
14270
14271     ELEM_OPT_TLV(0x21, BSSAP_PDU_TYPE_DTAP, DE_AUTH_RESP_PARAM_EXT, "");
14272
14273     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14274 }
14275
14276 /*
14277  * [4] 9.2.3a
14278  */
14279 static void
14280 dtap_mm_auth_fail(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14281 {
14282     guint32     curr_offset;
14283     guint32     consumed;
14284     guint       curr_len;
14285
14286     curr_offset = offset;
14287     curr_len = len;
14288
14289     is_uplink = IS_UPLINK_TRUE;
14290
14291     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_REJ_CAUSE);
14292
14293     ELEM_OPT_TLV(0x22, BSSAP_PDU_TYPE_DTAP, DE_AUTH_FAIL_PARAM, "");
14294
14295     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14296 }
14297
14298 /*
14299  * [3] 9.2.4
14300  */
14301 static void
14302 dtap_mm_cm_reestab_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14303 {
14304     guint32     curr_offset;
14305     guint32     consumed;
14306     guint       curr_len;
14307     guint8      oct;
14308     proto_tree  *subtree;
14309     proto_item  *item;
14310
14311     curr_offset = offset;
14312     curr_len = len;
14313
14314     is_uplink = IS_UPLINK_TRUE;
14315
14316     /*
14317      * special dissection for Cipher Key Sequence Number
14318      */
14319     oct = tvb_get_guint8(tvb, curr_offset);
14320
14321     other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
14322     proto_tree_add_text(tree,
14323         tvb, curr_offset, 1,
14324         "%s :  Spare",
14325         a_bigbuf);
14326
14327     item =
14328         proto_tree_add_text(tree,
14329             tvb, curr_offset, 1,
14330             gsm_dtap_elem_strings[DE_CIPH_KEY_SEQ_NUM].strptr);
14331
14332     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_CIPH_KEY_SEQ_NUM]);
14333
14334     other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
14335     proto_tree_add_text(subtree,
14336         tvb, curr_offset, 1,
14337         "%s :  Spare",
14338         a_bigbuf);
14339
14340     other_decode_bitfield_value(a_bigbuf, oct, 0x07, 8);
14341
14342     switch (oct & 0x07)
14343     {
14344     case 0x07:
14345         proto_tree_add_text(subtree,
14346             tvb, curr_offset, 1,
14347             "%s :  Ciphering Key Sequence Number: No key is available",
14348             a_bigbuf);
14349         break;
14350
14351     default:
14352         proto_tree_add_text(subtree,
14353             tvb, curr_offset, 1,
14354             "%s :  Ciphering Key Sequence Number: %u",
14355             a_bigbuf,
14356             oct & 0x07);
14357         break;
14358     }
14359
14360     curr_offset++;
14361     curr_len--;
14362
14363     if (curr_len <= 0) return;
14364
14365     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_MS_CM_2, "");
14366
14367     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_MID, "");
14368
14369     ELEM_OPT_TV(0x13, BSSAP_PDU_TYPE_DTAP, DE_LAI, "");
14370
14371     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14372 }
14373
14374 /*
14375  * [3] 9.2.5a
14376  */
14377 static void
14378 dtap_mm_cm_srvc_prompt(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14379 {
14380     guint32     curr_offset;
14381     guint32     consumed;
14382     guint       curr_len;
14383
14384     curr_offset = offset;
14385     curr_len = len;
14386
14387     is_uplink = IS_UPLINK_FALSE;
14388
14389     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_PD_SAPI);
14390
14391     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14392 }
14393
14394 /*
14395  * [4] 9.2.6
14396  */
14397 static void
14398 dtap_mm_cm_srvc_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14399 {
14400     guint32     curr_offset;
14401     guint32     consumed;
14402     guint       curr_len;
14403
14404     curr_offset = offset;
14405     curr_len = len;
14406
14407     is_uplink = IS_UPLINK_FALSE;
14408
14409     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_REJ_CAUSE);
14410
14411     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14412 }
14413
14414 /*
14415  * [4] 9.2.8
14416  */
14417 static void
14418 dtap_mm_abort(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14419 {
14420     guint32     curr_offset;
14421     guint32     consumed;
14422     guint       curr_len;
14423
14424     curr_offset = offset;
14425     curr_len = len;
14426
14427     is_uplink = IS_UPLINK_FALSE;
14428
14429     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_REJ_CAUSE);
14430
14431     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14432 }
14433
14434 /*
14435  * [3] 9.2.9
14436  */
14437 static void
14438 dtap_mm_cm_srvc_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14439 {
14440     guint32     curr_offset;
14441     guint32     consumed;
14442     guint       curr_len;
14443     guint8      oct;
14444     proto_tree  *subtree;
14445     proto_item  *item;
14446     const gchar *str;
14447
14448     curr_offset = offset;
14449     curr_len = len;
14450
14451     is_uplink = IS_UPLINK_TRUE;
14452
14453     /*
14454      * special dissection for CM Service Type
14455      */
14456     oct = tvb_get_guint8(tvb, curr_offset);
14457
14458     item =
14459         proto_tree_add_text(tree,
14460             tvb, curr_offset, 1,
14461             gsm_dtap_elem_strings[DE_CIPH_KEY_SEQ_NUM].strptr);
14462
14463     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_CIPH_KEY_SEQ_NUM]);
14464
14465     other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
14466     proto_tree_add_text(subtree,
14467         tvb, curr_offset, 1,
14468         "%s :  Spare",
14469         a_bigbuf);
14470
14471     other_decode_bitfield_value(a_bigbuf, oct, 0x70, 8);
14472
14473     switch ((oct & 0x70) >> 4)
14474     {
14475     case 0x07:
14476         proto_tree_add_text(subtree,
14477             tvb, curr_offset, 1,
14478             "%s :  Ciphering Key Sequence Number: No key is available",
14479             a_bigbuf);
14480         break;
14481
14482     default:
14483         proto_tree_add_text(subtree,
14484             tvb, curr_offset, 1,
14485             "%s :  Ciphering Key Sequence Number: %u",
14486             a_bigbuf,
14487             (oct & 0x70) >> 4);
14488         break;
14489     }
14490
14491     item =
14492         proto_tree_add_text(tree,
14493             tvb, curr_offset, 1,
14494             gsm_dtap_elem_strings[DE_CM_SRVC_TYPE].strptr);
14495
14496     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_CM_SRVC_TYPE]);
14497
14498     switch (oct & 0x0f)
14499     {
14500     case 0x01: str = "Mobile originating call establishment or packet mode connection establishment"; break;
14501     case 0x02: str = "Emergency call establishment"; break;
14502     case 0x04: str = "Short message service"; break;
14503     case 0x08: str = "Supplementary service activation"; break;
14504     case 0x09: str = "Voice group call establishment"; break;
14505     case 0x0a: str = "Voice broadcast call establishment"; break;
14506     case 0x0b: str = "Location Services"; break;
14507     default:
14508         str = "Reserved";
14509         break;
14510     }
14511
14512     other_decode_bitfield_value(a_bigbuf, oct, 0x0f, 8);
14513     proto_tree_add_text(subtree,
14514         tvb, curr_offset, 1,
14515         "%s :  Service Type: (%u) %s",
14516         a_bigbuf,
14517         oct & 0x0f,
14518         str);
14519
14520     curr_offset++;
14521     curr_len--;
14522
14523     if (curr_len <= 0) return;
14524
14525     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_MS_CM_2, "");
14526
14527     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_MID, "");
14528
14529     ELEM_OPT_TV_SHORT(0x80, BSSAP_PDU_TYPE_DTAP, DE_PRIO, "");
14530
14531     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14532 }
14533
14534 /*
14535  * [3] 9.2.10
14536  */
14537 static void
14538 dtap_mm_id_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14539 {
14540     guint8      oct;
14541     guint32     curr_offset;
14542     guint       curr_len;
14543     proto_tree  *subtree;
14544     proto_item  *item;
14545     const gchar *str;
14546
14547     curr_offset = offset;
14548     curr_len = len;
14549
14550     is_uplink = IS_UPLINK_FALSE;
14551
14552     /*
14553      * special dissection for Identity Type
14554      */
14555     oct = tvb_get_guint8(tvb, curr_offset);
14556
14557     other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
14558     proto_tree_add_text(tree,
14559         tvb, curr_offset, 1,
14560         "%s :  Spare",
14561         a_bigbuf);
14562
14563     item =
14564         proto_tree_add_text(tree,
14565             tvb, curr_offset, 1,
14566             gsm_dtap_elem_strings[DE_ID_TYPE].strptr);
14567
14568     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_ID_TYPE]);
14569
14570     other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
14571     proto_tree_add_text(subtree,
14572         tvb, curr_offset, 1,
14573         "%s :  Spare",
14574         a_bigbuf);
14575
14576     switch (oct & 0x07)
14577     {
14578     case 1: str = "IMSI"; break;
14579     case 2: str = "IMEI"; break;
14580     case 3: str = "IMEISV"; break;
14581     case 4: str = "TMSI"; break;
14582     default:
14583         str = "Reserved";
14584         break;
14585     }
14586
14587     other_decode_bitfield_value(a_bigbuf, oct, 0x07, 8);
14588     proto_tree_add_text(subtree,
14589         tvb, curr_offset, 1,
14590         "%s :  Type of identity: %s",
14591         a_bigbuf,
14592         str);
14593
14594     curr_offset++;
14595     curr_len--;
14596
14597     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14598 }
14599
14600 /*
14601  * [3] 9.2.11
14602  */
14603 static void
14604 dtap_mm_id_resp(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14605 {
14606     guint32     curr_offset;
14607     guint32     consumed;
14608     guint       curr_len;
14609
14610     curr_offset = offset;
14611     curr_len = len;
14612
14613     is_uplink = IS_UPLINK_TRUE;
14614
14615     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_MID, "");
14616
14617     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14618 }
14619
14620 /*
14621  * [3] 9.2.12
14622  */
14623 static void
14624 dtap_mm_imsi_det_ind(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14625 {
14626     guint32     curr_offset;
14627     guint32     consumed;
14628     guint       curr_len;
14629
14630     curr_offset = offset;
14631     curr_len = len;
14632
14633     is_uplink = IS_UPLINK_TRUE;
14634
14635     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_MS_CM_1);
14636
14637     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_MID, "");
14638
14639     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14640 }
14641
14642 /*
14643  * [3] 9.2.13
14644  */
14645 static void
14646 dtap_mm_loc_upd_acc(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14647 {
14648     guint32     curr_offset;
14649     guint32     consumed;
14650     guint       curr_len;
14651
14652     curr_offset = offset;
14653     curr_len = len;
14654
14655     is_uplink = IS_UPLINK_FALSE;
14656
14657     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_LAI);
14658
14659     ELEM_OPT_TLV(0x17, BSSAP_PDU_TYPE_DTAP, DE_MID, "");
14660
14661     ELEM_OPT_T(0xa1, BSSAP_PDU_TYPE_DTAP, DE_FOP, "");
14662
14663     ELEM_OPT_T(0xa2, BSSAP_PDU_TYPE_DTAP, DE_CTS_PERM, "");
14664
14665     ELEM_OPT_TLV(0x4a, BSSAP_PDU_TYPE_DTAP, DE_PLMN_LIST, " Equivalent");
14666
14667     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14668 }
14669
14670 /*
14671  * [3] 9.2.14
14672  */
14673 static void
14674 dtap_mm_loc_upd_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14675 {
14676     guint32     curr_offset;
14677     guint32     consumed;
14678     guint       curr_len;
14679
14680     curr_offset = offset;
14681     curr_len = len;
14682
14683     is_uplink = IS_UPLINK_FALSE;
14684
14685     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_REJ_CAUSE);
14686
14687     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14688 }
14689
14690 /*
14691  * [3] 9.2.15
14692  */
14693 static void
14694 dtap_mm_loc_upd_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14695 {
14696     guint32     curr_offset;
14697     guint32     consumed;
14698     guint       curr_len;
14699     guint8      oct;
14700     proto_tree  *subtree;
14701     proto_item  *item;
14702     const gchar *str;
14703
14704     curr_offset = offset;
14705     curr_len = len;
14706
14707     is_uplink = IS_UPLINK_TRUE;
14708
14709     /*
14710      * special dissection for Location Updating Type
14711      */
14712     oct = tvb_get_guint8(tvb, curr_offset);
14713
14714     item =
14715         proto_tree_add_text(tree,
14716             tvb, curr_offset, 1,
14717             gsm_dtap_elem_strings[DE_CIPH_KEY_SEQ_NUM].strptr);
14718
14719     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_CIPH_KEY_SEQ_NUM]);
14720
14721     other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8);
14722     proto_tree_add_text(subtree,
14723         tvb, curr_offset, 1,
14724         "%s :  Spare",
14725         a_bigbuf);
14726
14727     other_decode_bitfield_value(a_bigbuf, oct, 0x70, 8);
14728
14729     switch ((oct & 0x70) >> 4)
14730     {
14731     case 0x07:
14732         proto_tree_add_text(subtree,
14733             tvb, curr_offset, 1,
14734             "%s :  Ciphering Key Sequence Number: No key is available",
14735             a_bigbuf);
14736         break;
14737
14738     default:
14739         proto_tree_add_text(subtree,
14740             tvb, curr_offset, 1,
14741             "%s :  Ciphering Key Sequence Number: %u",
14742             a_bigbuf,
14743             (oct & 0x70) >> 4);
14744         break;
14745     }
14746
14747     item =
14748         proto_tree_add_text(tree,
14749             tvb, curr_offset, 1,
14750             gsm_dtap_elem_strings[DE_LOC_UPD_TYPE].strptr);
14751
14752     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_LOC_UPD_TYPE]);
14753
14754     other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
14755     proto_tree_add_text(subtree,
14756         tvb, curr_offset, 1,
14757         "%s :  Follow-On Request (FOR): %s",
14758         a_bigbuf,
14759         (oct & 0x08) ? "Follow-on request pending" : "No follow-on request pending");
14760
14761     other_decode_bitfield_value(a_bigbuf, oct, 0x04, 8);
14762     proto_tree_add_text(subtree,
14763         tvb, curr_offset, 1,
14764         "%s :  Spare",
14765         a_bigbuf);
14766
14767     switch (oct & 0x03)
14768     {
14769     case 0: str = "Normal"; break;
14770     case 1: str = "Periodic"; break;
14771     case 2: str = "IMSI attach"; break;
14772     default:
14773         str = "Reserved";
14774         break;
14775     }
14776
14777     other_decode_bitfield_value(a_bigbuf, oct, 0x03, 8);
14778     proto_tree_add_text(subtree,
14779         tvb, curr_offset, 1,
14780         "%s :  Updating Type: %s",
14781         a_bigbuf,
14782         str);
14783
14784     proto_item_append_text(item, " - %s", str);
14785
14786     curr_offset++;
14787     curr_len--;
14788
14789     if (curr_len <= 0) return;
14790
14791     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_LAI);
14792
14793     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_MS_CM_1);
14794
14795     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_MID, "");
14796
14797     ELEM_OPT_TLV(0x33, BSSAP_PDU_TYPE_DTAP, DE_MS_CM_2, "");
14798
14799     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14800 }
14801
14802 /*
14803  * [4] 9.1.15a
14804  */
14805 void
14806 dtap_mm_mm_info(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14807 {
14808     guint32     curr_offset;
14809     guint32     consumed;
14810     guint       curr_len;
14811
14812     curr_offset = offset;
14813     curr_len = len;
14814
14815     is_uplink = IS_UPLINK_TRUE;
14816
14817     ELEM_OPT_TLV(0x43, BSSAP_PDU_TYPE_DTAP, DE_NETWORK_NAME, " - Full Name");
14818
14819     ELEM_OPT_TLV(0x45, BSSAP_PDU_TYPE_DTAP, DE_NETWORK_NAME, " - Short Name");
14820
14821     ELEM_OPT_TV(0x46, BSSAP_PDU_TYPE_DTAP, DE_TIME_ZONE, " - Local");
14822
14823     ELEM_OPT_TV(0x47, BSSAP_PDU_TYPE_DTAP, DE_TIME_ZONE_TIME, " - Universal Time and Local Time Zone");
14824
14825     ELEM_OPT_TLV(0x48, BSSAP_PDU_TYPE_DTAP, DE_LSA_ID, "");
14826
14827     ELEM_OPT_TLV(0x49, BSSAP_PDU_TYPE_DTAP, DE_DAY_SAVING_TIME, "");
14828
14829     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14830 }
14831
14832 /*
14833  * [4] 9.1.16
14834  */
14835 static void
14836 dtap_mm_mm_status(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14837 {
14838     guint32     curr_offset;
14839     guint32     consumed;
14840     guint       curr_len;
14841
14842     curr_offset = offset;
14843     curr_len = len;
14844
14845     is_uplink = IS_UPLINK_TRUE;
14846
14847     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_REJ_CAUSE);
14848
14849     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14850 }
14851
14852 /*
14853  * [3] 9.2.17
14854  */
14855 static void
14856 dtap_mm_tmsi_realloc_cmd(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14857 {
14858     guint32     curr_offset;
14859     guint32     consumed;
14860     guint       curr_len;
14861
14862     curr_offset = offset;
14863     curr_len = len;
14864
14865     is_uplink = IS_UPLINK_FALSE;
14866
14867     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_LAI);
14868
14869     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_MID, "");
14870
14871     EXTRANEOUS_DATA_CHECK(curr_len, 0);
14872 }
14873 /* 3GPP TS 24.008 version 4.7.0 Release 4
14874  * [3] 9.1.15
14875  */
14876 void
14877 dtap_rr_ho_cmd(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
14878 {
14879     guint32     curr_offset;
14880     guint32     consumed;
14881     guint       curr_len;
14882     curr_offset = offset;
14883     curr_len = len;
14884
14885         /* Mandatory Elemets
14886          * Cell description 10.5.2.2 
14887          */
14888         ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RR_CELL_DSC);
14889
14890         /* Description of the first channel,after time
14891          * Channel Description 2 10.5.2.5a
14892          */
14893         ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RR_CH_DSC2);
14894
14895         /* Handover Reference 10.5.2.15 */
14896         ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RR_HO_REF);
14897
14898         /* Power Command and Access type 10.5.2.28a */
14899         ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RR_POW_CMD_AND_ACC_TYPE);
14900
14901         /* optional elements */
14902
14903         /* Synchronization Indication 10.5.2.39 */
14904         ELEM_OPT_TV_SHORT(0xD0,BSSAP_PDU_TYPE_DTAP, DE_RR_SYNC_IND,"");
14905
14906         /* Frequency Short List 10.5.2.14 */
14907         ELEM_OPT_TV(0x02,BSSAP_PDU_TYPE_DTAP, DE_RR_FREQ_SHORT_LIST," - Frequency Short List, after time");
14908
14909         /* Frequency List 10.5.2.13 */
14910         ELEM_OPT_TLV(0x05, BSSAP_PDU_TYPE_DTAP, DE_RR_FREQ_LIST, " - Frequency List, after time");
14911
14912         /* Cell Channel Description 10.5.2.1b */
14913         ELEM_OPT_TV(0x62,BSSAP_PDU_TYPE_DTAP, DE_RR_CELL_CH_DSC, "");
14914
14915         /* Multislot Allocation 10.5.2.21b */
14916         ELEM_OPT_TLV(0x10,BSSAP_PDU_TYPE_DTAP, DE_RR_MULT_ALL, "");
14917
14918         /* Mode of the First Channel(Channel Set 1)) Channel Mode 10.5.2.6*/
14919         ELEM_OPT_TV(0x63,BSSAP_PDU_TYPE_DTAP, DE_RR_CH_MODE, " - Mode of the First Channel(Channel Set 1))");
14920
14921         /* Mode of Channel Set 2 Channel Mode 10.5.2.6*/
14922         ELEM_OPT_TV(0x11,BSSAP_PDU_TYPE_DTAP, DE_RR_CH_MODE, " - Mode of Channel Set 2");
14923
14924         /* Mode of Channel Set 3 Channel Mode 10.5.2.6*/        
14925         ELEM_OPT_TV(0x13,BSSAP_PDU_TYPE_DTAP, DE_RR_CH_MODE, " - Mode of Channel Set 3");
14926
14927         /* Mode of Channel Set 4 Channel Mode 10.5.2.6*/
14928         ELEM_OPT_TV(0x14,BSSAP_PDU_TYPE_DTAP, DE_RR_CH_MODE, " - Mode of Channel Set 4");
14929
14930         /* Mode of Channel Set 5 Channel Mode 10.5.2.6*/
14931         ELEM_OPT_TV(0x15,BSSAP_PDU_TYPE_DTAP, DE_RR_CH_MODE, " - Mode of Channel Set 5");
14932
14933         /* Mode of Channel Set 6 Channel Mode 10.5.2.6*/
14934         ELEM_OPT_TV(0x16,BSSAP_PDU_TYPE_DTAP, DE_RR_CH_MODE, " - Mode of Channel Set 6");
14935
14936         /* Mode of Channel Set 7 Channel Mode 10.5.2.6*/
14937         ELEM_OPT_TV(0x17,BSSAP_PDU_TYPE_DTAP, DE_RR_CH_MODE, " - Mode of Channel Set 7");
14938
14939         /* Mode of Channel Set 8 Channel Mode 10.5.2.6*/
14940         ELEM_OPT_TV(0x18,BSSAP_PDU_TYPE_DTAP, DE_RR_CH_MODE, " - Mode of Channel Set 8");
14941
14942         /* Description of the Second Channel, after time, Channel Description 10.5.2.5 */
14943         ELEM_OPT_TV(0x64,BSSAP_PDU_TYPE_DTAP, DE_RR_CH_DSC, " - Description of the Second Channel, after time");
14944
14945         /* Mode of the Second Channel, Channel Mode 2 10.5.2.7 */
14946         ELEM_OPT_TV(0x66,BSSAP_PDU_TYPE_DTAP, DE_RR_CH_MODE2, " - Mode of the Second Channel");
14947
14948         /* Frequency Channel Sequence, after time, Frequency Channel Sequence 10.5.2.12 */
14949         ELEM_OPT_TV(0x69,BSSAP_PDU_TYPE_DTAP, DE_RR_FREQ_CH_SEQ, " - Frequency Channel Sequence, after time");
14950
14951         /* Mobile Allocation, after time, Mobile Allocation 10.5.2.21 */
14952         ELEM_OPT_TLV(0x72,BSSAP_PDU_TYPE_DTAP, DE_RR_MOB_ALL, " - Mobile Allocation, after time");
14953         
14954         /* Starting Time 10.5.2.38 */
14955         ELEM_OPT_TV(0x7C,BSSAP_PDU_TYPE_DTAP, DE_RR_STARTING_TIME, "");
14956
14957         /* Real Time Difference, Time Difference 10.5.2.41 */
14958         ELEM_OPT_TV(0x7B,BSSAP_PDU_TYPE_DTAP, DE_RR_TIME_DIFF, " - Real Time Difference");
14959
14960         /* Timing Advance, Timing Advance 10.5.2.40 */
14961         ELEM_OPT_TV(0x7D,BSSAP_PDU_TYPE_DTAP, DE_RR_TIMING_ADV, "");
14962
14963         /* Frequency Short List, before time, Frequency Short List 10.5.2.14 */
14964         ELEM_OPT_TLV(0x19,BSSAP_PDU_TYPE_DTAP, DE_RR_FREQ_SHORT_LIST, " - Frequency Short List, before time");
14965
14966         /* Frequency List, before time, Frequency List 10.5.2.13 */
14967         ELEM_OPT_TV(0x12,BSSAP_PDU_TYPE_DTAP, DE_RR_FREQ_LIST, " - Frequency List, before time");
14968
14969         /* Description of the First Channel, before time,       Channel Description 2 10.5.2.5a*/
14970         ELEM_OPT_TV(0x1c,BSSAP_PDU_TYPE_DTAP, DE_RR_CH_DSC2, " - Description of the First Channel, before time");
14971
14972         /* Description of the Second Channel, before time,      Channel Description 10.5.2.5*/
14973         ELEM_OPT_TV(0x1d,BSSAP_PDU_TYPE_DTAP, DE_RR_CH_DSC, " - Description of the Second Channel, before time");
14974
14975         /* Frequency channel sequence before time,      Frequency channel sequence 10.5.2.12*/
14976         ELEM_OPT_TV(0x1e,BSSAP_PDU_TYPE_DTAP, DE_RR_FREQ_CH_SEQ, " - Frequency channel sequence before time");
14977
14978         /* Mobile Allocation, before time,      Mobile Allocation 10.5.2.21*/
14979         ELEM_OPT_TLV(0x21,BSSAP_PDU_TYPE_DTAP, DE_RR_MOB_ALL, " - Mobile Allocation, before time");
14980
14981         /* Cipher Mode Setting, Cipher Mode Setting 10.5.2.9*/
14982         ELEM_OPT_TV_SHORT(0x90,BSSAP_PDU_TYPE_DTAP, DE_RR_CIP_MODE_SET, "");
14983
14984         /* VGCS target mode Indication, VGCS target mode Indication 10.5.2.42a*/
14985         ELEM_OPT_TLV(0x01,BSSAP_PDU_TYPE_DTAP, DE_RR_VGCS_TAR_MODE_IND, "");
14986
14987         /* Multi-Rate configuration,    MultiRate configuration 10.5.2.21aa*/
14988         ELEM_OPT_TLV(0x03,BSSAP_PDU_TYPE_DTAP, DE_RR_MULTIRATE_CONF, "");
14989
14990         /* Dynamic ARFCN Mapping,       Dynamic ARFCN Mapping 10.5.2.11b*/
14991         ELEM_OPT_TLV(0x76,BSSAP_PDU_TYPE_DTAP, DE_RR_DYN_ARFCN_MAP, "");
14992
14993         /* VGCS Ciphering Parameters,   VGCS Ciphering Parameters 10.5.2.42b*/
14994         ELEM_OPT_TLV(0x04,BSSAP_PDU_TYPE_DTAP, DE_RR_VGCS_CIP_PAR, "");
14995
14996         /* Dedicated Service Information,       Dedicated Service Information 10.5.2.59*/
14997         ELEM_OPT_TV(0x51,BSSAP_PDU_TYPE_DTAP, DE_RR_DED_SERV_INF, "");
14998
14999         EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
15000
15001 }
15002 /*
15003  * [4] 9.1.25
15004  */
15005 static void
15006 dtap_rr_paging_resp(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15007 {
15008     guint32     curr_offset;
15009     guint32     consumed;
15010     guint       curr_len;
15011     guint8      oct;
15012     proto_tree  *subtree;
15013     proto_item  *item;
15014
15015     curr_offset = offset;
15016     curr_len = len;
15017
15018     is_uplink = IS_UPLINK_TRUE;
15019
15020     /*
15021      * special dissection for Cipher Key Sequence Number
15022      */
15023     oct = tvb_get_guint8(tvb, curr_offset);
15024
15025     other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
15026     proto_tree_add_text(tree,
15027         tvb, curr_offset, 1,
15028         "%s :  Spare",
15029         a_bigbuf);
15030
15031     item =
15032         proto_tree_add_text(tree,
15033             tvb, curr_offset, 1,
15034             gsm_dtap_elem_strings[DE_CIPH_KEY_SEQ_NUM].strptr);
15035
15036     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_CIPH_KEY_SEQ_NUM]);
15037
15038     other_decode_bitfield_value(a_bigbuf, oct, 0x08, 8);
15039     proto_tree_add_text(subtree,
15040         tvb, curr_offset, 1,
15041         "%s :  Spare",
15042         a_bigbuf);
15043
15044     other_decode_bitfield_value(a_bigbuf, oct, 0x07, 8);
15045
15046     switch (oct & 0x07)
15047     {
15048     case 0x07:
15049         proto_tree_add_text(subtree,
15050             tvb, curr_offset, 1,
15051             "%s :  Ciphering Key Sequence Number: No key is available",
15052             a_bigbuf);
15053         break;
15054
15055     default:
15056         proto_tree_add_text(subtree,
15057             tvb, curr_offset, 1,
15058             "%s :  Ciphering Key Sequence Number: %u",
15059             a_bigbuf,
15060             oct & 0x07);
15061         break;
15062     }
15063
15064     curr_offset++;
15065     curr_len--;
15066
15067     if (curr_len <= 0) return;
15068
15069     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_MS_CM_2, "");
15070
15071     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_MID, "");
15072
15073     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15074 }
15075
15076 /*
15077  * [4] 9.1.29
15078  */
15079 static void
15080 dtap_rr_rr_status(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15081 {
15082     guint32     curr_offset;
15083     guint32     consumed;
15084     guint       curr_len;
15085
15086     curr_offset = offset;
15087     curr_len = len;
15088
15089     is_uplink = IS_UPLINK_TRUE;
15090
15091     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RR_CAUSE);
15092
15093     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15094 }
15095
15096 /*
15097  * [4] 9.3.1
15098  */
15099 static void
15100 dtap_cc_alerting(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15101 {
15102     guint32     curr_offset;
15103     guint32     consumed;
15104     guint       curr_len;
15105
15106     curr_offset = offset;
15107     curr_len = len;
15108
15109     is_uplink = IS_UPLINK_TRUE;
15110
15111     ELEM_OPT_TLV(0x1c, BSSAP_PDU_TYPE_DTAP, DE_FACILITY, "");
15112
15113     ELEM_OPT_TLV(0x1e, BSSAP_PDU_TYPE_DTAP, DE_PROG_IND, "");
15114
15115     ELEM_OPT_TLV(0x7e, BSSAP_PDU_TYPE_DTAP, DE_USER_USER, "");
15116
15117     /* uplink only */
15118
15119     ELEM_OPT_TLV(0x7f, BSSAP_PDU_TYPE_DTAP, DE_SS_VER_IND, "");
15120
15121     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15122 }
15123
15124 /*
15125  * [4] 9.3.2
15126  */
15127 static void
15128 dtap_cc_call_conf(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15129 {
15130     guint32     curr_offset;
15131     guint32     consumed;
15132     guint       curr_len;
15133
15134     curr_offset = offset;
15135     curr_len = len;
15136
15137     is_uplink = IS_UPLINK_TRUE;
15138
15139     ELEM_OPT_TV_SHORT(0xd0, BSSAP_PDU_TYPE_DTAP, DE_REPEAT_IND, " BC repeat indicator");
15140
15141     ELEM_OPT_TLV(0x04, BSSAP_PDU_TYPE_DTAP, DE_BEARER_CAP, " 1");
15142
15143     ELEM_OPT_TLV(0x04, BSSAP_PDU_TYPE_DTAP, DE_BEARER_CAP, " 2");
15144
15145     ELEM_OPT_TLV(0x08, BSSAP_PDU_TYPE_DTAP, DE_CAUSE, "");
15146
15147     ELEM_OPT_TLV(0x15, BSSAP_PDU_TYPE_DTAP, DE_CC_CAP, "");
15148
15149     ELEM_OPT_TLV(0x2d, BSSAP_PDU_TYPE_DTAP, DE_SI, "");
15150
15151     ELEM_OPT_TLV(0x40, BSSAP_PDU_TYPE_DTAP, DE_SUP_CODEC_LIST, "");
15152
15153     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15154 }
15155
15156 /*
15157  * [4] 9.3.3
15158  */
15159 static void
15160 dtap_cc_call_proceed(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15161 {
15162     guint32     curr_offset;
15163     guint32     consumed;
15164     guint       curr_len;
15165
15166     curr_offset = offset;
15167     curr_len = len;
15168
15169     is_uplink = IS_UPLINK_FALSE;
15170
15171     ELEM_OPT_TV_SHORT(0xd0, BSSAP_PDU_TYPE_DTAP, DE_REPEAT_IND, " BC repeat indicator");
15172
15173     ELEM_OPT_TLV(0x04, BSSAP_PDU_TYPE_DTAP, DE_BEARER_CAP, " 1");
15174
15175     ELEM_OPT_TLV(0x04, BSSAP_PDU_TYPE_DTAP, DE_BEARER_CAP, " 2");
15176
15177     ELEM_OPT_TLV(0x1c, BSSAP_PDU_TYPE_DTAP, DE_FACILITY, "");
15178
15179     ELEM_OPT_TLV(0x1e, BSSAP_PDU_TYPE_DTAP, DE_PROG_IND, "");
15180
15181     ELEM_OPT_TV_SHORT(0x80, BSSAP_PDU_TYPE_DTAP, DE_PRIO, "");
15182
15183     ELEM_OPT_TLV(0x2f, BSSAP_PDU_TYPE_DTAP, DE_NET_CC_CAP, "");
15184
15185     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15186 }
15187
15188 /*
15189  * [4] 9.3.4
15190  */
15191 static void
15192 dtap_cc_congestion_control(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15193 {
15194     guint32     curr_offset;
15195     guint32     consumed;
15196     guint       curr_len;
15197     guint8      oct;
15198     proto_tree  *subtree;
15199     proto_item  *item;
15200     const gchar *str;
15201
15202     curr_offset = offset;
15203     curr_len = len;
15204
15205     is_uplink = IS_UPLINK_FALSE;
15206
15207     /*
15208      * special dissection for Congestion Level
15209      */
15210     oct = tvb_get_guint8(tvb, curr_offset);
15211
15212     other_decode_bitfield_value(a_bigbuf, oct, 0xf0, 8);
15213     proto_tree_add_text(tree,
15214         tvb, curr_offset, 1,
15215         "%s :  Spare",
15216         a_bigbuf);
15217
15218     item =
15219         proto_tree_add_text(tree,
15220             tvb, curr_offset, 1,
15221             gsm_dtap_elem_strings[DE_CONGESTION].strptr);
15222
15223     subtree = proto_item_add_subtree(item, ett_gsm_dtap_elem[DE_CONGESTION]);
15224
15225     switch (oct & 0x0f)
15226     {
15227     case 0: str = "Receiver ready"; break;
15228     case 15: str = "Receiver not ready"; break;
15229     default:
15230         str = "Reserved";
15231         break;
15232     }
15233
15234     other_decode_bitfield_value(a_bigbuf, oct, 0x0f, 8);
15235     proto_tree_add_text(subtree,
15236         tvb, curr_offset, 1,
15237         "%s :  Congestion level: %s",
15238         a_bigbuf,
15239         str);
15240
15241     curr_offset++;
15242     curr_len--;
15243
15244     if (curr_len <= 0) return;
15245
15246     ELEM_OPT_TLV(0x08, BSSAP_PDU_TYPE_DTAP, DE_CAUSE, "");
15247
15248     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15249 }
15250
15251 /*
15252  * [4] 9.3.5
15253  */
15254 static void
15255 dtap_cc_connect(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15256 {
15257     guint32     curr_offset;
15258     guint32     consumed;
15259     guint       curr_len;
15260
15261     curr_offset = offset;
15262     curr_len = len;
15263
15264     is_uplink = IS_UPLINK_TRUE;
15265
15266     ELEM_OPT_TLV(0x1c, BSSAP_PDU_TYPE_DTAP, DE_FACILITY, "");
15267
15268     ELEM_OPT_TLV(0x1e, BSSAP_PDU_TYPE_DTAP, DE_PROG_IND, "");
15269
15270     ELEM_OPT_TLV(0x4c, BSSAP_PDU_TYPE_DTAP, DE_CONN_NUM, "");
15271
15272     ELEM_OPT_TLV(0x4d, BSSAP_PDU_TYPE_DTAP, DE_CONN_SUB_ADDR, "");
15273
15274     ELEM_OPT_TLV(0x7e, BSSAP_PDU_TYPE_DTAP, DE_USER_USER, "");
15275
15276     /* uplink only */
15277
15278     ELEM_OPT_TLV(0x7f, BSSAP_PDU_TYPE_DTAP, DE_SS_VER_IND, "");
15279
15280     ELEM_OPT_TLV(0x2d, BSSAP_PDU_TYPE_DTAP, DE_SI, "");
15281
15282     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15283 }
15284
15285 /*
15286  * [4] 9.3.7
15287  */
15288 static void
15289 dtap_cc_disconnect(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15290 {
15291     guint32     curr_offset;
15292     guint32     consumed;
15293     guint       curr_len;
15294
15295     curr_offset = offset;
15296     curr_len = len;
15297
15298     is_uplink = IS_UPLINK_TRUE;
15299
15300     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_CAUSE, "");
15301
15302     ELEM_OPT_TLV(0x1c, BSSAP_PDU_TYPE_DTAP, DE_FACILITY, "");
15303
15304     ELEM_OPT_TLV(0x1e, BSSAP_PDU_TYPE_DTAP, DE_PROG_IND, "");
15305
15306     ELEM_OPT_TLV(0x7e, BSSAP_PDU_TYPE_DTAP, DE_USER_USER, "");
15307
15308     ELEM_OPT_TLV(0x7b, BSSAP_PDU_TYPE_DTAP, DE_ALLOWED_ACTIONS, "");
15309
15310     /* uplink only */
15311
15312     ELEM_OPT_TLV(0x7f, BSSAP_PDU_TYPE_DTAP, DE_SS_VER_IND, "");
15313
15314     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15315 }
15316
15317 /*
15318  * [4] 9.3.8
15319  */
15320 static void
15321 dtap_cc_emerg_setup(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15322 {
15323     guint32     curr_offset;
15324     guint32     consumed;
15325     guint       curr_len;
15326
15327     curr_offset = offset;
15328     curr_len = len;
15329
15330     is_uplink = IS_UPLINK_TRUE;
15331
15332     ELEM_OPT_TLV(0x04, BSSAP_PDU_TYPE_DTAP, DE_BEARER_CAP, "");
15333
15334     ELEM_OPT_TLV(0x2d, BSSAP_PDU_TYPE_DTAP, DE_SI, "");
15335
15336     ELEM_OPT_TLV(0x40, BSSAP_PDU_TYPE_DTAP, DE_SUP_CODEC_LIST, "");
15337
15338     ELEM_OPT_TLV(0x2e, BSSAP_PDU_TYPE_DTAP, DE_SRVC_CAT, " Emergency");
15339
15340     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15341 }
15342
15343 /*
15344  * [4] 9.3.9
15345  */
15346 static void
15347 dtap_cc_facility(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15348 {
15349     guint32     curr_offset;
15350     guint32     consumed;
15351     guint       curr_len;
15352
15353     curr_offset = offset;
15354     curr_len = len;
15355
15356     is_uplink = IS_UPLINK_TRUE;
15357
15358     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_FACILITY, "");
15359
15360     /* uplink only */
15361
15362     ELEM_OPT_TLV(0x7f, BSSAP_PDU_TYPE_DTAP, DE_SS_VER_IND, "");
15363
15364     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15365 }
15366
15367 /*
15368  * [4] 9.3.12
15369  */
15370 static void
15371 dtap_cc_hold_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15372 {
15373     guint32     curr_offset;
15374     guint32     consumed;
15375     guint       curr_len;
15376
15377     curr_offset = offset;
15378     curr_len = len;
15379
15380     is_uplink = IS_UPLINK_FALSE;
15381
15382     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_CAUSE, "");
15383
15384     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15385 }
15386
15387 /*
15388  * [4] 9.3.13
15389  */
15390 static void
15391 dtap_cc_modify(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15392 {
15393     guint32     curr_offset;
15394     guint32     consumed;
15395     guint       curr_len;
15396
15397     curr_offset = offset;
15398     curr_len = len;
15399
15400     is_uplink = IS_UPLINK_TRUE;
15401
15402     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_BEARER_CAP, "");
15403
15404     ELEM_OPT_TLV(0x7c, BSSAP_PDU_TYPE_DTAP, DE_LLC, "");
15405
15406     ELEM_OPT_TLV(0x7d, BSSAP_PDU_TYPE_DTAP, DE_HLC, "");
15407
15408     ELEM_OPT_T(0xa3, BSSAP_PDU_TYPE_DTAP, DE_REV_CALL_SETUP_DIR, "");
15409
15410     ELEM_OPT_T(0xa4, BSSAP_PDU_TYPE_DTAP, DE_IMM_MOD_IND, "");
15411
15412     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15413 }
15414
15415 /*
15416  * [4] 9.3.14
15417  */
15418 static void
15419 dtap_cc_modify_complete(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15420 {
15421     guint32     curr_offset;
15422     guint32     consumed;
15423     guint       curr_len;
15424
15425     curr_offset = offset;
15426     curr_len = len;
15427
15428     is_uplink = IS_UPLINK_TRUE;
15429
15430     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_BEARER_CAP, "");
15431
15432     ELEM_OPT_TLV(0x7c, BSSAP_PDU_TYPE_DTAP, DE_LLC, "");
15433
15434     ELEM_OPT_TLV(0x7d, BSSAP_PDU_TYPE_DTAP, DE_HLC, "");
15435
15436     ELEM_OPT_T(0xa3, BSSAP_PDU_TYPE_DTAP, DE_REV_CALL_SETUP_DIR, "");
15437
15438     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15439 }
15440
15441 /*
15442  * [4] 9.3.15
15443  */
15444 static void
15445 dtap_cc_modify_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15446 {
15447     guint32     curr_offset;
15448     guint32     consumed;
15449     guint       curr_len;
15450
15451     curr_offset = offset;
15452     curr_len = len;
15453
15454     is_uplink = IS_UPLINK_FALSE;
15455
15456     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_BEARER_CAP, "");
15457
15458     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_CAUSE, "");
15459
15460     ELEM_OPT_TLV(0x7c, BSSAP_PDU_TYPE_DTAP, DE_LLC, "");
15461
15462     ELEM_OPT_TLV(0x7d, BSSAP_PDU_TYPE_DTAP, DE_HLC, "");
15463
15464     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15465 }
15466
15467 /*
15468  * [4] 9.3.16
15469  */
15470 static void
15471 dtap_cc_notify(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15472 {
15473     guint32     curr_offset;
15474     guint32     consumed;
15475     guint       curr_len;
15476
15477     curr_offset = offset;
15478     curr_len = len;
15479
15480     is_uplink = IS_UPLINK_FALSE;
15481
15482     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_NOT_IND);
15483
15484     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15485 }
15486
15487 /*
15488  * [4] 9.3.17
15489  */
15490 static void
15491 dtap_cc_progress(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15492 {
15493     guint32     curr_offset;
15494     guint32     consumed;
15495     guint       curr_len;
15496
15497     curr_offset = offset;
15498     curr_len = len;
15499
15500     is_uplink = IS_UPLINK_FALSE;
15501
15502     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_PROG_IND, "");
15503
15504     ELEM_OPT_TLV(0x7e, BSSAP_PDU_TYPE_DTAP, DE_USER_USER, "");
15505
15506     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15507 }
15508
15509 /*
15510  * [4] 9.3.17a
15511  */
15512 static void
15513 dtap_cc_cc_est(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15514 {
15515     guint32     curr_offset;
15516     guint32     consumed;
15517     guint       curr_len;
15518
15519     curr_offset = offset;
15520     curr_len = len;
15521
15522     is_uplink = IS_UPLINK_FALSE;
15523
15524     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_SETUP_CONTAINER, "");
15525
15526     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15527 }
15528
15529 /*
15530  * [4] 9.3.17b
15531  */
15532 static void
15533 dtap_cc_cc_est_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, " Repeat indicator");
15545
15546     ELEM_MAND_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(0x40, BSSAP_PDU_TYPE_DTAP, DE_SUP_CODEC_LIST, "");
15553
15554     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15555 }
15556
15557 /*
15558  * [4] 9.3.18
15559  */
15560 static void
15561 dtap_cc_release(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15562 {
15563     guint32     curr_offset;
15564     guint32     consumed;
15565     guint       curr_len;
15566
15567     curr_offset = offset;
15568     curr_len = len;
15569
15570     is_uplink = IS_UPLINK_TRUE;
15571
15572     ELEM_OPT_TLV(0x08, BSSAP_PDU_TYPE_DTAP, DE_CAUSE, "");
15573
15574     ELEM_OPT_TLV(0x08, BSSAP_PDU_TYPE_DTAP, DE_CAUSE, " 2");
15575
15576     ELEM_OPT_TLV(0x1c, BSSAP_PDU_TYPE_DTAP, DE_FACILITY, "");
15577
15578     ELEM_OPT_TLV(0x7e, BSSAP_PDU_TYPE_DTAP, DE_USER_USER, "");
15579
15580     /* uplink only */
15581
15582     ELEM_OPT_TLV(0x7f, BSSAP_PDU_TYPE_DTAP, DE_SS_VER_IND, "");
15583
15584     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15585 }
15586
15587 /*
15588  * [4] 9.3.18a
15589  */
15590 static void
15591 dtap_cc_recall(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15592 {
15593     guint32     curr_offset;
15594     guint32     consumed;
15595     guint       curr_len;
15596
15597     curr_offset = offset;
15598     curr_len = len;
15599
15600     is_uplink = IS_UPLINK_FALSE;
15601
15602     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RECALL_TYPE);
15603
15604     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_FACILITY, "");
15605
15606     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15607 }
15608
15609 /*
15610  * [4] 9.3.19
15611  */
15612 static void
15613 dtap_cc_release_complete(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15614 {
15615     guint32     curr_offset;
15616     guint32     consumed;
15617     guint       curr_len;
15618
15619     curr_offset = offset;
15620     curr_len = len;
15621
15622     is_uplink = IS_UPLINK_FALSE;
15623
15624     ELEM_OPT_TLV(0x08, BSSAP_PDU_TYPE_DTAP, DE_CAUSE, "");
15625
15626     ELEM_OPT_TLV(0x1c, BSSAP_PDU_TYPE_DTAP, DE_FACILITY, "");
15627
15628     ELEM_OPT_TLV(0x7e, BSSAP_PDU_TYPE_DTAP, DE_USER_USER, "");
15629
15630     /* uplink only */
15631
15632     ELEM_OPT_TLV(0x7f, BSSAP_PDU_TYPE_DTAP, DE_SS_VER_IND, "");
15633
15634     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15635 }
15636
15637 /*
15638  * [4] 9.3.22
15639  */
15640 static void
15641 dtap_cc_retrieve_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15642 {
15643     guint32     curr_offset;
15644     guint32     consumed;
15645     guint       curr_len;
15646
15647     curr_offset = offset;
15648     curr_len = len;
15649
15650     is_uplink = IS_UPLINK_FALSE;
15651
15652     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_CAUSE, "");
15653
15654     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15655 }
15656
15657 /*
15658  * [4] 9.3.23
15659  * 3GPP TS 24.008 version 7.5.0 Release 7
15660  */
15661 static void
15662 dtap_cc_setup(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15663 {
15664     guint32     curr_offset;
15665     guint32     consumed;
15666     guint       curr_len;
15667
15668     curr_offset = offset;
15669     curr_len = len;
15670
15671     is_uplink = IS_UPLINK_TRUE;
15672
15673     ELEM_OPT_TV_SHORT(0xd0, BSSAP_PDU_TYPE_DTAP, DE_REPEAT_IND, " BC repeat indicator");
15674
15675     ELEM_OPT_TLV(0x04, BSSAP_PDU_TYPE_DTAP, DE_BEARER_CAP, " 1");
15676
15677     ELEM_OPT_TLV(0x04, BSSAP_PDU_TYPE_DTAP, DE_BEARER_CAP, " 2");
15678
15679     ELEM_OPT_TLV(0x1c, BSSAP_PDU_TYPE_DTAP, DE_FACILITY, "");
15680
15681     ELEM_OPT_TLV(0x1e, BSSAP_PDU_TYPE_DTAP, DE_PROG_IND, "");
15682
15683     ELEM_OPT_TV(0x34, BSSAP_PDU_TYPE_DTAP, DE_SIGNAL, "");
15684
15685     ELEM_OPT_TLV(0x5c, BSSAP_PDU_TYPE_DTAP, DE_CLG_PARTY_BCD_NUM, "");
15686
15687     ELEM_OPT_TLV(0x5d, BSSAP_PDU_TYPE_DTAP, DE_CLG_PARTY_SUB_ADDR, "");
15688
15689     ELEM_OPT_TLV(0x5e, BSSAP_PDU_TYPE_DTAP, DE_CLD_PARTY_BCD_NUM, "");
15690
15691     ELEM_OPT_TLV(0x6d, BSSAP_PDU_TYPE_DTAP, DE_CLD_PARTY_SUB_ADDR, "");
15692
15693     ELEM_OPT_TLV(0x74, BSSAP_PDU_TYPE_DTAP, DE_RED_PARTY_BCD_NUM, "");
15694
15695     ELEM_OPT_TLV(0x75, BSSAP_PDU_TYPE_DTAP, DE_RED_PARTY_SUB_ADDR, "");
15696
15697     ELEM_OPT_TV_SHORT(0xd0, BSSAP_PDU_TYPE_DTAP, DE_REPEAT_IND, " LLC repeat indicator");
15698
15699     ELEM_OPT_TLV(0x7c, BSSAP_PDU_TYPE_DTAP, DE_LLC, " 1");
15700
15701     ELEM_OPT_TLV(0x7c, BSSAP_PDU_TYPE_DTAP, DE_LLC, " 2");
15702
15703     ELEM_OPT_TV_SHORT(0xd0, BSSAP_PDU_TYPE_DTAP, DE_REPEAT_IND, " HLC repeat indicator");
15704
15705     ELEM_OPT_TLV(0x7d, BSSAP_PDU_TYPE_DTAP, DE_HLC, " 1");
15706
15707     ELEM_OPT_TLV(0x7d, BSSAP_PDU_TYPE_DTAP, DE_HLC, " 2");
15708
15709     ELEM_OPT_TLV(0x7e, BSSAP_PDU_TYPE_DTAP, DE_USER_USER, "");
15710
15711     /* downlink only */
15712
15713     ELEM_OPT_TV_SHORT(0x80, BSSAP_PDU_TYPE_DTAP, DE_PRIO, "");
15714
15715     ELEM_OPT_TLV(0x19, BSSAP_PDU_TYPE_DTAP, DE_ALERT_PATTERN, "");
15716
15717     ELEM_OPT_TLV(0x2f, BSSAP_PDU_TYPE_DTAP, DE_NET_CC_CAP, "");
15718
15719     ELEM_OPT_TLV(0x3a, BSSAP_PDU_TYPE_DTAP, DE_CAUSE_NO_CLI, "");
15720
15721         /* Backup bearer capability O TLV 3-15 10.5.4.4a */
15722         ELEM_OPT_TLV(0x41, BSSAP_PDU_TYPE_DTAP, DE_BEARER_CAP, "");
15723
15724     /* uplink only */
15725
15726     ELEM_OPT_TLV(0x7f, BSSAP_PDU_TYPE_DTAP, DE_SS_VER_IND, "");
15727
15728     ELEM_OPT_T(0xa1, BSSAP_PDU_TYPE_DTAP, DE_CLIR_SUP, "");
15729
15730     ELEM_OPT_T(0xa2, BSSAP_PDU_TYPE_DTAP, DE_CLIR_INV, "");
15731
15732     ELEM_OPT_TLV(0x15, BSSAP_PDU_TYPE_DTAP, DE_CC_CAP, "");
15733
15734     ELEM_OPT_TLV(0x1d, BSSAP_PDU_TYPE_DTAP, DE_FACILITY, " $(CCBS)$ (advanced recall alignment)");
15735
15736     ELEM_OPT_TLV(0x1b, BSSAP_PDU_TYPE_DTAP, DE_FACILITY, " (recall alignment Not essential) $(CCBS)$");
15737
15738     ELEM_OPT_TLV(0x2d, BSSAP_PDU_TYPE_DTAP, DE_SI, "");
15739
15740     ELEM_OPT_TLV(0x40, BSSAP_PDU_TYPE_DTAP, DE_SUP_CODEC_LIST, "");
15741
15742         /*A3 Redial Redial O T 1 10.5.4.34 
15743          * TODO add this element 
15744          * ELEM_OPT_T(0xA3, BSSAP_PDU_TYPE_DTAP, DE_REDIAL, "");
15745          */
15746
15747     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15748 }
15749
15750 /*
15751  * [4] 9.3.23a
15752  */
15753 static void
15754 dtap_cc_start_cc(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15755 {
15756     guint32     curr_offset;
15757     guint32     consumed;
15758     guint       curr_len;
15759
15760     curr_offset = offset;
15761     curr_len = len;
15762
15763     is_uplink = IS_UPLINK_FALSE;
15764
15765     ELEM_OPT_TLV(0x15, BSSAP_PDU_TYPE_DTAP, DE_CC_CAP, "");
15766
15767     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15768 }
15769
15770 /*
15771  * [4] 9.3.24
15772  */
15773 static void
15774 dtap_cc_start_dtmf(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15775 {
15776     guint32     curr_offset;
15777     guint32     consumed;
15778     guint       curr_len;
15779
15780     curr_offset = offset;
15781     curr_len = len;
15782
15783     is_uplink = IS_UPLINK_TRUE;
15784
15785     ELEM_MAND_TV(0x2c, BSSAP_PDU_TYPE_DTAP, DE_KEYPAD_FACILITY, "");
15786
15787     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15788 }
15789
15790 /*
15791  * [4] 9.3.25
15792  */
15793 static void
15794 dtap_cc_start_dtmf_ack(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15795 {
15796     guint32     curr_offset;
15797     guint32     consumed;
15798     guint       curr_len;
15799
15800     curr_offset = offset;
15801     curr_len = len;
15802
15803     is_uplink = IS_UPLINK_FALSE;
15804
15805     ELEM_MAND_TV(0x2c, BSSAP_PDU_TYPE_DTAP, DE_KEYPAD_FACILITY, "");
15806
15807     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15808 }
15809
15810 /*
15811  * [4] 9.3.26
15812  */
15813 static void
15814 dtap_cc_start_dtmf_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15815 {
15816     guint32     curr_offset;
15817     guint32     consumed;
15818     guint       curr_len;
15819
15820     curr_offset = offset;
15821     curr_len = len;
15822
15823     is_uplink = IS_UPLINK_FALSE;
15824
15825     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_CAUSE, "");
15826
15827     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15828 }
15829
15830 /*
15831  * [4] 9.3.27
15832  */
15833 static void
15834 dtap_cc_status(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15835 {
15836     guint32     curr_offset;
15837     guint32     consumed;
15838     guint       curr_len;
15839
15840     curr_offset = offset;
15841     curr_len = len;
15842
15843     is_uplink = IS_UPLINK_FALSE;
15844
15845     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_CAUSE, "");
15846
15847     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_CALL_STATE);
15848
15849     ELEM_OPT_TLV(0x24, BSSAP_PDU_TYPE_DTAP, DE_AUX_STATES, "");
15850
15851     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15852 }
15853
15854 /*
15855  * [4] 9.3.31
15856  */
15857 static void
15858 dtap_cc_user_info(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15859 {
15860     guint32     curr_offset;
15861     guint32     consumed;
15862     guint       curr_len;
15863
15864     curr_offset = offset;
15865     curr_len = len;
15866
15867     is_uplink = IS_UPLINK_TRUE;
15868
15869     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_USER_USER, "");
15870
15871     ELEM_OPT_T(0xa0, BSSAP_PDU_TYPE_DTAP, DE_MORE_DATA, "");
15872
15873     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15874 }
15875
15876 /*
15877  * [6] 2.4.2
15878  */
15879 static void
15880 dtap_ss_register(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15881 {
15882     guint32     curr_offset;
15883     guint32     consumed;
15884     guint       curr_len;
15885
15886     curr_offset = offset;
15887     curr_len = len;
15888
15889     is_uplink = IS_UPLINK_TRUE;
15890
15891     ELEM_MAND_TLV(0x1c, BSSAP_PDU_TYPE_DTAP, DE_FACILITY, "");
15892
15893     ELEM_OPT_TLV(0x7f, BSSAP_PDU_TYPE_DTAP, DE_SS_VER_IND, "");
15894
15895     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15896 }
15897
15898 /*
15899  * [5] 7.2.1
15900  */
15901 static void
15902 dtap_sms_cp_data(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15903 {
15904     guint32     curr_offset;
15905     guint32     consumed;
15906     guint       curr_len;
15907
15908     curr_offset = offset;
15909     curr_len = len;
15910
15911     is_uplink = IS_UPLINK_TRUE;
15912
15913     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_CP_USER_DATA, "");
15914
15915     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15916 }
15917
15918 /*
15919  * [5] 7.2.3
15920  */
15921 static void
15922 dtap_sms_cp_error(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15923 {
15924     guint32     curr_offset;
15925     guint32     consumed;
15926     guint       curr_len;
15927
15928     curr_offset = offset;
15929     curr_len = len;
15930
15931     is_uplink = IS_UPLINK_TRUE;
15932
15933     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_CP_CAUSE);
15934
15935     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15936 }
15937
15938 /*
15939  * [5] 7.3.1.1
15940  */
15941 static void
15942 rp_data_n_ms(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15943 {
15944     guint32     curr_offset;
15945     guint32     consumed;
15946     guint       curr_len;
15947
15948     curr_offset = offset;
15949     curr_len = len;
15950
15951     is_uplink = IS_UPLINK_FALSE;
15952     g_pinfo->p2p_dir = P2P_DIR_SENT;
15953
15954     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RP_MESSAGE_REF);
15955
15956     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_RP_ORIG_ADDR, "");
15957
15958     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_RP_DEST_ADDR, "");
15959
15960     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_RP_USER_DATA, "");
15961
15962     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15963 }
15964
15965 /*
15966  * [5] 7.3.1.2
15967  */
15968 static void
15969 rp_data_ms_n(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
15970 {
15971     guint32     curr_offset;
15972     guint32     consumed;
15973     guint       curr_len;
15974
15975     curr_offset = offset;
15976     curr_len = len;
15977
15978     is_uplink = IS_UPLINK_TRUE;
15979     g_pinfo->p2p_dir = P2P_DIR_RECV;
15980
15981     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RP_MESSAGE_REF);
15982
15983     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_RP_ORIG_ADDR, "");
15984
15985     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_RP_DEST_ADDR, "");
15986
15987     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_RP_USER_DATA, "");
15988
15989     EXTRANEOUS_DATA_CHECK(curr_len, 0);
15990 }
15991
15992 /*
15993  * [5] 7.3.2
15994  */
15995 static void
15996 rp_smma(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_TRUE;
16006
16007     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RP_MESSAGE_REF);
16008
16009     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16010 }
16011
16012 /*
16013  * [5] 7.3.3
16014  */
16015 static void
16016 rp_ack_n_ms(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16017 {
16018     guint32     curr_offset;
16019     guint32     consumed;
16020     guint       curr_len;
16021
16022     curr_offset = offset;
16023     curr_len = len;
16024
16025     is_uplink = IS_UPLINK_FALSE;
16026     g_pinfo->p2p_dir = P2P_DIR_SENT;
16027
16028     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RP_MESSAGE_REF);
16029
16030     ELEM_OPT_TLV(0x41, BSSAP_PDU_TYPE_DTAP, DE_RP_USER_DATA, "");
16031
16032     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16033 }
16034
16035 /*
16036  * [5] 7.3.3
16037  */
16038 static void
16039 rp_ack_ms_n(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16040 {
16041     guint32     curr_offset;
16042     guint32     consumed;
16043     guint       curr_len;
16044
16045     curr_offset = offset;
16046     curr_len = len;
16047
16048     is_uplink = IS_UPLINK_TRUE;
16049     g_pinfo->p2p_dir = P2P_DIR_RECV;
16050
16051     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RP_MESSAGE_REF);
16052
16053     ELEM_OPT_TLV(0x41, BSSAP_PDU_TYPE_DTAP, DE_RP_USER_DATA, "");
16054
16055     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16056 }
16057
16058 /*
16059  * [5] 7.3.4
16060  */
16061 static void
16062 rp_error_n_ms(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16063 {
16064     guint32     curr_offset;
16065     guint32     consumed;
16066     guint       curr_len;
16067
16068     curr_offset = offset;
16069     curr_len = len;
16070
16071     is_uplink = IS_UPLINK_FALSE;
16072     g_pinfo->p2p_dir = P2P_DIR_SENT;
16073
16074     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RP_MESSAGE_REF);
16075
16076     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_RP_CAUSE, "");
16077
16078     ELEM_OPT_TLV(0x41, BSSAP_PDU_TYPE_DTAP, DE_RP_USER_DATA, "");
16079
16080     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16081 }
16082
16083 /*
16084  * [5] 7.3.4
16085  */
16086 static void
16087 rp_error_ms_n(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16088 {
16089     guint32     curr_offset;
16090     guint32     consumed;
16091     guint       curr_len;
16092
16093     curr_offset = offset;
16094     curr_len = len;
16095
16096     is_uplink = IS_UPLINK_TRUE;
16097     g_pinfo->p2p_dir = P2P_DIR_RECV;
16098
16099     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RP_MESSAGE_REF);
16100
16101     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_RP_CAUSE, "");
16102
16103     ELEM_OPT_TLV(0x41, BSSAP_PDU_TYPE_DTAP, DE_RP_USER_DATA, "");
16104
16105     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16106 }
16107
16108 /*
16109  * [7] 9.4.1
16110  */
16111 static void
16112 dtap_gmm_attach_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16113 {
16114     guint32     curr_offset;
16115     guint32     consumed;
16116     guint       curr_len;
16117
16118     curr_offset = offset;
16119     curr_len = len;
16120
16121     is_uplink = IS_UPLINK_TRUE;
16122     g_pinfo->p2p_dir = P2P_DIR_RECV;
16123
16124     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_MS_NET_CAP, "");
16125     
16126     /* Included in attach type
16127     
16128     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_CIPH_KEY_SEQ_NUM );
16129     curr_offset--;
16130     curr_len++;
16131     */
16132     
16133     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_ATTACH_TYPE );
16134     
16135     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_DRX_PARAM );
16136     
16137     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_MID , "" );
16138     
16139     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RAI );
16140     
16141     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_MS_RAD_ACC_CAP , "" );
16142
16143     ELEM_OPT_TV( 0x19 , BSSAP_PDU_TYPE_DTAP, DE_P_TMSI_SIG, " - Old P-TMSI Signature");
16144     
16145     ELEM_OPT_TV( 0x17 , BSSAP_PDU_TYPE_DTAP, DE_GPRS_TIMER , " - Ready Timer" );
16146     
16147     ELEM_OPT_TV_SHORT( 0x90 , BSSAP_PDU_TYPE_DTAP, DE_TMSI_STAT , "" );
16148
16149     ELEM_OPT_TLV( 0x33 , BSSAP_PDU_TYPE_DTAP, DE_PS_LCS_CAP , "" );
16150
16151     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16152 }
16153
16154 /*
16155  * [7] 9.4.2
16156  */
16157 static void
16158 dtap_gmm_attach_acc(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16159 {
16160     guint32     curr_offset;
16161     guint32     consumed;
16162     guint       curr_len;
16163
16164     curr_offset = offset;
16165     curr_len = len;
16166
16167     is_uplink = IS_UPLINK_FALSE;
16168     g_pinfo->p2p_dir = P2P_DIR_SENT;
16169
16170     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_FORCE_TO_STAND_H );
16171     curr_len++;
16172     curr_offset--;    
16173
16174     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_ATTACH_RES );
16175     
16176     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_GPRS_TIMER );
16177     
16178     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RAD_PRIO_2 );
16179     curr_len++;
16180     curr_offset--;
16181     
16182     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RAD_PRIO );
16183     
16184     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RAI );
16185     
16186     ELEM_OPT_TV( 0x19 , BSSAP_PDU_TYPE_DTAP, DE_P_TMSI_SIG, "" );
16187     
16188     ELEM_OPT_TV( 0x17 , BSSAP_PDU_TYPE_DTAP, DE_GPRS_TIMER , " - Negotiated Ready Timer" );
16189     
16190     ELEM_OPT_TLV( 0x18 , BSSAP_PDU_TYPE_DTAP, DE_MID , " - Allocated P-TMSI" );
16191     
16192     ELEM_OPT_TLV( 0x23 , BSSAP_PDU_TYPE_DTAP, DE_MID , "" );
16193     
16194     ELEM_OPT_TV( 0x25 , BSSAP_PDU_TYPE_DTAP, DE_GMM_CAUSE , "" );
16195     
16196     ELEM_OPT_TLV( 0x2A , BSSAP_PDU_TYPE_DTAP, DE_GPRS_TIMER_2 , " - T3302" );
16197     
16198     ELEM_OPT_T( 0x8C , BSSAP_PDU_TYPE_DTAP, DE_CELL_NOT , "" );
16199     
16200     ELEM_OPT_TLV( 0x4A , BSSAP_PDU_TYPE_DTAP, DE_PLMN_LIST , "" );
16201
16202     ELEM_OPT_TV_SHORT( 0xB0 , BSSAP_PDU_TYPE_DTAP, DE_NET_FEAT_SUP , "" );
16203     
16204     ELEM_OPT_TLV( 0x34 , BSSAP_PDU_TYPE_DTAP, DE_EMERGENCY_NUM_LIST , "" );
16205
16206     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16207 }
16208
16209 /*
16210  * [7] 9.4.3
16211  */
16212 static void
16213 dtap_gmm_attach_com(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16214 {
16215
16216     guint32     curr_offset;
16217 /*    guint32   consumed; */
16218     guint       curr_len;
16219
16220     curr_offset = offset;
16221     curr_len = len;
16222
16223     is_uplink = IS_UPLINK_TRUE;
16224     g_pinfo->p2p_dir = P2P_DIR_RECV;
16225
16226     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16227 }
16228
16229 /*
16230  * [7] 9.4.4
16231  */
16232 static void
16233 dtap_gmm_attach_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16234 {
16235     guint32     curr_offset;
16236     guint32     consumed;
16237     guint       curr_len;
16238
16239     curr_offset = offset;
16240     curr_len = len;
16241
16242     is_uplink = IS_UPLINK_FALSE;
16243     g_pinfo->p2p_dir = P2P_DIR_SENT;
16244
16245     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_GMM_CAUSE );
16246
16247     ELEM_OPT_TLV( 0x2A , BSSAP_PDU_TYPE_DTAP, DE_GPRS_TIMER_2 , " - T3302" );
16248
16249     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16250 }
16251
16252 /*
16253  * [7] 9.4.5
16254  */
16255 static void
16256 dtap_gmm_detach_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16257 {
16258     guint32     curr_offset;
16259     guint32     consumed;
16260     guint       curr_len;
16261
16262     curr_offset = offset;
16263     curr_len = len;
16264
16265     is_uplink = IS_UPLINK_FALSE;
16266     g_pinfo->p2p_dir = P2P_DIR_SENT;
16267
16268     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_FORCE_TO_STAND_H );
16269     /* Force to standy might be wrong - To decode it correct, we need the direction */
16270     curr_len++;
16271     curr_offset--;
16272     
16273     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_DETACH_TYPE );
16274     
16275     ELEM_OPT_TV( 0x25 , BSSAP_PDU_TYPE_DTAP, DE_GMM_CAUSE , "" );
16276     
16277     ELEM_OPT_TLV( 0x18 , BSSAP_PDU_TYPE_DTAP, DE_MID , " - P-TMSI" );
16278
16279     ELEM_OPT_TLV( 0x19 , BSSAP_PDU_TYPE_DTAP, DE_P_TMSI_SIG , "" );
16280     
16281     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16282 }
16283
16284 /*
16285  * [7] 9.4.6
16286  */
16287 static void
16288 dtap_gmm_detach_acc(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16289 {
16290     guint32     curr_offset;
16291     guint32     consumed;
16292     guint       curr_len;
16293
16294     curr_offset = offset;
16295     curr_len = len;
16296
16297     is_uplink = IS_UPLINK_TRUE;
16298     g_pinfo->p2p_dir = P2P_DIR_RECV;
16299
16300     if ( curr_len != 0 )
16301     {
16302         ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_SPARE_NIBBLE );
16303         curr_len++;
16304         curr_offset--;
16305         
16306         ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_FORCE_TO_STAND );
16307     }
16308
16309     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16310 }
16311
16312 /*
16313  * [7] 9.4.7
16314  */
16315 static void
16316 dtap_gmm_ptmsi_realloc_cmd(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16317 {
16318     guint32     curr_offset;
16319     guint32     consumed;
16320     guint       curr_len;
16321
16322     curr_offset = offset;
16323     curr_len = len;
16324
16325     is_uplink = IS_UPLINK_FALSE;
16326     g_pinfo->p2p_dir = P2P_DIR_SENT;
16327
16328     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_MID , " - Allocated P-TMSI" );
16329
16330     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RAI );
16331
16332     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_SPARE_NIBBLE );
16333     curr_len++;
16334     curr_offset--;
16335     
16336     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_FORCE_TO_STAND );
16337
16338     ELEM_OPT_TV( 0x19 , BSSAP_PDU_TYPE_DTAP, DE_MID , " - P-TMSI Signature" );    
16339
16340     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16341 }
16342
16343 /*
16344  * [7] 9.4.8
16345  */
16346 static void
16347 dtap_gmm_ptmsi_realloc_com(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_TRUE;
16357     g_pinfo->p2p_dir = P2P_DIR_RECV;
16358
16359     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16360 }
16361
16362 /*
16363  * [7] 9.4.9
16364  */
16365 static void
16366 dtap_gmm_auth_ciph_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16367 {
16368     guint32     curr_offset;
16369     guint32     consumed;
16370     guint       curr_len;
16371     guint8      oct;
16372     
16373     curr_offset = offset;
16374     curr_len = len;
16375
16376     is_uplink = IS_UPLINK_FALSE;
16377     g_pinfo->p2p_dir = P2P_DIR_SENT;
16378
16379     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_IMEISV_REQ );
16380     curr_offset--;
16381     curr_len++;
16382     
16383     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_CIPH_ALG );
16384     
16385     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_AC_REF_NUM_H );
16386     curr_offset--;
16387     curr_len++;
16388     
16389     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_FORCE_TO_STAND );
16390     
16391     ELEM_OPT_TV( 0x21 , BSSAP_PDU_TYPE_DTAP, DE_AUTH_PARAM_RAND , "" );
16392
16393 #if 0    
16394     ELEM_OPT_TV_SHORT( 0x08 , BSSAP_PDU_TYPE_DTAP, DE_CIPH_KEY_SEQ_NUM , "" );
16395 #else
16396     if ( curr_len > 0 )
16397     {
16398             oct = tvb_get_guint8(tvb, curr_offset);
16399             if (( oct & 0xf0 ) == 0x80 )
16400             {
16401                 /* The ciphering key sequence number is added here */
16402                 proto_tree_add_text(tree,
16403                         tvb, curr_offset, 1,
16404                         "Ciphering key sequence number: 0x%02x (%u)",
16405                         oct&7,
16406                         oct&7);
16407                 curr_offset++;
16408                 curr_len--;
16409             }
16410     }
16411 #endif
16412
16413     if ( curr_len == 0  )
16414     {
16415         EXTRANEOUS_DATA_CHECK(curr_len, 0);
16416         return;
16417     }
16418         
16419     ELEM_OPT_TLV( 0x28 , BSSAP_PDU_TYPE_DTAP, DE_AUTH_PARAM_AUTN , "" );
16420
16421     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16422 }
16423
16424 /*
16425  * [7] 9.4.10
16426  */
16427 static void
16428 dtap_gmm_auth_ciph_resp(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16429 {
16430     guint32     curr_offset;
16431     guint32     consumed;
16432     guint       curr_len;
16433
16434     curr_offset = offset;
16435     curr_len = len;
16436
16437     is_uplink = IS_UPLINK_TRUE;
16438     g_pinfo->p2p_dir = P2P_DIR_RECV;
16439
16440     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_SPARE_NIBBLE );
16441     curr_offset--;
16442     curr_len++;
16443     
16444     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_AC_REF_NUM );
16445     
16446     ELEM_OPT_TV( 0x22 , BSSAP_PDU_TYPE_DTAP, DE_AUTH_RESP_PARAM , "" );
16447     
16448     ELEM_OPT_TLV( 0x23 , BSSAP_PDU_TYPE_DTAP, DE_MID , " - IMEISV" );
16449     
16450     ELEM_OPT_TLV( 0x29 , BSSAP_PDU_TYPE_DTAP, DE_AUTH_RESP_PARAM_EXT , "" );
16451
16452     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16453 }
16454
16455 /*
16456  * [7] 9.4.11
16457  */
16458 static void
16459 dtap_gmm_auth_ciph_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16460 {
16461     guint32     curr_offset;
16462 /*    guint32   consumed; */
16463     guint       curr_len;
16464
16465     curr_offset = offset;
16466     curr_len = len;
16467
16468     is_uplink = IS_UPLINK_FALSE;
16469     g_pinfo->p2p_dir = P2P_DIR_SENT;
16470
16471     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16472 }
16473
16474 /*
16475  * [7] 9.4.10a
16476  */
16477 static void
16478 dtap_gmm_auth_ciph_fail(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16479 {
16480     guint32     curr_offset;
16481     guint32     consumed;
16482     guint       curr_len;
16483
16484     curr_offset = offset;
16485     curr_len = len;
16486
16487     is_uplink = IS_UPLINK_TRUE;
16488     g_pinfo->p2p_dir = P2P_DIR_RECV;
16489
16490     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_GMM_CAUSE );
16491     
16492     ELEM_OPT_TLV( 0x30 , BSSAP_PDU_TYPE_DTAP, DE_AUTH_FAIL_PARAM , "" );
16493
16494     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16495 }
16496
16497 /*
16498  * [7] 9.4.12
16499  */
16500 static void
16501 dtap_gmm_ident_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16502 {
16503     guint32     curr_offset;
16504     guint       curr_len;
16505
16506     curr_offset = offset;
16507     curr_len = len;
16508
16509     is_uplink = IS_UPLINK_FALSE;
16510     g_pinfo->p2p_dir = P2P_DIR_SENT;
16511
16512 /*  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. */
16513 /*    ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_ID_TYPE_2 );
16514     curr_offset--;
16515     curr_len++;
16516     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_FORCE_TO_STAND_H );*/
16517     
16518     elem_v(tvb, tree, BSSAP_PDU_TYPE_DTAP, DE_FORCE_TO_STAND_H, curr_offset);
16519     elem_v(tvb, tree, BSSAP_PDU_TYPE_DTAP, DE_ID_TYPE_2, curr_offset);
16520
16521     curr_offset+=1;
16522     curr_len-=1;
16523
16524     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16525 }
16526
16527 /*
16528  * [7] 9.4.13
16529  */
16530 static void
16531 dtap_gmm_ident_res(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16532 {
16533     guint32     curr_offset;
16534     guint32     consumed;
16535     guint       curr_len;
16536
16537     curr_offset = offset;
16538     curr_len = len;
16539
16540     is_uplink = IS_UPLINK_TRUE;
16541     g_pinfo->p2p_dir = P2P_DIR_RECV;
16542
16543     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_MID , "" );
16544
16545     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16546 }
16547
16548 /*
16549  * [7] 9.4.14
16550  */
16551 static void
16552 dtap_gmm_rau_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16553 {
16554     guint32     curr_offset;
16555     guint32     consumed;
16556     guint       curr_len;
16557
16558     curr_offset = offset;
16559     curr_len = len;
16560
16561     is_uplink = IS_UPLINK_TRUE;
16562     g_pinfo->p2p_dir = P2P_DIR_RECV;
16563
16564     /* is included in update type
16565     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_CIPH_KEY_SEQ_NUM );
16566     curr_offset--;
16567     curr_len++;
16568     
16569     */
16570     
16571     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_UPD_TYPE );
16572     
16573     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RAI );
16574     
16575     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_MS_RAD_ACC_CAP , "" );
16576     
16577     ELEM_OPT_TV( 0x19 , BSSAP_PDU_TYPE_DTAP, DE_P_TMSI_SIG , " - Old P-TMSI Signature" ); 
16578     
16579     ELEM_OPT_TV( 0x17 , BSSAP_PDU_TYPE_DTAP, DE_GPRS_TIMER , " - Requested Ready Timer" );
16580
16581     ELEM_OPT_TV( 0x27 , BSSAP_PDU_TYPE_DTAP, DE_DRX_PARAM , "" );
16582     
16583     ELEM_OPT_TV_SHORT( 0x90 , BSSAP_PDU_TYPE_DTAP, DE_TMSI_STAT , "" );
16584     
16585     ELEM_OPT_TLV( 0x18 , BSSAP_PDU_TYPE_DTAP, DE_MID , " - P-TMSI" );
16586     
16587     ELEM_OPT_TLV( 0x31 , BSSAP_PDU_TYPE_DTAP, DE_MS_NET_CAP , "" );
16588     
16589     ELEM_OPT_TLV( 0x32 , BSSAP_PDU_TYPE_DTAP, DE_PDP_CONTEXT_STAT , "" );
16590     
16591     ELEM_OPT_TLV( 0x33 , BSSAP_PDU_TYPE_DTAP, DE_PS_LCS_CAP , "" );
16592     
16593     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16594 }
16595
16596 /*
16597  * [7] 9.4.15
16598  */
16599 static void
16600 dtap_gmm_rau_acc(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16601 {
16602     guint32     curr_offset;
16603     guint32     consumed;
16604     guint       curr_len;
16605
16606     curr_offset = offset;
16607     curr_len = len;
16608
16609     is_uplink = IS_UPLINK_FALSE;
16610     g_pinfo->p2p_dir = P2P_DIR_SENT;
16611
16612     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_UPD_RES );
16613     curr_offset--;
16614     curr_len++;
16615     
16616     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_FORCE_TO_STAND );
16617     
16618     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_GPRS_TIMER );
16619     
16620     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RAI );
16621     
16622     ELEM_OPT_TV( 0x19 , BSSAP_PDU_TYPE_DTAP, DE_P_TMSI_SIG , "" ); 
16623     
16624     ELEM_OPT_TLV( 0x18 , BSSAP_PDU_TYPE_DTAP, DE_MID , " - Allocated P-TMSI");
16625     
16626     ELEM_OPT_TLV( 0x23 , BSSAP_PDU_TYPE_DTAP, DE_MID , "" );
16627     
16628     ELEM_OPT_TLV( 0x26 , BSSAP_PDU_TYPE_DTAP, DE_REC_N_PDU_NUM_LIST , "" );
16629     
16630     ELEM_OPT_TV( 0x17 , BSSAP_PDU_TYPE_DTAP, DE_GPRS_TIMER , " - Negotiated Ready Timer" );
16631     
16632     ELEM_OPT_TV( 0x25 , BSSAP_PDU_TYPE_DTAP, DE_GMM_CAUSE , "" );
16633     
16634     ELEM_OPT_TLV( 0x2A , BSSAP_PDU_TYPE_DTAP, DE_GPRS_TIMER_2 , " - T3302" );
16635     
16636     ELEM_OPT_T( 0x8C , BSSAP_PDU_TYPE_DTAP, DE_CELL_NOT , "" );
16637     
16638     ELEM_OPT_TLV( 0x4A , BSSAP_PDU_TYPE_DTAP, DE_PLMN_LIST , "" );
16639     
16640     ELEM_OPT_TLV( 0x32 , BSSAP_PDU_TYPE_DTAP, DE_PDP_CONTEXT_STAT , "" );
16641     
16642     ELEM_OPT_TV_SHORT ( 0xB0 , BSSAP_PDU_TYPE_DTAP, DE_NET_FEAT_SUP , "" );
16643     
16644     ELEM_OPT_TLV( 0x34 , BSSAP_PDU_TYPE_DTAP, DE_EMERGENCY_NUM_LIST , "" );
16645
16646     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16647 }
16648
16649 /*
16650  * [7] 9.4.16
16651  */
16652 static void
16653 dtap_gmm_rau_com(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16654 {
16655     guint32     curr_offset;
16656     guint32     consumed;
16657     guint       curr_len;
16658
16659     curr_offset = offset;
16660     curr_len = len;
16661
16662     is_uplink = IS_UPLINK_TRUE;
16663     g_pinfo->p2p_dir = P2P_DIR_RECV;
16664         /* [7] 10.5.5.11 */
16665     ELEM_OPT_TLV( 0x26 , BSSAP_PDU_TYPE_DTAP, DE_REC_N_PDU_NUM_LIST , "" );
16666         /* Inter RAT information container 10.5.5.24 TS 24.008 version 6.8.0 Release 6 */
16667         /*TO DO: Implement */
16668         ELEM_OPT_TLV( 0x27 , BSSAP_PDU_TYPE_DTAP, DE_RAT_INFO_CONTAINER , "" );
16669     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16670 }
16671
16672 /*
16673  * [7] 9.4.17
16674  */
16675 static void
16676 dtap_gmm_rau_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16677 {
16678     guint32     curr_offset;
16679     guint32     consumed;
16680     guint       curr_len;
16681
16682     curr_offset = offset;
16683     curr_len = len;
16684
16685     is_uplink = IS_UPLINK_FALSE;
16686     g_pinfo->p2p_dir = P2P_DIR_SENT;
16687
16688     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_GMM_CAUSE );
16689     
16690     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_SPARE_NIBBLE );
16691     curr_offset--;
16692     curr_len++;
16693     
16694     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_FORCE_TO_STAND );
16695     
16696     ELEM_OPT_TLV( 0x26 , BSSAP_PDU_TYPE_DTAP, DE_GPRS_TIMER_2 , " - T3302" );
16697
16698     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16699 }
16700
16701 /*
16702  * [7] 9.4.18
16703  */
16704 static void
16705 dtap_gmm_status(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16706 {
16707     guint32     curr_offset;
16708     guint32     consumed;
16709     guint       curr_len;
16710
16711     curr_offset = offset;
16712     curr_len = len;
16713
16714      is_uplink = IS_UPLINK_UNKNOWN;
16715     g_pinfo->p2p_dir = P2P_DIR_UNKNOWN;
16716
16717     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_GMM_CAUSE );
16718
16719     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16720 }
16721
16722 /*
16723  * [8] 9.4.19 GMM Information
16724  */
16725 static void
16726 dtap_gmm_information(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16727 {
16728     guint32     curr_offset;
16729     guint32     consumed;
16730     guint       curr_len;
16731
16732     curr_offset = offset;
16733     curr_len = len;
16734
16735     is_uplink = IS_UPLINK_FALSE;
16736     g_pinfo->p2p_dir = P2P_DIR_SENT;
16737
16738     ELEM_OPT_TLV( 0x43 , BSSAP_PDU_TYPE_DTAP, DE_NETWORK_NAME , " - Full Name" );
16739     
16740     ELEM_OPT_TLV( 0x45 , BSSAP_PDU_TYPE_DTAP, DE_NETWORK_NAME , " - Short Name" );
16741     
16742     ELEM_OPT_TV( 0x46 , BSSAP_PDU_TYPE_DTAP, DE_TIME_ZONE , "" );
16743     
16744     ELEM_OPT_TV( 0x47 , BSSAP_PDU_TYPE_DTAP, DE_TIME_ZONE_TIME , "" );
16745     
16746     ELEM_OPT_TLV( 0x48 , BSSAP_PDU_TYPE_DTAP, DE_LSA_ID , "" );
16747     
16748     ELEM_OPT_TLV( 0x49 , BSSAP_PDU_TYPE_DTAP, DE_DAY_SAVING_TIME , "" );
16749
16750     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16751 }
16752
16753 /*
16754  * [7] 9.4.20
16755  */
16756 static void
16757 dtap_gmm_service_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16758 {
16759     guint32     curr_offset;
16760     guint32     consumed;
16761     guint       curr_len;
16762
16763     curr_offset = offset;
16764     curr_len = len;
16765
16766     is_uplink = IS_UPLINK_TRUE;
16767     g_pinfo->p2p_dir = P2P_DIR_RECV;
16768
16769     /* Is included in SRVC TYPE
16770     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_CIPH_KEY_SEQ_NUM );
16771     curr_offset--;
16772     curr_len++;
16773     */
16774     
16775     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_SRVC_TYPE );
16776     
16777         /* P-TMSI Mobile station identity 10.5.1.4 M LV 6 */
16778     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_MID, "");
16779     
16780     ELEM_OPT_TLV( 0x32 , BSSAP_PDU_TYPE_DTAP, DE_PDP_CONTEXT_STAT , "" );
16781
16782         /* MBMS context status 10.5.7.6 TLV 2 - 18 */
16783         ELEM_OPT_TLV( 0x35 , BSSAP_PDU_TYPE_DTAP, DE_MBMS_CTX_STATUS , "" );
16784
16785     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16786 }
16787
16788 /*
16789  * [7] 9.4.21
16790  */
16791 static void
16792 dtap_gmm_service_acc(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16793 {
16794     guint32     curr_offset;
16795     guint32     consumed;
16796     guint       curr_len;
16797
16798     curr_offset = offset;
16799     curr_len = len;
16800
16801     is_uplink = IS_UPLINK_FALSE;
16802     g_pinfo->p2p_dir = P2P_DIR_SENT;
16803
16804     ELEM_OPT_TLV( 0x32 , BSSAP_PDU_TYPE_DTAP, DE_PDP_CONTEXT_STAT , "" );
16805
16806         /* MBMS context status 10.5.7.6 TLV 2 - 18 */
16807         ELEM_OPT_TLV( 0x35 , BSSAP_PDU_TYPE_DTAP, DE_MBMS_CTX_STATUS , "" );
16808
16809     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16810 }
16811
16812 /*
16813  * [7] 9.4.22
16814  */
16815 static void
16816 dtap_gmm_service_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16817 {
16818     guint32     curr_offset;
16819     guint32     consumed;
16820     guint       curr_len;
16821
16822     curr_offset = offset;
16823     curr_len = len;
16824
16825     is_uplink = IS_UPLINK_FALSE;
16826     g_pinfo->p2p_dir = P2P_DIR_SENT;
16827
16828     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_GMM_CAUSE );
16829
16830     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16831 }
16832
16833 /*
16834  * [8] 9.5.1 Activate PDP context request
16835  */
16836 static void
16837 dtap_sm_act_pdp_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16838 {
16839     guint32     curr_offset;
16840     guint32     consumed;
16841     guint       curr_len;
16842
16843     curr_offset = offset;
16844     curr_len = len;
16845
16846     is_uplink = IS_UPLINK_UNKNOWN;
16847     g_pinfo->p2p_dir = P2P_DIR_UNKNOWN;
16848
16849     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_NET_SAPI );
16850
16851     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_LLC_SAPI );
16852
16853     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_QOS , " - Requested QoS" );
16854
16855     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_PD_PRO_ADDR , " - Requested PDP address" );
16856
16857     ELEM_OPT_TLV( 0x28 , BSSAP_PDU_TYPE_DTAP, DE_ACC_POINT_NAME , "" );
16858
16859     ELEM_OPT_TLV( 0x27 , BSSAP_PDU_TYPE_DTAP, DE_PRO_CONF_OPT , "" );
16860
16861     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16862 }
16863
16864 /*
16865  * [8] 9.5.2 Activate PDP context accept
16866  */
16867 static void
16868 dtap_sm_act_pdp_acc(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16869 {
16870     guint32     curr_offset;
16871     guint32     consumed;
16872     guint       curr_len;
16873
16874     curr_offset = offset;
16875     curr_len = len;
16876
16877     is_uplink = IS_UPLINK_UNKNOWN;
16878     g_pinfo->p2p_dir = P2P_DIR_UNKNOWN;
16879
16880     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_LLC_SAPI );
16881
16882     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_QOS , " - Negotiated QoS" );
16883
16884 #if 0   
16885     /* This is done automatically */
16886     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_SPARE );
16887     curr_offset--;
16888     curr_len++;
16889 #endif
16890
16891     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RAD_PRIO );
16892
16893     ELEM_OPT_TLV( 0x2B , BSSAP_PDU_TYPE_DTAP, DE_PD_PRO_ADDR , "" );
16894
16895     ELEM_OPT_TLV( 0x27 , BSSAP_PDU_TYPE_DTAP, DE_PRO_CONF_OPT , "" );
16896
16897     ELEM_OPT_TLV( 0x34 , BSSAP_PDU_TYPE_DTAP, DE_PACKET_FLOW_ID , "" );
16898
16899     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16900 }
16901
16902 /*
16903  * [8] 9.5.3 Activate PDP context reject
16904  */
16905 static void
16906 dtap_sm_act_pdp_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16907 {
16908     guint32     curr_offset;
16909     guint32     consumed;
16910     guint       curr_len;
16911
16912     curr_offset = offset;
16913     curr_len = len;
16914
16915     is_uplink = IS_UPLINK_UNKNOWN;
16916     g_pinfo->p2p_dir = P2P_DIR_UNKNOWN;
16917
16918     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_SM_CAUSE );
16919
16920     ELEM_OPT_TLV( 0x27 , BSSAP_PDU_TYPE_DTAP, DE_PRO_CONF_OPT , "" );
16921
16922     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16923 }
16924
16925 /*
16926  * [8] 9.5.4 Activate Secondary PDP Context Request
16927  */
16928 static void
16929 dtap_sm_act_sec_pdp_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16930 {
16931     guint32     curr_offset;
16932     guint32     consumed;
16933     guint       curr_len;
16934
16935     curr_offset = offset;
16936     curr_len = len;
16937
16938     is_uplink = IS_UPLINK_UNKNOWN;
16939     g_pinfo->p2p_dir = P2P_DIR_UNKNOWN;
16940
16941     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_NET_SAPI );
16942
16943     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_LLC_SAPI );
16944
16945     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_QOS , " - Requested QoS" );
16946
16947     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_LINKED_TI , "" );
16948
16949         /* 3GPP TS 24.008 version 6.8.0 Release 6, 36 TFT Traffic Flow Template 10.5.6.12 O TLV 3-257 */
16950     ELEM_OPT_TLV( 0x36 , BSSAP_PDU_TYPE_DTAP, DE_TRAFFIC_FLOW_TEMPLATE , "" );
16951
16952     ELEM_OPT_TLV( 0x27 , BSSAP_PDU_TYPE_DTAP, DE_PRO_CONF_OPT , "" );
16953
16954     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16955 }
16956
16957 /*
16958  * [7] 9.5.5
16959  */
16960 static void
16961 dtap_sm_act_sec_pdp_acc(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16962 {
16963     guint32     curr_offset;
16964     guint32     consumed;
16965     guint       curr_len;
16966
16967     curr_offset = offset;
16968     curr_len = len;
16969
16970     is_uplink = IS_UPLINK_UNKNOWN;
16971     g_pinfo->p2p_dir = P2P_DIR_UNKNOWN;
16972
16973     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_LLC_SAPI );
16974
16975     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_QOS , " - Negotiated QoS" );
16976
16977     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_RAD_PRIO);
16978
16979 #if 0   
16980     /* This is done automatically */
16981     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_SPARE );
16982     curr_offset--;
16983     curr_len++;
16984 #endif
16985
16986     ELEM_OPT_TLV( 0x34 , BSSAP_PDU_TYPE_DTAP, DE_PACKET_FLOW_ID , "" );
16987
16988     ELEM_OPT_TLV( 0x27 , BSSAP_PDU_TYPE_DTAP, DE_PRO_CONF_OPT , "" );
16989
16990     EXTRANEOUS_DATA_CHECK(curr_len, 0);
16991 }
16992
16993 /*
16994  * [8] 9.5.6 Activate Secondary PDP Context Reject
16995  */
16996 static void
16997 dtap_sm_act_sec_pdp_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
16998 {
16999     guint32     curr_offset;
17000     guint32     consumed;
17001     guint       curr_len;
17002
17003     curr_offset = offset;
17004     curr_len = len;
17005
17006     is_uplink = IS_UPLINK_UNKNOWN;
17007     g_pinfo->p2p_dir = P2P_DIR_UNKNOWN;
17008
17009     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_SM_CAUSE );
17010
17011     ELEM_OPT_TLV( 0x27 , BSSAP_PDU_TYPE_DTAP, DE_PRO_CONF_OPT , "" );
17012
17013     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17014 }
17015
17016 /*
17017  * [8] 9.5.7 Request PDP context activation
17018  */
17019 static void
17020 dtap_sm_req_pdp_act(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
17021 {
17022     guint32     curr_offset;
17023     guint32     consumed;
17024     guint       curr_len;
17025
17026     curr_offset = offset;
17027     curr_len = len;
17028
17029     is_uplink = IS_UPLINK_UNKNOWN;
17030     g_pinfo->p2p_dir = P2P_DIR_UNKNOWN;
17031
17032     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_PD_PRO_ADDR , " - Offered PDP address" );
17033
17034     ELEM_OPT_TLV( 0x28 , BSSAP_PDU_TYPE_DTAP, DE_ACC_POINT_NAME , "" );
17035
17036     ELEM_OPT_TLV( 0x27 , BSSAP_PDU_TYPE_DTAP, DE_PRO_CONF_OPT , "" );
17037
17038     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17039 }
17040
17041 /*
17042  * [8] 9.5.8 Request PDP context activation reject
17043  */
17044 static void
17045 dtap_sm_req_pdp_act_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
17046 {
17047     guint32     curr_offset;
17048     guint32     consumed;
17049     guint       curr_len;
17050
17051     curr_offset = offset;
17052     curr_len = len;
17053
17054     is_uplink = IS_UPLINK_UNKNOWN;
17055     g_pinfo->p2p_dir = P2P_DIR_UNKNOWN;
17056
17057     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_SM_CAUSE );
17058
17059     ELEM_OPT_TLV( 0x27 , BSSAP_PDU_TYPE_DTAP, DE_PRO_CONF_OPT , "" );
17060
17061     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17062 }
17063
17064 /*
17065  * [8] 9.5.9 Modify PDP context request (Network to MS direction)
17066  */
17067 static void
17068 dtap_sm_mod_pdp_req_net(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
17069 {
17070     guint32     curr_offset;
17071     guint32     consumed;
17072     guint       curr_len;
17073
17074     curr_offset = offset;
17075     curr_len = len;
17076
17077     is_uplink = IS_UPLINK_UNKNOWN;
17078     g_pinfo->p2p_dir = P2P_DIR_UNKNOWN;
17079
17080         ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP,DE_RAD_PRIO);
17081 #if 0   
17082     /* This is done automatically */
17083     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_SPARE );
17084     curr_offset--;
17085     curr_len++;
17086 #endif
17087
17088     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_LLC_SAPI );
17089
17090     ELEM_MAND_LV(BSSAP_PDU_TYPE_DTAP, DE_QOS , " - New QoS" );
17091
17092     ELEM_OPT_TLV( 0x2B , BSSAP_PDU_TYPE_DTAP, DE_PD_PRO_ADDR , "" );
17093
17094     ELEM_OPT_TLV( 0x34 , BSSAP_PDU_TYPE_DTAP, DE_PACKET_FLOW_ID , "" );
17095
17096     ELEM_OPT_TLV( 0x27 , BSSAP_PDU_TYPE_DTAP, DE_PRO_CONF_OPT , "" );
17097
17098     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17099 }
17100
17101 /*
17102  * [8] 9.5.10 Modify PDP context request (MS to network direction)
17103  */
17104 static void
17105 dtap_sm_mod_pdp_req_ms(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
17106 {
17107     guint32     curr_offset;
17108     guint32     consumed;
17109     guint       curr_len;
17110
17111     curr_offset = offset;
17112     curr_len = len;
17113
17114     is_uplink = IS_UPLINK_UNKNOWN;
17115     g_pinfo->p2p_dir = P2P_DIR_UNKNOWN;
17116
17117     ELEM_OPT_TV( 0x32 , BSSAP_PDU_TYPE_DTAP, DE_LLC_SAPI , " - Requested LLC SAPI" );
17118
17119     ELEM_OPT_TLV( 0x30 , BSSAP_PDU_TYPE_DTAP, DE_QOS , " - Requested new QoS" );
17120
17121     ELEM_OPT_TLV( 0x31 , BSSAP_PDU_TYPE_DTAP, DE_TRAFFIC_FLOW_TEMPLATE , " - New TFT" );
17122
17123     ELEM_OPT_TLV( 0x27 , BSSAP_PDU_TYPE_DTAP, DE_PRO_CONF_OPT , "" );
17124
17125     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17126 }
17127
17128 /*
17129  * [8] 9.5.11 Modify PDP context accept (MS to network direction)
17130  */
17131 static void
17132 dtap_sm_mod_pdp_acc_ms(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
17133 {
17134     guint32     curr_offset;
17135     guint32     consumed;
17136     guint       curr_len;
17137
17138     curr_offset = offset;
17139     curr_len = len;
17140
17141     is_uplink = IS_UPLINK_UNKNOWN;
17142     g_pinfo->p2p_dir = P2P_DIR_UNKNOWN;
17143
17144     ELEM_OPT_TLV( 0x27 , BSSAP_PDU_TYPE_DTAP, DE_PRO_CONF_OPT , "" );
17145
17146     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17147 }
17148
17149 /*
17150  * [8] 9.5.12 Modify PDP context accept (Network to MS direction)
17151  */
17152 static void
17153 dtap_sm_mod_pdp_acc_net(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
17154 {
17155     guint32     curr_offset;
17156     guint32     consumed;
17157     guint       curr_len;
17158
17159     curr_offset = offset;
17160     curr_len = len;
17161
17162     is_uplink = IS_UPLINK_UNKNOWN;
17163     g_pinfo->p2p_dir = P2P_DIR_UNKNOWN;
17164
17165     ELEM_OPT_TLV( 0x30 , BSSAP_PDU_TYPE_DTAP, DE_QOS , " - Negotiated QoS" );
17166
17167     ELEM_OPT_TV( 0x32 , BSSAP_PDU_TYPE_DTAP, DE_LLC_SAPI , " - Negotiated LLC SAPI" );
17168
17169     ELEM_OPT_TV_SHORT ( 0x80 , BSSAP_PDU_TYPE_DTAP , DE_RAD_PRIO , " - New radio priority" );
17170
17171     ELEM_OPT_TLV( 0x34 , BSSAP_PDU_TYPE_DTAP, DE_PACKET_FLOW_ID , "" );
17172
17173     ELEM_OPT_TLV( 0x27 , BSSAP_PDU_TYPE_DTAP, DE_PRO_CONF_OPT , "" );
17174
17175     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17176 }
17177
17178 /*
17179  * [8] 9.5.13 Modify PDP Context Reject
17180  */
17181 static void
17182 dtap_sm_mod_pdp_rej(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
17183 {
17184     guint32     curr_offset;
17185     guint32     consumed;
17186     guint       curr_len;
17187
17188     curr_offset = offset;
17189     curr_len = len;
17190
17191     is_uplink = IS_UPLINK_UNKNOWN;
17192     g_pinfo->p2p_dir = P2P_DIR_UNKNOWN;
17193
17194     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_SM_CAUSE );
17195
17196     ELEM_OPT_TLV( 0x27 , BSSAP_PDU_TYPE_DTAP, DE_PRO_CONF_OPT , "" );
17197
17198     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17199 }
17200
17201 /*
17202  * [8] 9.5.14 Deactivate PDP context request
17203  */
17204 static void
17205 dtap_sm_deact_pdp_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
17206 {
17207     guint32     curr_offset;
17208     guint32     consumed;
17209     guint       curr_len;
17210
17211     curr_offset = offset;
17212     curr_len = len;
17213
17214     is_uplink = IS_UPLINK_UNKNOWN;
17215     g_pinfo->p2p_dir = P2P_DIR_UNKNOWN;
17216
17217     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_SM_CAUSE );
17218
17219     ELEM_OPT_TV_SHORT( 0x90 , BSSAP_PDU_TYPE_DTAP , DE_TEAR_DOWN_IND , "" );
17220
17221     ELEM_OPT_TLV( 0x27 , BSSAP_PDU_TYPE_DTAP, DE_PRO_CONF_OPT , "" );
17222
17223         /* MBMS context status 10.5.7.6 TLV 2 - 18 */
17224         ELEM_OPT_TLV( 0x35 , BSSAP_PDU_TYPE_DTAP, DE_MBMS_CTX_STATUS , "" );
17225
17226     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17227 }
17228
17229
17230 /*
17231  * [8] 9.5.15 Deactivate PDP context accept
17232  */
17233 static void
17234 dtap_sm_deact_pdp_acc(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
17235 {
17236     guint32     curr_offset;
17237     guint32     consumed;
17238     guint       curr_len;
17239
17240     curr_offset = offset;
17241     curr_len = len;
17242
17243      is_uplink = IS_UPLINK_UNKNOWN;
17244     g_pinfo->p2p_dir = P2P_DIR_UNKNOWN;
17245
17246     ELEM_OPT_TLV( 0x27 , BSSAP_PDU_TYPE_DTAP, DE_PRO_CONF_OPT , "" );
17247
17248         /* MBMS context status 10.5.7.6 TLV 2 - 18 */
17249         ELEM_OPT_TLV( 0x35 , BSSAP_PDU_TYPE_DTAP, DE_MBMS_CTX_STATUS , "" );
17250
17251     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17252 }
17253
17254 /*
17255  * [8] 9.5.21 SM Status
17256  */
17257 static void
17258 dtap_sm_status(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len)
17259 {
17260     guint32     curr_offset;
17261     guint32     consumed;
17262     guint       curr_len;
17263
17264     curr_offset = offset;
17265     curr_len = len;
17266
17267      is_uplink = IS_UPLINK_UNKNOWN;
17268     g_pinfo->p2p_dir = P2P_DIR_UNKNOWN;
17269
17270     ELEM_MAND_V(BSSAP_PDU_TYPE_DTAP, DE_SM_CAUSE );
17271
17272     EXTRANEOUS_DATA_CHECK(curr_len, 0);
17273 }
17274
17275 /*
17276  * [8] 9.5.22 Activate MBMS Context Request
17277  */
17278
17279         /* Requested MBMS NSAPI Enhanced Network service access point identifier 10.5.6.15 M V */
17280         /* Requested LLC SAPI LLC service access point identifier 10.5.6.9 M V 1 */
17281         /* Supported MBMS bearer capabilities MBMS bearer capabilities 10.5.6.14 M LV 2 - 3 */
17282         /* Requested multicast address Packet data protocol address 10.5.6.4 M LV 3 - 19 */
17283         /* Access point name Access point name 10.5.6.1 M LV 2 - 101 */
17284         /* 35 MBMS protocol configuration options MBMS protocol configuration options 10.5.6.15 O TLV 3 - 253 */
17285
17286 /*
17287  * [8] 9.5.23 Activate MBMS Context Accept
17288  */
17289
17290 /*
17291  * [8] 9.5.24 Activate MBMS Context Reject
17292  */
17293
17294 /*
17295  * [8] 9.5.25 Request MBMS Context Activation
17296  */
17297
17298 /*
17299  * [8] 9.5.26 Request MBMS Context Activation Reject
17300  */
17301
17302 #define NUM_GSM_DTAP_MSG_MM (sizeof(gsm_a_dtap_msg_mm_strings)/sizeof(value_string))
17303 static gint ett_gsm_dtap_msg_mm[NUM_GSM_DTAP_MSG_MM];
17304 static void (*dtap_msg_mm_fcn[])(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len) = {
17305     dtap_mm_imsi_det_ind,       /* IMSI Detach Indication */
17306     dtap_mm_loc_upd_acc,        /* Location Updating Accept */
17307     dtap_mm_loc_upd_rej,        /* Location Updating Reject */
17308     dtap_mm_loc_upd_req,        /* Location Updating Request */
17309     NULL /* no associated data */,      /* Authentication Reject */
17310     dtap_mm_auth_req,   /* Authentication Request */
17311     dtap_mm_auth_resp,  /* Authentication Response */
17312     dtap_mm_auth_fail,  /* Authentication Failure */
17313     dtap_mm_id_req,     /* Identity Request */
17314     dtap_mm_id_resp,    /* Identity Response */
17315     dtap_mm_tmsi_realloc_cmd,   /* TMSI Reallocation Command */
17316     NULL /* no associated data */,      /* TMSI Reallocation Complete */
17317     NULL /* no associated data */,      /* CM Service Accept */
17318     dtap_mm_cm_srvc_rej,        /* CM Service Reject */
17319     NULL /* no associated data */,      /* CM Service Abort */
17320     dtap_mm_cm_srvc_req,        /* CM Service Request */
17321     dtap_mm_cm_srvc_prompt,     /* CM Service Prompt */
17322     NULL,       /* Reserved: was allocated in earlier phases of the protocol */
17323     dtap_mm_cm_reestab_req,     /* CM Re-establishment Request */
17324     dtap_mm_abort,      /* Abort */
17325     NULL /* no associated data */,      /* MM Null */
17326     dtap_mm_mm_status,  /* MM Status */
17327     dtap_mm_mm_info,    /* MM Information */
17328     NULL,       /* NONE */
17329 };
17330
17331 #define NUM_GSM_DTAP_MSG_RR (sizeof(gsm_a_dtap_msg_rr_strings)/sizeof(value_string))
17332 static gint ett_gsm_dtap_msg_rr[NUM_GSM_DTAP_MSG_RR];
17333 static void (*dtap_msg_rr_fcn[])(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len) = {
17334     NULL,       /* RR Initialisation Request */
17335     NULL,       /* Additional Assignment */
17336     NULL,       /* Immediate Assignment */
17337     NULL,       /* Immediate Assignment Extended */
17338     NULL,       /* Immediate Assignment Reject */
17339
17340     NULL,       /* DTM Assignment Failure */
17341     NULL,       /* DTM Reject */
17342     NULL,       /* DTM Request */
17343     NULL,       /* Main DCCH Assignment Command */
17344     NULL,       /* Packet Assignment Command */
17345
17346     NULL,       /* Ciphering Mode Command */
17347     NULL,       /* Ciphering Mode Complete */
17348
17349     NULL,       /* Configuration Change Command */
17350     NULL,       /* Configuration Change Ack. */
17351     NULL,       /* Configuration Change Reject */
17352
17353     NULL,       /* Assignment Command */
17354     NULL,       /* Assignment Complete */
17355     NULL,       /* Assignment Failure */
17356     dtap_rr_ho_cmd,     /* Handover Command */
17357     NULL,       /* Handover Complete */
17358     NULL,       /* Handover Failure */
17359     NULL,       /* Physical Information */
17360     NULL,       /* DTM Assignment Command */
17361
17362     NULL,       /* RR-cell Change Order */
17363     NULL,       /* PDCH Assignment Command */
17364
17365     NULL,       /* Channel Release */
17366     NULL,       /* Partial Release */
17367     NULL,       /* Partial Release Complete */
17368
17369     NULL,       /* Paging Request Type 1 */
17370     NULL,       /* Paging Request Type 2 */
17371     NULL,       /* Paging Request Type 3 */
17372     dtap_rr_paging_resp,        /* Paging Response */
17373     NULL,       /* Notification/NCH */
17374     NULL,       /* Reserved */
17375     NULL,       /* Notification/Response */
17376
17377     NULL,       /* Reserved */
17378
17379     NULL,       /* Utran Classmark Change  */
17380     NULL,       /* UE RAB Preconfiguration */
17381     NULL,       /* cdma2000 Classmark Change */
17382     NULL,       /* Inter System to UTRAN Handover Command */
17383     NULL,       /* Inter System to cdma2000 Handover Command */
17384
17385     NULL,       /* System Information Type 8 */
17386     NULL,       /* System Information Type 1 */
17387     NULL,       /* System Information Type 2 */
17388     NULL,       /* System Information Type 3 */
17389     NULL,       /* System Information Type 4 */
17390     NULL,       /* System Information Type 5 */
17391     NULL,       /* System Information Type 6 */
17392     NULL,       /* System Information Type 7 */
17393
17394     NULL,       /* System Information Type 2bis */
17395     NULL,       /* System Information Type 2ter */
17396     NULL,       /* System Information Type 2quater */
17397     NULL,       /* System Information Type 5bis */
17398     NULL,       /* System Information Type 5ter */
17399     NULL,       /* System Information Type 9 */
17400     NULL,       /* System Information Type 13 */
17401
17402     NULL,       /* System Information Type 16 */
17403     NULL,       /* System Information Type 17 */
17404
17405     NULL,       /* System Information Type 18 */
17406     NULL,       /* System Information Type 19 */
17407     NULL,       /* System Information Type 20 */
17408
17409     NULL,       /* Channel Mode Modify */
17410     dtap_rr_rr_status,  /* RR Status */
17411     NULL,       /* Channel Mode Modify Acknowledge */
17412     NULL,       /* Frequency Redefinition */
17413     NULL,       /* Measurement Report */
17414     NULL,       /* Classmark Change */
17415     NULL,       /* Classmark Enquiry */
17416     NULL,       /* Extended Measurement Report */
17417     NULL,       /* Extended Measurement Order */
17418     NULL,       /* GPRS Suspension Request */
17419
17420     NULL,       /* VGCS Uplink Grant */
17421     NULL,       /* Uplink Release */
17422     NULL,       /* Reserved */
17423     NULL,       /* Uplink Busy */
17424     NULL,       /* Talker Indication */
17425
17426     NULL,       /* UTRAN Classmark Change/Handover To UTRAN Command */  /* spec conflict */
17427
17428     NULL,       /* Application Information */
17429
17430     NULL,       /* NONE */
17431 };
17432
17433 #define NUM_GSM_DTAP_MSG_CC (sizeof(gsm_a_dtap_msg_cc_strings)/sizeof(value_string))
17434 static gint ett_gsm_dtap_msg_cc[NUM_GSM_DTAP_MSG_CC];
17435 static void (*dtap_msg_cc_fcn[])(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len) = {
17436     dtap_cc_alerting,   /* Alerting */
17437     dtap_cc_call_conf,  /* Call Confirmed */
17438     dtap_cc_call_proceed,       /* Call Proceeding */
17439     dtap_cc_connect,    /* Connect */
17440     NULL /* no associated data */,      /* Connect Acknowledge */
17441     dtap_cc_emerg_setup,        /* Emergency Setup */
17442     dtap_cc_progress,   /* Progress */
17443     dtap_cc_cc_est,     /* CC-Establishment */
17444     dtap_cc_cc_est_conf,        /* CC-Establishment Confirmed */
17445     dtap_cc_recall,     /* Recall */
17446     dtap_cc_start_cc,   /* Start CC */
17447     dtap_cc_setup,      /* Setup */
17448     dtap_cc_modify,     /* Modify */
17449     dtap_cc_modify_complete,    /* Modify Complete */
17450     dtap_cc_modify_rej, /* Modify Reject */
17451     dtap_cc_user_info,  /* User Information */
17452     NULL /* no associated data */,      /* Hold */
17453     NULL /* no associated data */,      /* Hold Acknowledge */
17454     dtap_cc_hold_rej,   /* Hold Reject */
17455     NULL /* no associated data */,      /* Retrieve */
17456     NULL /* no associated data */,      /* Retrieve Acknowledge */
17457     dtap_cc_retrieve_rej,       /* Retrieve Reject */
17458     dtap_cc_disconnect, /* Disconnect */
17459     dtap_cc_release,    /* Release */
17460     dtap_cc_release_complete,   /* Release Complete */
17461     dtap_cc_congestion_control, /* Congestion Control */
17462     dtap_cc_notify,     /* Notify */
17463     dtap_cc_status,     /* Status */
17464     NULL /* no associated data */,      /* Status Enquiry */
17465     dtap_cc_start_dtmf, /* Start DTMF */
17466     NULL /* no associated data */,      /* Stop DTMF */
17467     NULL /* no associated data */,      /* Stop DTMF Acknowledge */
17468     dtap_cc_start_dtmf_ack,     /* Start DTMF Acknowledge */
17469     dtap_cc_start_dtmf_rej,     /* Start DTMF Reject */
17470     dtap_cc_facility,   /* Facility */
17471     NULL,       /* NONE */
17472 };
17473
17474 #define NUM_GSM_DTAP_MSG_GMM (sizeof(gsm_a_dtap_msg_gmm_strings)/sizeof(value_string))
17475 static gint ett_gsm_dtap_msg_gmm[NUM_GSM_DTAP_MSG_GMM];
17476 static void (*dtap_msg_gmm_fcn[])(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len) = {
17477     dtap_gmm_attach_req,                /* Attach Request */
17478     dtap_gmm_attach_acc,                /* Attach Accept */
17479     dtap_gmm_attach_com,                /* Attach Complete */
17480     dtap_gmm_attach_rej,                /* Attach Reject */
17481     dtap_gmm_detach_req,                /* Detach Request */
17482     dtap_gmm_detach_acc,                /* Detach Accept */
17483     dtap_gmm_rau_req,                   /* Routing Area Update Request */
17484     dtap_gmm_rau_acc,                   /* Routing Area Update Accept */
17485     dtap_gmm_rau_com,                   /* Routing Area Update Complete */
17486     dtap_gmm_rau_rej,                   /* Routing Area Update Reject */
17487     dtap_gmm_service_req,               /* Service Request */
17488     dtap_gmm_service_acc,               /* Service Accept */
17489     dtap_gmm_service_rej,               /* Service Reject */
17490     dtap_gmm_ptmsi_realloc_cmd, /* P-TMSI Reallocation Command */
17491     dtap_gmm_ptmsi_realloc_com, /* P-TMSI Reallocation Complete */
17492     dtap_gmm_auth_ciph_req,             /* Authentication and Ciphering Req */
17493     dtap_gmm_auth_ciph_resp,    /* Authentication and Ciphering Resp */
17494     dtap_gmm_auth_ciph_rej,             /* Authentication and Ciphering Rej */
17495     dtap_gmm_auth_ciph_fail,    /* Authentication and Ciphering Failure */
17496     dtap_gmm_ident_req,                 /* Identity Request */
17497     dtap_gmm_ident_res,                 /* Identity Response */
17498     dtap_gmm_status,                    /* GMM Status */
17499     dtap_gmm_information,               /* GMM Information */
17500     NULL,       /* NONE */
17501 };
17502
17503 #define NUM_GSM_DTAP_MSG_SMS (sizeof(gsm_a_dtap_msg_sms_strings)/sizeof(value_string))
17504 static gint ett_gsm_dtap_msg_sms[NUM_GSM_DTAP_MSG_SMS];
17505 static void (*dtap_msg_sms_fcn[])(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len) = {
17506     dtap_sms_cp_data,   /* CP-DATA */
17507     NULL /* no associated data */,      /* CP-ACK */
17508     dtap_sms_cp_error,  /* CP-ERROR */
17509     NULL,       /* NONE */
17510 };
17511
17512 #define NUM_GSM_DTAP_MSG_SM (sizeof(gsm_a_dtap_msg_sm_strings)/sizeof(value_string))
17513 static gint ett_gsm_dtap_msg_sm[NUM_GSM_DTAP_MSG_SM];
17514 static void (*dtap_msg_sm_fcn[])(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len) = {
17515     dtap_sm_act_pdp_req,                /* Activate PDP Context Request */
17516     dtap_sm_act_pdp_acc,                /* Activate PDP Context Accept */
17517     dtap_sm_act_pdp_rej,                /* Activate PDP Context Reject */
17518     dtap_sm_req_pdp_act,                /* Request PDP Context Activation */
17519     dtap_sm_req_pdp_act_rej,    /* Request PDP Context Activation rej. */
17520     dtap_sm_deact_pdp_req,              /* Deactivate PDP Context Request */
17521     dtap_sm_deact_pdp_acc,              /* Deactivate PDP Context Accept */
17522     dtap_sm_mod_pdp_req_net,    /* Modify PDP Context Request(Network to MS direction) */
17523     dtap_sm_mod_pdp_acc_ms,             /* Modify PDP Context Accept (MS to network direction) */
17524     dtap_sm_mod_pdp_req_ms,             /* Modify PDP Context Request(MS to network direction) */
17525     dtap_sm_mod_pdp_acc_net,    /* Modify PDP Context Accept (Network to MS direction) */
17526     dtap_sm_mod_pdp_rej,                /* Modify PDP Context Reject */
17527     dtap_sm_act_sec_pdp_req,    /* Activate Secondary PDP Context Request */
17528     dtap_sm_act_sec_pdp_acc,    /* Activate Secondary PDP Context Accept */
17529     dtap_sm_act_sec_pdp_rej,    /* Activate Secondary PDP Context Reject */
17530     NULL,                                               /* Reserved: was allocated in earlier phases of the protocol */
17531     NULL,                                               /* Reserved: was allocated in earlier phases of the protocol */
17532     NULL,                                               /* Reserved: was allocated in earlier phases of the protocol */
17533     NULL,                                               /* Reserved: was allocated in earlier phases of the protocol */
17534     NULL,                                               /* Reserved: was allocated in earlier phases of the protocol */
17535     dtap_sm_status,                             /* SM Status */
17536                                                                 /* Activate MBMS Context Request */
17537                                                                 /* Activate MBMS Context Accept */
17538                                                                 /* Activate MBMS Context Reject */
17539                                                                 /* Request MBMS Context Activation */
17540                                                                 /* Request MBMS Context Activation Reject */
17541     NULL,       /* NONE */
17542 };
17543
17544 #define NUM_GSM_DTAP_MSG_SS (sizeof(gsm_a_dtap_msg_ss_strings)/sizeof(value_string))
17545 static gint ett_gsm_dtap_msg_ss[NUM_GSM_DTAP_MSG_SS];
17546 static void (*dtap_msg_ss_fcn[])(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len) = {
17547     dtap_cc_release_complete,   /* Release Complete */
17548     dtap_cc_facility,   /* Facility */
17549     dtap_ss_register,   /* Register */
17550     NULL,       /* NONE */
17551 };
17552
17553 #define NUM_GSM_RP_MSG (sizeof(gsm_rp_msg_strings)/sizeof(value_string))
17554 static gint ett_gsm_rp_msg[NUM_GSM_RP_MSG];
17555 static void (*rp_msg_fcn[])(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len) = {
17556     rp_data_ms_n,       /* RP-DATA (MS to Network) */
17557     rp_data_n_ms,       /* RP-DATA (Network to MS */
17558     rp_ack_ms_n,        /* RP-ACK (MS to Network) */
17559     rp_ack_n_ms,        /* RP-ACK (Network to MS) */
17560     rp_error_ms_n,      /* RP-ERROR (MS to Network) */
17561     rp_error_n_ms,      /* RP-ERROR (Network to MS) */
17562     rp_smma,    /* RP-SMMA (MS to Network) */
17563     NULL,       /* NONE */
17564 };
17565
17566 /* GENERIC DISSECTOR FUNCTIONS */
17567
17568 static void
17569 dissect_rp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
17570 {
17571     guint8      oct;
17572     guint32     offset, saved_offset;
17573     guint32     len;
17574     gint        idx;
17575     proto_item  *rp_item = NULL;
17576     proto_tree  *rp_tree = NULL;
17577     const gchar *str;
17578
17579
17580     if (check_col(pinfo->cinfo, COL_INFO))
17581     {
17582         col_append_str(pinfo->cinfo, COL_INFO, "(RP) ");
17583     }
17584
17585     /*
17586      * In the interest of speed, if "tree" is NULL, don't do any work
17587      * not necessary to generate protocol tree items.
17588      */
17589     if (!tree)
17590     {
17591         return;
17592     }
17593
17594     offset = 0;
17595     saved_offset = offset;
17596
17597     g_pinfo = pinfo;
17598     g_tree = tree;
17599
17600     len = tvb_length(tvb);
17601
17602     /*
17603      * add RP message name
17604      */
17605     oct = tvb_get_guint8(tvb, offset++);
17606
17607     str = match_strval_idx((guint32) oct, gsm_rp_msg_strings, &idx);
17608
17609     /*
17610      * create the protocol tree
17611      */
17612     if (str == NULL)
17613     {
17614         rp_item =
17615             proto_tree_add_protocol_format(tree, proto_a_rp, tvb, 0, len,
17616                 "GSM A-I/F RP - Unknown RP Message Type (0x%02x)",
17617                 oct);
17618
17619         rp_tree = proto_item_add_subtree(rp_item, ett_rp_msg);
17620     }
17621     else
17622     {
17623         rp_item =
17624             proto_tree_add_protocol_format(tree, proto_a_rp, tvb, 0, -1,
17625                 "GSM A-I/F RP - %s",
17626                 str);
17627
17628         rp_tree = proto_item_add_subtree(rp_item, ett_gsm_rp_msg[idx]);
17629
17630         if (check_col(pinfo->cinfo, COL_INFO))
17631         {
17632             col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", str);
17633         }
17634     }
17635
17636     /*
17637      * add RP message name
17638      */
17639     proto_tree_add_uint_format(rp_tree, hf_gsm_a_rp_msg_type,
17640                 tvb, saved_offset, 1, oct, "Message Type %s", str ? str : "(Unknown)");
17641
17642     if (str == NULL) return;
17643
17644     if ((len - offset) <= 0) return;
17645
17646     /*
17647      * decode elements
17648      */
17649     if (rp_msg_fcn[idx] == NULL)
17650     {
17651         proto_tree_add_text(rp_tree,
17652             tvb, offset, len - offset,
17653             "Message Elements");
17654     }
17655     else
17656     {
17657         (*rp_msg_fcn[idx])(tvb, rp_tree, offset, len - offset);
17658     }
17659 }
17660
17661
17662 void
17663 dissect_bssmap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
17664 {
17665     static gsm_a_tap_rec_t      tap_rec[4];
17666     static gsm_a_tap_rec_t      *tap_p;
17667     static int                  tap_current=0;
17668     guint8      oct;
17669     guint32     offset, saved_offset;
17670     guint32     len;
17671     gint        idx;
17672     proto_item  *bssmap_item = NULL;
17673     proto_tree  *bssmap_tree = NULL;
17674     const gchar *str;
17675         
17676
17677         sccp_msg = pinfo->sccp_info;
17678         
17679         if (sccp_msg && sccp_msg->data.co.assoc) {
17680                 sccp_assoc = sccp_msg->data.co.assoc;
17681         } else {
17682                 sccp_assoc = NULL;
17683                 sccp_msg = NULL;
17684         }
17685         
17686     if (check_col(pinfo->cinfo, COL_INFO))
17687     {
17688         col_append_str(pinfo->cinfo, COL_INFO, "(BSSMAP) ");
17689     }
17690
17691     /*
17692      * set tap record pointer
17693      */
17694     tap_current++;
17695     if (tap_current == 4)
17696     {
17697         tap_current = 0;
17698     }
17699     tap_p = &tap_rec[tap_current];
17700
17701
17702     offset = 0;
17703     saved_offset = offset;
17704
17705     g_pinfo = pinfo;
17706     g_tree = tree;
17707
17708     len = tvb_length(tvb);
17709
17710     /*
17711      * add BSSMAP message name
17712      */
17713     oct = tvb_get_guint8(tvb, offset++);
17714
17715     str = match_strval_idx((guint32) oct, gsm_a_bssmap_msg_strings, &idx);
17716
17717         if (sccp_msg && !sccp_msg->data.co.label) {
17718                 sccp_msg->data.co.label = se_strdup(val_to_str((guint32) oct, gsm_a_bssmap_msg_strings, "BSSMAP (0x%02x)"));
17719         }
17720         
17721     /*
17722      * create the protocol tree
17723      */
17724     if (str == NULL)
17725     {
17726         bssmap_item =
17727             proto_tree_add_protocol_format(tree, proto_a_bssmap, tvb, 0, len,
17728                 "GSM A-I/F BSSMAP - Unknown BSSMAP Message Type (0x%02x)",
17729                 oct);
17730
17731         bssmap_tree = proto_item_add_subtree(bssmap_item, ett_bssmap_msg);
17732     }
17733     else
17734     {
17735         bssmap_item =
17736             proto_tree_add_protocol_format(tree, proto_a_bssmap, tvb, 0, -1,
17737                 "GSM A-I/F BSSMAP - %s",
17738                 str);
17739
17740         bssmap_tree = proto_item_add_subtree(bssmap_item, ett_gsm_bssmap_msg[idx]);
17741
17742         if (check_col(pinfo->cinfo, COL_INFO))
17743         {
17744             col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", str);
17745         }
17746
17747     /*
17748      * add BSSMAP message name
17749      */
17750     proto_tree_add_uint_format(bssmap_tree, hf_gsm_a_bssmap_msg_type,
17751         tvb, saved_offset, 1, oct, "Message Type %s",str);
17752     }
17753
17754     tap_p->pdu_type = BSSAP_PDU_TYPE_BSSMAP;
17755     tap_p->message_type = oct;
17756
17757     tap_queue_packet(gsm_a_tap, pinfo, tap_p);
17758
17759     if (str == NULL) return;
17760
17761     if ((len - offset) <= 0) return;
17762
17763     /*
17764      * decode elements
17765      */
17766     if (bssmap_msg_fcn[idx] == NULL)
17767     {
17768         proto_tree_add_text(bssmap_tree,
17769             tvb, offset, len - offset,
17770             "Message Elements");
17771     }
17772     else
17773     {
17774         (*bssmap_msg_fcn[idx])(tvb, bssmap_tree, offset, len - offset);
17775     }
17776 }
17777
17778
17779 static void
17780 dissect_dtap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
17781 {
17782     static gsm_a_tap_rec_t      tap_rec[4];
17783     static gsm_a_tap_rec_t      *tap_p;
17784     static int                  tap_current=0;
17785     void                        (*msg_fcn)(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len);
17786     guint8                      oct;
17787     guint8                      pd;
17788     guint32                     offset;
17789     guint32                     len;
17790     guint32                     oct_1, oct_2;
17791     gint                        idx;
17792     proto_item                  *dtap_item = NULL;
17793     proto_tree                  *dtap_tree = NULL;
17794     proto_item                  *oct_1_item = NULL;
17795     proto_tree                  *pd_tree = NULL;
17796     const gchar                 *msg_str;
17797     gint                        ett_tree;
17798     gint                        ti;
17799     int                         hf_idx;
17800     gboolean                    nsd;
17801
17802
17803     len = tvb_length(tvb);
17804
17805     if (len < 2)
17806     {
17807         /*
17808          * too short to be DTAP
17809          */
17810         call_dissector(data_handle, tvb, pinfo, tree);
17811         return;
17812     }
17813
17814     if (check_col(pinfo->cinfo, COL_INFO))
17815     {
17816         col_append_str(pinfo->cinfo, COL_INFO, "(DTAP) ");
17817     }
17818
17819     /*
17820      * set tap record pointer
17821      */
17822     tap_current++;
17823     if (tap_current == 4)
17824     {
17825         tap_current = 0;
17826     }
17827     tap_p = &tap_rec[tap_current];
17828
17829
17830     offset = 0;
17831     oct_2 = 0;
17832
17833     g_pinfo = pinfo;
17834     g_tree = tree;
17835
17836     /*
17837      * get protocol discriminator
17838      */
17839     oct_1 = tvb_get_guint8(tvb, offset++);
17840
17841     if ((((oct_1 & DTAP_TI_MASK) >> 4) & DTAP_TIE_PRES_MASK) == DTAP_TIE_PRES_MASK)
17842     {
17843         /*
17844          * eventhough we don't know if a TI should be in the message yet
17845          * we rely on the TI/SKIP indicator to be 0 to avoid taking this
17846          * octet
17847          */
17848         oct_2 = tvb_get_guint8(tvb, offset++);
17849     }
17850
17851     oct = tvb_get_guint8(tvb, offset);
17852
17853     pd = oct_1 & DTAP_PD_MASK;
17854     ti = -1;
17855     msg_str = NULL;
17856     ett_tree = -1;
17857     hf_idx = -1;
17858     msg_fcn = NULL;
17859     nsd = FALSE;
17860     if (check_col(pinfo->cinfo, COL_INFO))
17861     {
17862         col_append_fstr(pinfo->cinfo, COL_INFO, "(%s) ",val_to_str(pd,gsm_a_pd_short_str_vals,"unknown"));
17863     }
17864
17865     /*
17866      * octet 1
17867      */
17868     switch (pd)
17869     {
17870     case 3:
17871         msg_str = match_strval_idx((guint32) (oct & DTAP_CC_IEI_MASK), gsm_a_dtap_msg_cc_strings, &idx);
17872         ett_tree = ett_gsm_dtap_msg_cc[idx];
17873         hf_idx = hf_gsm_a_dtap_msg_cc_type;
17874         msg_fcn = dtap_msg_cc_fcn[idx];
17875         ti = (oct_1 & DTAP_TI_MASK) >> 4;
17876         nsd = TRUE;
17877         break;
17878
17879     case 5:
17880         msg_str = match_strval_idx((guint32) (oct & DTAP_MM_IEI_MASK), gsm_a_dtap_msg_mm_strings, &idx);
17881         ett_tree = ett_gsm_dtap_msg_mm[idx];
17882         hf_idx = hf_gsm_a_dtap_msg_mm_type;
17883         msg_fcn = dtap_msg_mm_fcn[idx];
17884         nsd = TRUE;
17885         break;
17886
17887     case 6:
17888         msg_str = match_strval_idx((guint32) (oct & DTAP_RR_IEI_MASK), gsm_a_dtap_msg_rr_strings, &idx);
17889         ett_tree = ett_gsm_dtap_msg_rr[idx];
17890         hf_idx = hf_gsm_a_dtap_msg_rr_type;
17891         msg_fcn = dtap_msg_rr_fcn[idx];
17892         break;
17893
17894     case 8:
17895         msg_str = match_strval_idx((guint32) (oct & DTAP_GMM_IEI_MASK), gsm_a_dtap_msg_gmm_strings, &idx);
17896         ett_tree = ett_gsm_dtap_msg_gmm[idx];
17897         hf_idx = hf_gsm_a_dtap_msg_gmm_type;
17898         msg_fcn = dtap_msg_gmm_fcn[idx];
17899         break;
17900
17901     case 9:
17902         msg_str = match_strval_idx((guint32) (oct & DTAP_SMS_IEI_MASK), gsm_a_dtap_msg_sms_strings, &idx);
17903         ett_tree = ett_gsm_dtap_msg_sms[idx];
17904         hf_idx = hf_gsm_a_dtap_msg_sms_type;
17905         msg_fcn = dtap_msg_sms_fcn[idx];
17906         ti = (oct_1 & DTAP_TI_MASK) >> 4;
17907         break;
17908
17909     case 10:
17910         msg_str = match_strval_idx((guint32) (oct & DTAP_SM_IEI_MASK), gsm_a_dtap_msg_sm_strings, &idx);
17911         ett_tree = ett_gsm_dtap_msg_sm[idx];
17912         hf_idx = hf_gsm_a_dtap_msg_sm_type;
17913         msg_fcn = dtap_msg_sm_fcn[idx];
17914         ti = (oct_1 & DTAP_TI_MASK) >> 4;
17915         break;
17916
17917     case 11:
17918         msg_str = match_strval_idx((guint32) (oct & DTAP_SS_IEI_MASK), gsm_a_dtap_msg_ss_strings, &idx);
17919         ett_tree = ett_gsm_dtap_msg_ss[idx];
17920         hf_idx = hf_gsm_a_dtap_msg_ss_type;
17921         msg_fcn = dtap_msg_ss_fcn[idx];
17922         ti = (oct_1 & DTAP_TI_MASK) >> 4;
17923         nsd = TRUE;
17924         break;
17925
17926     default:
17927     /* 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 */
17928     return;
17929         break;
17930     }
17931
17932         sccp_msg = pinfo->sccp_info;
17933         
17934         if (sccp_msg && sccp_msg->data.co.assoc) {
17935                 sccp_assoc = sccp_msg->data.co.assoc;
17936         } else {
17937                 sccp_assoc = NULL;
17938                 sccp_msg = NULL;
17939         }
17940         
17941     /*
17942      * create the protocol tree
17943      */
17944     if (msg_str == NULL)
17945     {
17946         dtap_item =
17947             proto_tree_add_protocol_format(tree, proto_a_dtap, tvb, 0, len,
17948                 "GSM A-I/F DTAP - Unknown DTAP Message Type (0x%02x)",
17949                 oct);
17950
17951         dtap_tree = proto_item_add_subtree(dtap_item, ett_dtap_msg);
17952         
17953         if (sccp_msg && !sccp_msg->data.co.label) {
17954                 sccp_msg->data.co.label = se_strdup_printf("DTAP (0x%02x)",oct);
17955         }
17956         
17957         
17958     }
17959     else
17960     {
17961         dtap_item =
17962             proto_tree_add_protocol_format(tree, proto_a_dtap, tvb, 0, -1,
17963                 "GSM A-I/F DTAP - %s",
17964                 msg_str);
17965
17966         dtap_tree = proto_item_add_subtree(dtap_item, ett_tree);
17967
17968         if (sccp_msg && !sccp_msg->data.co.label) {
17969                 sccp_msg->data.co.label = se_strdup(msg_str);
17970         }
17971
17972         if (check_col(pinfo->cinfo, COL_INFO))
17973         {
17974             col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", msg_str);
17975         }
17976     }
17977
17978     oct_1_item =
17979         proto_tree_add_text(dtap_tree,
17980             tvb, 0, 1,
17981             "Protocol Discriminator: %s",
17982             val_to_str(pd, protocol_discriminator_vals, "Unknown (%u)"));
17983
17984     pd_tree = proto_item_add_subtree(oct_1_item, ett_dtap_oct_1);
17985
17986     if (ti == -1)
17987     {
17988         proto_tree_add_item(pd_tree, hf_gsm_a_skip_ind, tvb, 0, 1, FALSE);
17989     }
17990     else
17991     {
17992         other_decode_bitfield_value(a_bigbuf, oct_1, 0x80, 8);
17993         proto_tree_add_text(pd_tree,
17994             tvb, 0, 1,
17995             "%s :  TI flag: %s",
17996             a_bigbuf,
17997             ((oct_1 & 0x80) ?  "allocated by receiver" : "allocated by sender"));
17998
17999         if ((ti & DTAP_TIE_PRES_MASK) == DTAP_TIE_PRES_MASK)
18000         {
18001             /* ti is extended to next octet */
18002
18003             other_decode_bitfield_value(a_bigbuf, oct_1, 0x70, 8);
18004             proto_tree_add_text(pd_tree,
18005                 tvb, 0, 1,
18006                 "%s :  TIO: The TI value is given by the TIE in octet 2",
18007                 a_bigbuf);
18008         }
18009         else
18010         {
18011             other_decode_bitfield_value(a_bigbuf, oct_1, 0x70, 8);
18012             proto_tree_add_text(pd_tree,
18013                 tvb, 0, 1,
18014                 "%s :  TIO: %u",
18015                 a_bigbuf,
18016                 ti & DTAP_TIE_PRES_MASK);
18017         }
18018     }
18019
18020     proto_tree_add_item(pd_tree, hf_gsm_a_L3_protocol_discriminator, tvb, 0, 1, FALSE);
18021
18022     if ((ti != -1) &&
18023         (ti & DTAP_TIE_PRES_MASK) == DTAP_TIE_PRES_MASK)
18024     {
18025         proto_tree_add_item(tree, hf_gsm_a_extension, tvb, 1, 1, FALSE);
18026
18027         other_decode_bitfield_value(a_bigbuf, oct_2, DTAP_TIE_MASK, 8);
18028         proto_tree_add_text(pd_tree,
18029             tvb, 1, 1,
18030             "%s :  TIE: %u",
18031             a_bigbuf,
18032             oct_2 & DTAP_TIE_MASK);
18033     }
18034
18035     /*
18036      * N(SD)
18037      */
18038     if ((pinfo->p2p_dir == P2P_DIR_RECV) &&
18039         nsd)
18040     {
18041         /* XXX */
18042     }
18043
18044     /*
18045      * add DTAP message name
18046      */
18047     proto_tree_add_uint_format(dtap_tree, hf_idx,
18048         tvb, offset, 1, oct,
18049         "Message Type %s",msg_str ? msg_str : "(Unknown)");
18050
18051     offset++;
18052
18053     tap_p->pdu_type = BSSAP_PDU_TYPE_DTAP;
18054     tap_p->message_type = (nsd ? (oct & 0x3f) : oct);
18055     tap_p->protocol_disc = pd;
18056
18057     tap_queue_packet(gsm_a_tap, pinfo, tap_p);
18058
18059     if (msg_str == NULL) return;
18060
18061     if ((len - offset) <= 0) return;
18062
18063     /*
18064      * decode elements
18065      */
18066     if (msg_fcn == NULL)
18067     {
18068         proto_tree_add_text(dtap_tree,
18069             tvb, offset, len - offset,
18070             "Message Elements");
18071     }
18072     else
18073     {
18074         (*msg_fcn)(tvb, dtap_tree, offset, len - offset);
18075     }
18076 }
18077
18078
18079 /* Register the protocol with Wireshark */
18080 void
18081 proto_register_gsm_a(void)
18082 {
18083     guint               i;
18084     guint               last_offset;
18085
18086     /* Setup list of header fields */
18087
18088     static hf_register_info hf[] =
18089     {
18090         { &hf_gsm_a_bssmap_msg_type,
18091             { "BSSMAP Message Type",    "gsm_a.bssmap_msgtype",
18092             FT_UINT8, BASE_HEX, VALS(gsm_a_bssmap_msg_strings), 0x0,
18093             "", HFILL }
18094         },
18095         { &hf_gsm_a_dtap_msg_mm_type,
18096             { "DTAP Mobility Management Message Type",  "gsm_a.dtap_msg_mm_type",
18097             FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_msg_mm_strings), 0x0,
18098             "", HFILL }
18099         },
18100         { &hf_gsm_a_dtap_msg_rr_type,
18101             { "DTAP Radio Resources Management Message Type",   "gsm_a.dtap_msg_rr_type",
18102             FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_msg_rr_strings), 0x0,
18103             "", HFILL }
18104         },
18105         { &hf_gsm_a_dtap_msg_cc_type,
18106             { "DTAP Call Control Message Type", "gsm_a.dtap_msg_cc_type",
18107             FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_msg_cc_strings), 0x0,
18108             "", HFILL }
18109         },
18110         { &hf_gsm_a_dtap_msg_gmm_type,
18111             { "DTAP GPRS Mobility Management Message Type",     "gsm_a.dtap_msg_gmm_type",
18112             FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_msg_gmm_strings), 0x0,
18113             "", HFILL }
18114         },
18115         { &hf_gsm_a_dtap_msg_sms_type,
18116             { "DTAP Short Message Service Message Type",        "gsm_a.dtap_msg_sms_type",
18117             FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_msg_sms_strings), 0x0,
18118             "", HFILL }
18119         },
18120         { &hf_gsm_a_dtap_msg_sm_type,
18121             { "DTAP GPRS Session Management Message Type",      "gsm_a.dtap_msg_sm_type",
18122             FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_msg_sm_strings), 0x0,
18123             "", HFILL }
18124         },
18125         { &hf_gsm_a_dtap_msg_ss_type,
18126             { "DTAP Non call Supplementary Service Message Type",       "gsm_a.dtap_msg_ss_type",
18127             FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_msg_ss_strings), 0x0,
18128             "", HFILL }
18129         },
18130         { &hf_gsm_a_rp_msg_type,
18131             { "RP Message Type",        "gsm_a.rp_msg_type",
18132             FT_UINT8, BASE_HEX, VALS(gsm_rp_msg_strings), 0x0,
18133             "", HFILL }
18134         },
18135         { &hf_gsm_a_bssmap_elem_id,
18136             { "Element ID",     "gsm_a_bssmap.elem_id",
18137             FT_UINT8, BASE_DEC, NULL, 0,
18138             "", HFILL }
18139         },
18140         { &hf_gsm_a_dtap_elem_id,
18141             { "Element ID",     "gsm_a_dtap.elem_id",
18142             FT_UINT8, BASE_DEC, NULL, 0,
18143             "", HFILL }
18144         },
18145         { &hf_gsm_a_length,
18146             { "Length",         "gsm_a.len",
18147             FT_UINT8, BASE_DEC, NULL, 0,
18148             "", HFILL }
18149         },
18150         { &hf_gsm_a_none,
18151             { "Sub tree",       "gsm_a.none",
18152             FT_NONE, 0, 0, 0,
18153             "", HFILL }
18154         },
18155         { &hf_gsm_a_imsi,
18156             { "IMSI",   "gsm_a.imsi",
18157             FT_STRING, BASE_DEC, 0, 0,
18158             "", HFILL }
18159         },
18160         { &hf_gsm_a_tmsi,
18161             { "TMSI/P-TMSI",    "gsm_a.tmsi",
18162             FT_UINT32, BASE_HEX, 0, 0x0,
18163             "", HFILL }
18164         },
18165         { &hf_gsm_a_imei,
18166             { "IMEI",   "gsm_a.imei",
18167             FT_STRING, BASE_DEC, 0, 0,
18168             "", HFILL }
18169         },
18170         { &hf_gsm_a_imeisv,
18171             { "IMEISV", "gsm_a.imeisv",
18172             FT_STRING, BASE_DEC, 0, 0,
18173             "", HFILL }
18174         },
18175         { &hf_gsm_a_cld_party_bcd_num,
18176             { "Called Party BCD Number",        "gsm_a.cld_party_bcd_num",
18177             FT_STRING, BASE_DEC, 0, 0,
18178             "", HFILL }
18179         },
18180         { &hf_gsm_a_clg_party_bcd_num,
18181             { "Calling Party BCD Number",       "gsm_a.clg_party_bcd_num",
18182             FT_STRING, BASE_DEC, 0, 0,
18183             "", HFILL }
18184         },
18185         { &hf_gsm_a_cell_ci,
18186             { "Cell CI",        "gsm_a.cell_ci",
18187             FT_UINT16, BASE_HEX_DEC, 0, 0x0,
18188             "", HFILL }
18189         },
18190         { &hf_gsm_a_cell_lac,
18191             { "Cell LAC",       "gsm_a.cell_lac",
18192             FT_UINT16, BASE_HEX_DEC, 0, 0x0,
18193             "", HFILL }
18194         },
18195         { &hf_gsm_a_dlci_cc,
18196             { "Control Channel", "bssap.dlci.cc",
18197             FT_UINT8, BASE_HEX, VALS(bssap_cc_values), 0xc0,
18198             "", HFILL}
18199         },
18200         { &hf_gsm_a_dlci_spare,
18201             { "Spare", "bssap.dlci.spare",
18202             FT_UINT8, BASE_HEX, NULL, 0x38,
18203             "", HFILL}
18204         },
18205         { &hf_gsm_a_dlci_sapi,
18206             { "SAPI", "bssap.dlci.sapi",
18207             FT_UINT8, BASE_HEX, VALS(bssap_sapi_values), 0x07,
18208             "", HFILL}
18209         },
18210         { &hf_gsm_a_bssmap_cause,
18211             { "BSSMAP Cause",   "gsm_a_bssmap.cause",
18212             FT_UINT8, BASE_HEX, 0, 0x0,
18213             "", HFILL }
18214         },
18215         { &hf_gsm_a_dtap_cause,
18216             { "DTAP Cause",     "gsm_a_dtap.cause",
18217             FT_UINT8, BASE_HEX, 0, 0x0,
18218             "", HFILL }
18219         },
18220         { &hf_gsm_a_MSC_rev,
18221                 { "Revision Level","gsm_a.MSC2_rev",
18222                 FT_UINT8,BASE_DEC,  VALS(gsm_a_msc_rev_vals), 0x60,          
18223                 "Revision level", HFILL }
18224         },
18225         { &hf_gsm_a_ES_IND,
18226                 { "ES IND","gsm_a.MSC2_rev",
18227                 FT_UINT8,BASE_DEC,  VALS(ES_IND_vals), 0x10,          
18228                         "ES IND", HFILL }
18229         },
18230     { &hf_gsm_a_qos_traffic_cls,
18231       { "Traffic class", "gsm_a.qos.traffic_cls",
18232         FT_UINT8, BASE_DEC, VALS(gsm_a_qos_traffic_cls_vals), 0xe0,
18233         "Traffic class", HFILL }},
18234     { &hf_gsm_a_qos_del_order,
18235       { "Delivery order", "gsm_a.qos.del_order",
18236         FT_UINT8, BASE_DEC, VALS(gsm_a_qos_traffic_cls_vals), 0x18,
18237         "Delivery order", HFILL }},
18238     { &hf_gsm_a_qos_del_of_err_sdu,
18239       { "Delivery of erroneous SDUs", "gsm_a.qos.del_of_err_sdu",
18240         FT_UINT8, BASE_DEC, VALS(gsm_a_qos_del_of_err_sdu_vals), 0x03,
18241         "Delivery of erroneous SDUs", HFILL }},
18242     { &hf_gsm_a_qos_ber,
18243       { "Residual Bit Error Rate (BER)", "gsm_a.qos.ber",
18244         FT_UINT8, BASE_DEC, VALS(gsm_a_qos_ber_vals), 0xf0,
18245         "Residual Bit Error Rate (BER)", HFILL }},
18246     { &hf_gsm_a_qos_sdu_err_rat,
18247       { "SDU error ratio", "gsm_a.qos.sdu_err_rat",
18248         FT_UINT8, BASE_DEC, VALS(gsm_a_qos_sdu_err_rat_vals), 0x0f,
18249         "SDU error ratio", HFILL }},
18250     { &hf_gsm_a_qos_traff_hdl_pri,
18251       { "Traffic handling priority", "gsm_a.qos.traff_hdl_pri",
18252         FT_UINT8, BASE_DEC, VALS(gsm_a_qos_traff_hdl_pri_vals), 0x03,
18253         "Traffic handling priority", HFILL }},
18254         { &hf_gsm_a_A5_1_algorithm_sup,
18255                 { "A5/1 algorithm supported","gsm_a.MSC2_rev",
18256                 FT_UINT8,BASE_DEC,  VALS(A5_1_algorithm_sup_vals), 0x08,          
18257                 "A5/1 algorithm supported ", HFILL }
18258         },
18259         { &hf_gsm_a_RF_power_capability,
18260                 { "RF Power Capability","gsm_a.MSC2_rev",
18261                 FT_UINT8,BASE_DEC,  VALS(RF_power_capability_vals), 0x07,          
18262                 "RF Power Capability", HFILL }
18263         },
18264         { &hf_gsm_a_ps_sup_cap,
18265                 { "PS capability (pseudo-synchronization capability)","gsm_a.ps_sup_cap",
18266                 FT_UINT8,BASE_DEC,  VALS(ps_sup_cap_vals), 0x40,          
18267                 "PS capability (pseudo-synchronization capability)", HFILL }
18268         },
18269         { &hf_gsm_a_SS_screening_indicator,
18270                 { "SS Screening Indicator","gsm_a.SS_screening_indicator",
18271                 FT_UINT8,BASE_DEC,  VALS(SS_screening_indicator_vals), 0x30,          
18272                 "SS Screening Indicator", HFILL }
18273         },
18274         { &hf_gsm_a_SM_capability,
18275                 { "SM capability (MT SMS pt to pt capability)","gsm_a.SM_cap",
18276                 FT_UINT8,BASE_DEC,  VALS(SM_capability_vals), 0x08,          
18277                 "SM capability (MT SMS pt to pt capability)", HFILL }
18278         },
18279         { &hf_gsm_a_VBS_notification_rec,
18280                 { "VBS notification reception ","gsm_a.VBS_notification_rec",
18281                 FT_UINT8,BASE_DEC,  VALS(VBS_notification_rec_vals), 0x04,          
18282                 "VBS notification reception ", HFILL }
18283         },
18284         { &hf_gsm_a_VGCS_notification_rec,
18285                 { "VGCS notification reception ","gsm_a.VGCS_notification_rec",
18286                 FT_UINT8,BASE_DEC,  VALS(VGCS_notification_rec_vals), 0x02,          
18287                 "VGCS notification reception", HFILL }
18288         },
18289         { &hf_gsm_a_FC_frequency_cap,
18290                 { "FC Frequency Capability","gsm_a.FC_frequency_cap",
18291                 FT_UINT8,BASE_DEC,  VALS(FC_frequency_cap_vals), 0x01,          
18292                 "FC Frequency Capability", HFILL }
18293         },
18294         { &hf_gsm_a_CM3,
18295                 { "CM3","gsm_a.CM3",
18296                 FT_UINT8,BASE_DEC,  VALS(CM3_vals), 0x80,          
18297                 "CM3", HFILL }
18298         },
18299         { &hf_gsm_a_LCS_VA_cap,
18300                 { "LCS VA capability (LCS value added location request notification capability) ","gsm_a.LCS_VA_cap",
18301                 FT_UINT8,BASE_DEC,  VALS(LCS_VA_cap_vals), 0x20,          
18302                 "LCS VA capability (LCS value added location request notification capability) ", HFILL }
18303         },
18304         { &hf_gsm_a_UCS2_treatment,
18305                 { "UCS2 treatment ","gsm_a.UCS2_treatment",
18306                 FT_UINT8,BASE_DEC,  VALS(UCS2_treatment_vals), 0x10,          
18307                 "UCS2 treatment ", HFILL }
18308         },
18309         { &hf_gsm_a_SoLSA,
18310                 { "SoLSA","gsm_a.SoLSA",
18311                 FT_UINT8,BASE_DEC,  VALS(SoLSA_vals), 0x08,          
18312                 "SoLSA", HFILL }
18313         },
18314         { &hf_gsm_a_CMSP,
18315                 { "CMSP: CM Service Prompt","gsm_a.CMSP",
18316                 FT_UINT8,BASE_DEC,  VALS(CMSP_vals), 0x04,          
18317                 "CMSP: CM Service Prompt", HFILL }
18318         },
18319         { &hf_gsm_a_A5_3_algorithm_sup,
18320                 { "A5/3 algorithm supported","gsm_a.A5_3_algorithm_sup",
18321                 FT_UINT8,BASE_DEC,  VALS(A5_3_algorithm_sup_vals), 0x02,          
18322                 "A5/3 algorithm supported", HFILL }
18323         },
18324         { &hf_gsm_a_A5_2_algorithm_sup,
18325                 { "A5/2 algorithm supported","gsm_a.A5_2_algorithm_sup",
18326                 FT_UINT8,BASE_DEC,  VALS(A5_2_algorithm_sup_vals), 0x01,          
18327                 "A5/2 algorithm supported", HFILL }
18328         },
18329         { &hf_gsm_a_mobile_identity_type,
18330                 { "Mobile Identity Type","gsm_a.ie.mobileid.type",
18331                 FT_UINT8, BASE_DEC, VALS(mobile_identity_type_vals), 0x07,          
18332                 "Mobile Identity Type", HFILL }
18333         },
18334         { &hf_gsm_a_odd_even_ind,
18335                 { "Odd/even indication","gsm_a.oddevenind",
18336                 FT_UINT8, BASE_DEC, oddevenind_vals, 0x08,          
18337                 "Mobile Identity", HFILL }
18338         },
18339         { &hf_gsm_a_L3_protocol_discriminator,
18340                 { "Protocol discriminator","gsm_a.L3_protocol_discriminator",
18341                 FT_UINT8,BASE_DEC,  VALS(protocol_discriminator_vals), 0x0f,          
18342                 "Protocol discriminator", HFILL }
18343         },
18344         { &hf_gsm_a_skip_ind,
18345                 { "Skip Indicator",           "gsm_a.skip.ind",
18346                 FT_UINT8, BASE_DEC, NULL, 0xf0,          
18347                 "Skip Indicator", HFILL }
18348         },
18349         { &hf_gsm_a_bcc,
18350                 { "BCC","gsm_a.bcc",
18351                 FT_UINT8,BASE_DEC,  NULL, 0x07,          
18352                 "BCC", HFILL }
18353         },
18354         { &hf_gsm_a_ncc,
18355                 { "NCC","gsm_a.ncc",
18356                 FT_UINT8,BASE_DEC,  NULL, 0x38,          
18357                 "NCC", HFILL }
18358         },
18359         { &hf_gsm_a_bcch_arfcn,
18360                 { "BCCH ARFCN(RF channel number)","gsm_a.bcch_arfcn",
18361                 FT_UINT16,BASE_DEC,  NULL, 0x0,          
18362                 "BCCH ARFCN", HFILL }
18363         },
18364         { &hf_gsm_a_rr_ho_ref_val,
18365                 { "Handover reference value","gsm_a.rr.ho_ref_val",
18366                 FT_UINT8,BASE_DEC,  NULL, 0x0,          
18367                 "Handover reference value", HFILL }
18368         },
18369         { &hf_gsm_a_b7spare,
18370                 { "Spare","gsm_a.spareb7",
18371                 FT_UINT8,BASE_DEC,  NULL, 0x40,
18372                 "Spare", HFILL }
18373         },
18374         { &hf_gsm_a_b8spare,
18375                 { "Spare","gsm_a.spareb8",
18376                 FT_UINT8,BASE_DEC,  NULL, 0x80,          
18377                 "Spare", HFILL }
18378         },
18379         { &hf_gsm_a_rr_pow_cmd_atc,
18380                 { "Spare","gsm_a.rr.pow_cmd_atc",
18381                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_pow_cmd_atc_value), 0x80,          
18382                 "Spare", HFILL }
18383         },
18384         { &hf_gsm_a_rr_pow_cmd_epc,
18385                 { "EPC_mode","gsm_a.rr.pow_cmd_epc",
18386                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_pow_cmd_epc_value), 0x40,          
18387                 "EPC_mode", HFILL }
18388         },
18389         { &hf_gsm_a_rr_pow_cmd_fpcepc,
18390                 { "FPC_EPC","gsm_a.rr.pow_cmd_fpcepc",
18391                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_pow_cmd_fpcepc_value), 0x20,          
18392                 "FPC_EPC", HFILL }
18393         },
18394         { &hf_gsm_a_rr_pow_cmd_powlev,
18395                 { "POWER LEVEL","gsm_a.rr.pow_cmd_pow",
18396                 FT_UINT8,BASE_DEC,  NULL, 0x1f,          
18397                 "POWER LEVEL", HFILL }
18398         },
18399         { &hf_gsm_a_rr_sync_ind_nci,
18400                 { "Normal cell indication(NCI)","gsm_a.rr.sync_ind_nci",
18401                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_sync_ind_nci_value), 0x08,          
18402                 "Normal cell indication(NCI)", HFILL }
18403         },
18404         { &hf_gsm_a_rr_sync_ind_rot,
18405                 { "Report Observed Time Difference(ROT)","gsm_a.rr.sync_ind_rot",
18406                 FT_BOOLEAN,8,  TFS(&sm_a_rr_sync_ind_rot_value), 0x04,          
18407                 "Report Observed Time Difference(ROT)", HFILL }
18408         },
18409         { &hf_gsm_a_rr_sync_ind_si,
18410                 { "Synchronization indication(SI)","gsm_a.rr_sync_ind_si",
18411                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_sync_ind_si_vals), 0x03,          
18412                 "Synchronization indication(SI)", HFILL }
18413         },
18414         { &hf_gsm_a_rr_format_id,
18415                 { "Format Identifier","gsm_a.rr_format_id",
18416                 FT_UINT8,BASE_HEX,  VALS(gsm_a_rr_freq_list_format_id_vals), 0xce,          
18417                 "Format Identifier", HFILL }
18418         },
18419         { &hf_gsm_a_rr_channel_mode,
18420                 { "Channel Mode","gsm_a.rr.channel_mode",
18421                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_channel_mode_vals), 0x0,          
18422                 "Channel Mode", HFILL }
18423         },
18424         { &hf_gsm_a_rr_channel_mode2,
18425                 { "Channel Mode 2","gsm_a.rr.channel_mode2",
18426                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_channel_mode2_vals), 0x0,          
18427                 "Channel Mode 2", HFILL }
18428         },
18429         { &hf_gsm_a_rr_sc,
18430                 { "SC","gsm_a.rr.SC",
18431                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_sc_vals), 0x1,          
18432                 "SC", HFILL }
18433         },
18434         { &hf_gsm_a_algorithm_id,
18435                 { "Algorithm identifier","gsm_a.algorithm_identifier",
18436                 FT_UINT8,BASE_DEC,  VALS(gsm_a_algorithm_identifier_vals), 0xe,          
18437                 "Algorithm_identifier", HFILL }
18438         },
18439
18440         { &hf_gsm_a_rr_multirate_speech_ver,
18441                 { "Multirate speech version","gsm_a.rr.multirate_speech_ver",
18442                 FT_UINT8,BASE_DEC,  VALS(multirate_speech_ver_vals), 0xe0,          
18443                 "Multirate speech version", HFILL }
18444         },
18445         { &hf_gsm_a_rr_NCSB,
18446                 { "NSCB: Noise Suppression Control Bit","gsm_a.rr.NCSB",
18447                 FT_UINT8,BASE_DEC,  VALS(NSCB_vals), 0x10,          
18448                 "NSCB: Noise Suppression Control Bit", HFILL }
18449         },
18450         { &hf_gsm_a_rr_ICMI,
18451                 { "ICMI: Initial Codec Mode Indicator","gsm_a.rr.ICMI",
18452                 FT_UINT8,BASE_DEC,  VALS(ICMI_vals), 0x8,          
18453                 "ICMI: Initial Codec Mode Indicator", HFILL }
18454         },
18455         { &hf_gsm_a_rr_start_mode,
18456                 { "Start Mode","gsm_a.rr.start_mode",
18457                 FT_UINT8,BASE_DEC,  NULL, 0x3,          
18458                 "Start Mode", HFILL }
18459         },
18460         { &hf_gsm_a_rr_timing_adv,
18461                 { "Timing advance value","gsm_a.rr.timing_adv",
18462                 FT_UINT8,BASE_DEC,  NULL, 0x0,          
18463                 "Timing advance value", HFILL }
18464         },
18465         { &hf_gsm_a_rr_time_diff,
18466                 { "Time difference value","gsm_a.rr.time_diff",
18467                 FT_UINT8,BASE_DEC,  NULL, 0x0,          
18468                 "Time difference value", HFILL }
18469         },
18470         { &hf_gsm_a_rr_tlli,
18471                 { "TLLI","gsm_a.rr.tlli",
18472                 FT_UINT32,BASE_HEX,  NULL, 0x0,          
18473                 "TLLI", HFILL }
18474         },
18475         { &hf_gsm_a_rr_target_mode,
18476                 { "Target mode","gsm_a.rr.target_mode",
18477                 FT_UINT8,BASE_DEC,  NULL, 0xc0,          
18478                 "Target mode", HFILL }
18479         },
18480         { &hf_gsm_a_rr_group_cipher_key_number,
18481                 { "Group cipher key number","gsm_a.rr.Group_cipher_key_number",
18482                 FT_UINT8,BASE_DEC,  NULL, 0x3c,          
18483                 "Group cipher key number", HFILL }
18484         },
18485         { &hf_gsm_a_rr_last_segment,
18486                 { "Last Segment","gsm_a.rr.last_segment",
18487                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_last_segment_value), 0x01,          
18488                 "Last Segment", HFILL }
18489         },
18490         { &hf_gsm_a_gmm_split_on_ccch,
18491                 { "SPLIT on CCCH","gsm_a.gmm.split_on_ccch",
18492                 FT_BOOLEAN,8,  TFS(&gsm_a_gmm_split_on_ccch_value), 0x08,          
18493                 "SPLIT on CCCH", HFILL }
18494         },
18495         { &hf_gsm_a_gmm_non_drx_timer,
18496                 { "Non-DRX timer","gsm_a.gmm.non_drx_timer",
18497                 FT_UINT8,BASE_DEC,  VALS(gsm_a_gmm_non_drx_timer_strings), 0x07,          
18498                 "Non-DRX timer", HFILL }
18499         },
18500         { &hf_gsm_a_gmm_cn_spec_drs_cycle_len_coef,
18501                 { "CN Specific DRX cycle length coefficient","gsm_a.gmm.cn_spec_drs_cycle_len_coef",
18502                 FT_UINT8,BASE_DEC,  VALS(gsm_a_gmm_cn_spec_drs_cycle_len_coef_strings), 0xf0,          
18503                 "CN Specific DRX cycle length coefficient", HFILL }
18504         },
18505         { &hf_gsm_a_rr_RR_cause,
18506                 { "RR cause value","gsm_a.rr.RRcause",
18507                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_RR_cause_vals), 0x0,          
18508                 "RR cause value", HFILL }
18509                 },
18510         { &hf_gsm_a_be_cell_id_disc,
18511                 { "Cell identification discriminator","gsm_a.be.cell_id_disc",
18512                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_cell_id_disc_vals), 0x0f,          
18513                 "Cell identificationdiscriminator", HFILL }
18514         },
18515         { &hf_gsm_a_be_rnc_id,
18516                 { "RNC-ID","gsm_a.be.rnc_id",
18517                 FT_UINT16,BASE_DEC,  NULL, 0x0,          
18518                 "RNC-ID", HFILL }
18519         },
18520         { &hf_gsm_a_rr_cm_cng_msg_req, 
18521                 { "CLASSMARK CHANGE","gsm_a.rr_cm_cng_msg_req",
18522                 FT_BOOLEAN,8,  TFS(&gsm_a_msg_req_value), 0x80,          
18523                 "CLASSMARK CHANGE ", HFILL }
18524         },
18525         { &hf_gsm_a_rr_utran_cm_cng_msg_req,
18526                 { "UTRAN CLASSMARK CHANGE","gsm_a.rr_utran_cm_cng_msg_req",
18527                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_utran_cm_cng_msg_req_vals), 0x70,          
18528                 "UTRAN CLASSMARK CHANGE", HFILL }
18529         },
18530         { &hf_gsm_a_rr_cdma200_cm_cng_msg_req,
18531                 { "CDMA2000 CLASSMARK CHANGE ","gsm_a.rr_cdma200_cm_cng_msg_req",
18532                 FT_BOOLEAN,8,  TFS(&gsm_a_msg_req_value), 0x08,          
18533                 "CDMA2000 CLASSMARK CHANGE ", HFILL }
18534         },
18535         { &hf_gsm_a_rr_geran_iu_cm_cng_msg_req,
18536                 { "GERAN IU MODE CLASSMARK CHANGE","gsm_a.rr_geran_iu_cm_cng_msg_req",
18537                 FT_BOOLEAN,8,  TFS(&gsm_a_msg_req_value), 0x04,          
18538                 "GERAN IU MODE CLASSMARK CHANGE", HFILL }
18539         },
18540         { &hf_gsm_a_rr_chnl_needed_ch1,
18541                 { "Channel 1","gsm_a.rr_chnl_needed_ch1",
18542                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_channel_needed_vals), 0x03,          
18543                 "Channel 1", HFILL }
18544         },
18545         { &hf_gsm_a_rr_chnl_needed_ch2,
18546                 { "Channel 2","gsm_a.rr_chnl_needed_ch1",
18547                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_channel_needed_vals), 0x0c,          
18548                 "Channel 2", HFILL }
18549         },
18550         { &hf_gsm_a_rr_suspension_cause,
18551                 { "Suspension cause value","gsm_a.rr.suspension_cause",
18552                 FT_UINT8,BASE_DEC,  VALS(gsm_a_rr_suspension_cause_vals), 0x0,          
18553                 "Suspension cause value", HFILL }
18554         },
18555         { &hf_gsm_a_rr_set_of_amr_codec_modes_v1_b8,
18556       { "12,2 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v1b8",
18557                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x80,          
18558                 "12,2 kbit/s codec rate", HFILL }
18559         },
18560         { &hf_gsm_a_rr_set_of_amr_codec_modes_v1_b7,
18561       { "10,2 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v1b7",
18562                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x40,          
18563                 "10,2 kbit/s codec rate", HFILL }
18564         },
18565         { &hf_gsm_a_rr_set_of_amr_codec_modes_v1_b6,
18566       { "7,95 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v1b6",
18567                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x20,          
18568                 "7,95 kbit/s codec rate", HFILL }
18569         },
18570         { &hf_gsm_a_rr_set_of_amr_codec_modes_v1_b5,
18571       { "7,40 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v1b5",
18572                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x10,          
18573                 "7,40 kbit/s codec rate", HFILL }
18574         },
18575         { &hf_gsm_a_rr_set_of_amr_codec_modes_v1_b4,
18576       { "6,70 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v1b4",
18577                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x08,          
18578                 "6,70 kbit/s codec rate", HFILL }
18579         },
18580         { &hf_gsm_a_rr_set_of_amr_codec_modes_v1_b3,
18581       { "5,90 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v1b3",
18582                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x04,          
18583                 "5,90 kbit/s codec rate", HFILL }
18584         },
18585         { &hf_gsm_a_rr_set_of_amr_codec_modes_v1_b2,
18586       { "5,15 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v1b2",
18587                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x02,          
18588                 "5,15 kbit/s codec rate", HFILL }
18589         },
18590         { &hf_gsm_a_rr_set_of_amr_codec_modes_v1_b1,
18591       { "4,75 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v1b1",
18592                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x01,          
18593                 "4,75 kbit/s codec rate", HFILL }
18594         },
18595         { &hf_gsm_a_rr_set_of_amr_codec_modes_v2_b5,
18596       { "23,85 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v2b5",
18597                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x10,          
18598                 "23,85 kbit/s codec rate", HFILL }
18599         },
18600         { &hf_gsm_a_rr_set_of_amr_codec_modes_v2_b4,
18601       { "15,85 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v2b4",
18602                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x08,          
18603                 "15,85 kbit/s codec rate", HFILL }
18604         },
18605         { &hf_gsm_a_rr_set_of_amr_codec_modes_v2_b3,
18606       { "12,65 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v2b3",
18607                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x04,          
18608                 "12,65 kbit/s codec rate", HFILL }
18609         },
18610         { &hf_gsm_a_rr_set_of_amr_codec_modes_v2_b2,
18611       { "8,85 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v2b2",
18612                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x02,          
18613                 "8,85 kbit/s codec rate", HFILL }
18614         },
18615         { &hf_gsm_a_rr_set_of_amr_codec_modes_v2_b1,
18616       { "6,60 kbit/s codec rate", "gsm_a.rr.set_of_amr_codec_modes_v2b1",
18617                 FT_BOOLEAN,8,  TFS(&gsm_a_rr_set_of_amr_codec_modes), 0x01,          
18618                 "6,60 kbit/s codec rate", HFILL }
18619         },
18620        { &hf_gsm_a_extension,
18621       { "Extension", "gsm_a.extension",
18622         FT_BOOLEAN, 8, TFS(&gsm_a_extension_value), 0x80,
18623         "Extension", HFILL }},
18624        { &hf_gsm_a_type_of_number,
18625       { "Type of number", "gsm_a.type_of_number",
18626         FT_UINT8, BASE_HEX, VALS(gsm_a_type_of_number_values), 0x70,
18627         "Type of number", HFILL }},
18628        { &hf_gsm_a_numbering_plan_id,
18629       { "Numbering plan identification", "gsm_a.numbering_plan_id",
18630         FT_UINT8, BASE_HEX, VALS(gsm_a_numbering_plan_id_values), 0x0f,
18631         "Numbering plan identification", HFILL }},
18632         { &hf_gsm_a_tft_op_code,
18633                 { "TFT operation code", "gsm_a.tft.op_code", 
18634                 FT_UINT8, BASE_DEC, VALS(gsm_a_tft_op_code_vals), 0xe0,
18635                 "TFT operation code", HFILL }
18636         },
18637         { &hf_gsm_a_tft_e_bit,
18638                 { "E bit","gsm_a.tft.e_bit",
18639                 FT_BOOLEAN,8,  TFS(&gsm_a_tft_e_bit), 0x10,          
18640                 "E bit", HFILL }
18641         },
18642         { &hf_gsm_a_tft_pkt_flt,
18643                 { "Number of packet filters", "gsm_a.tft.pkt_flt", 
18644                 FT_UINT8, BASE_DEC, NULL, 0x0f,
18645                 "Number of packet filters", HFILL }
18646         },
18647
18648        { &hf_gsm_a_tft_ip4_address,
18649       { "IPv4 adress", "gsm_a.tft.ip4_address", FT_IPv4, BASE_NONE, NULL, 0x0,
18650                 "IPv4 address", HFILL }},
18651         { &hf_gsm_a_tft_ip4_mask,
18652       { "IPv4 address mask", "gsm_a.tft.ip4_mask", FT_IPv4, BASE_NONE, NULL, 0x0,
18653                 "IPv4 address mask", HFILL }},
18654         { &hf_gsm_a_tft_ip6_address,
18655       { "IPv6 adress", "gsm_a.tft.ip6_address", FT_IPv6, BASE_NONE, NULL, 0x0,
18656                 "IPv6 address", HFILL }},
18657         { &hf_gsm_a_tft_ip6_mask,
18658         { "IPv6 adress mask", "gsm_a.tft.ip6_mask", FT_IPv6, BASE_NONE, NULL, 0x0,
18659                 "IPv6 address mask", HFILL }},
18660         { &hf_gsm_a_tft_protocol_header,
18661         { "Protocol/header", "gsm_a.tft.protocol_header", FT_UINT8, BASE_HEX, NULL, 0x0,
18662                 "Protocol/header", HFILL }},
18663         { &hf_gsm_a_tft_port,
18664         { "Port", "gsm_a.tft.port", FT_UINT16, BASE_DEC, NULL, 0x0,
18665                 "Port", HFILL }},
18666         { &hf_gsm_a_tft_port_low,
18667         { "Low limit port", "gsm_a.tft.port_low", FT_UINT16, BASE_DEC, NULL, 0x0,
18668                 "Low limit port", HFILL }},
18669         { &hf_gsm_a_tft_port_high,
18670         { "High limit port", "gsm_a.tft.port_high", FT_UINT16, BASE_DEC, NULL, 0x0,
18671                 "High limit port", HFILL }},
18672         { &hf_gsm_a_tft_security,
18673         { "IPSec security parameter index", "gsm_a.tft.security", FT_UINT32, BASE_HEX, NULL, 0x0,
18674                 "IPSec security parameter index", HFILL }},
18675         { &hf_gsm_a_tft_traffic_mask,
18676         { "Mask field", "gsm_a.tft.traffic_mask", FT_UINT8, BASE_HEX, NULL, 0x0,
18677                 "Mask field", HFILL }},
18678         { &hf_gsm_a_tft_flow,
18679         { "IPv6 flow label", "gsm_a.tft.flow", FT_UINT24, BASE_HEX, NULL, 0x0FFFFF,
18680                 "IPv6 flow label", HFILL }},
18681
18682         { &hf_gsm_a_ptmsi_sig,
18683         { "P-TMSI Signature", "gsm_a.ptmsi_sig", FT_UINT24, BASE_HEX, NULL, 0x0,
18684                 "P-TMSI Signature", HFILL }},
18685         { &hf_gsm_a_ptmsi_sig2,
18686         { "P-TMSI Signature 2", "gsm_a.ptmsi_sig2", FT_UINT24, BASE_HEX, NULL, 0x0,
18687                 "P-TMSI Signature 2", HFILL }},
18688
18689         { &hf_gsm_a_apdu_protocol_id,
18690                 { "Protocol ID", "gsm_a.apdu_protocol_id", 
18691                 FT_UINT8, BASE_DEC, VALS(gsm_a_apdu_protocol_id_strings), 0x0,
18692                 "APDU embedded protocol id", HFILL }
18693         },
18694         { &hf_gsm_a_lsa_id,
18695                 { "LSA Identifier", "gsm_a.lsa_id", 
18696                 FT_UINT24, BASE_HEX, NULL, 0x0,
18697                 "LSA Identifier", HFILL }
18698         },
18699     };
18700
18701     /* Setup protocol subtree array */
18702 #define NUM_INDIVIDUAL_ELEMS    38
18703     static gint *ett[NUM_INDIVIDUAL_ELEMS + NUM_GSM_BSSMAP_MSG +
18704                         NUM_GSM_DTAP_MSG_MM + NUM_GSM_DTAP_MSG_RR + NUM_GSM_DTAP_MSG_CC +
18705                         NUM_GSM_DTAP_MSG_GMM + NUM_GSM_DTAP_MSG_SMS +
18706                         NUM_GSM_DTAP_MSG_SM + NUM_GSM_DTAP_MSG_SS + NUM_GSM_RP_MSG +
18707                         NUM_GSM_BSSMAP_ELEM + NUM_GSM_DTAP_ELEM];
18708
18709     ett[0] = &ett_bssmap_msg;
18710     ett[1] = &ett_dtap_msg;
18711     ett[2] = &ett_rp_msg;
18712     ett[3] = &ett_elems;
18713     ett[4] = &ett_elem;
18714     ett[5] = &ett_dtap_oct_1;
18715     ett[6] = &ett_cm_srvc_type;
18716     ett[7] = &ett_gsm_enc_info;
18717     ett[8] = &ett_cell_list;
18718     ett[9] = &ett_dlci;
18719     ett[10] = &ett_bc_oct_3a;
18720     ett[11] = &ett_bc_oct_4;
18721     ett[12] = &ett_bc_oct_5;
18722     ett[13] = &ett_bc_oct_5a;
18723     ett[14] = &ett_bc_oct_5b;
18724     ett[15] = &ett_bc_oct_6;
18725     ett[16] = &ett_bc_oct_6a;
18726     ett[17] = &ett_bc_oct_6b;
18727     ett[18] = &ett_bc_oct_6c;
18728     ett[19] = &ett_bc_oct_6d;
18729     ett[20] = &ett_bc_oct_6e;
18730     ett[21] = &ett_bc_oct_6f;
18731     ett[22] = &ett_bc_oct_6g;
18732     ett[23] = &ett_bc_oct_7;
18733
18734     ett[24] = &ett_tc_component;
18735     ett[25] = &ett_tc_invoke_id;
18736     ett[26] = &ett_tc_linked_id;
18737     ett[27] = &ett_tc_opr_code;
18738     ett[28] = &ett_tc_err_code;
18739     ett[29] = &ett_tc_prob_code;
18740     ett[30] = &ett_tc_sequence;
18741     
18742     ett[31] = &ett_gmm_drx;
18743     ett[32] = &ett_gmm_detach_type;
18744     ett[33] = &ett_gmm_attach_type;
18745     ett[34] = &ett_gmm_context_stat;
18746     ett[35] = &ett_gmm_update_type;
18747     ett[36] = &ett_gmm_radio_cap;
18748
18749     ett[37] = &ett_sm_tft;
18750
18751
18752     last_offset = NUM_INDIVIDUAL_ELEMS;
18753
18754     for (i=0; i < NUM_GSM_BSSMAP_MSG; i++, last_offset++)
18755     {
18756         ett_gsm_bssmap_msg[i] = -1;
18757         ett[last_offset] = &ett_gsm_bssmap_msg[i];
18758     }
18759
18760     for (i=0; i < NUM_GSM_DTAP_MSG_MM; i++, last_offset++)
18761     {
18762         ett_gsm_dtap_msg_mm[i] = -1;
18763         ett[last_offset] = &ett_gsm_dtap_msg_mm[i];
18764     }
18765
18766     for (i=0; i < NUM_GSM_DTAP_MSG_RR; i++, last_offset++)
18767     {
18768         ett_gsm_dtap_msg_rr[i] = -1;
18769         ett[last_offset] = &ett_gsm_dtap_msg_rr[i];
18770     }
18771
18772     for (i=0; i < NUM_GSM_DTAP_MSG_CC; i++, last_offset++)
18773     {
18774         ett_gsm_dtap_msg_cc[i] = -1;
18775         ett[last_offset] = &ett_gsm_dtap_msg_cc[i];
18776     }
18777
18778     for (i=0; i < NUM_GSM_DTAP_MSG_GMM; i++, last_offset++)
18779     {
18780         ett_gsm_dtap_msg_gmm[i] = -1;
18781         ett[last_offset] = &ett_gsm_dtap_msg_gmm[i];
18782     }
18783
18784     for (i=0; i < NUM_GSM_DTAP_MSG_SMS; i++, last_offset++)
18785     {
18786         ett_gsm_dtap_msg_sms[i] = -1;
18787         ett[last_offset] = &ett_gsm_dtap_msg_sms[i];
18788     }
18789
18790     for (i=0; i < NUM_GSM_DTAP_MSG_SM; i++, last_offset++)
18791     {
18792         ett_gsm_dtap_msg_sm[i] = -1;
18793         ett[last_offset] = &ett_gsm_dtap_msg_sm[i];
18794     }
18795
18796     for (i=0; i < NUM_GSM_DTAP_MSG_SS; i++, last_offset++)
18797     {
18798         ett_gsm_dtap_msg_ss[i] = -1;
18799         ett[last_offset] = &ett_gsm_dtap_msg_ss[i];
18800     }
18801
18802     for (i=0; i < NUM_GSM_RP_MSG; i++, last_offset++)
18803     {
18804         ett_gsm_rp_msg[i] = -1;
18805         ett[last_offset] = &ett_gsm_rp_msg[i];
18806     }
18807
18808     for (i=0; i < NUM_GSM_BSSMAP_ELEM; i++, last_offset++)
18809     {
18810         ett_gsm_bssmap_elem[i] = -1;
18811         ett[last_offset] = &ett_gsm_bssmap_elem[i];
18812     }
18813
18814     for (i=0; i < NUM_GSM_DTAP_ELEM; i++, last_offset++)
18815     {
18816         ett_gsm_dtap_elem[i] = -1;
18817         ett[last_offset] = &ett_gsm_dtap_elem[i];
18818     }
18819
18820
18821     /* Register the protocol name and description */
18822
18823     proto_a_bssmap =
18824         proto_register_protocol("GSM A-I/F BSSMAP", "GSM BSSMAP", "gsm_a_bssmap");
18825
18826     proto_register_field_array(proto_a_bssmap, hf, array_length(hf));
18827
18828     proto_a_dtap =
18829         proto_register_protocol("GSM A-I/F DTAP", "GSM DTAP", "gsm_a_dtap");
18830
18831     proto_a_rp =
18832         proto_register_protocol("GSM A-I/F RP", "GSM RP", "gsm_a_rp");
18833
18834     sms_dissector_table =
18835         register_dissector_table("gsm_a.sms_tpdu", "GSM SMS TPDU",
18836         FT_UINT8, BASE_DEC);
18837
18838     proto_register_subtree_array(ett, array_length(ett));
18839
18840     /* subdissector code */
18841     gprs_sm_pco_subdissector_table = register_dissector_table("sm_pco.protocol",
18842         "GPRS SM PCO PPP protocol", FT_UINT16, BASE_HEX);
18843
18844     gsm_a_tap = register_tap("gsm_a");
18845         
18846         register_dissector("gsm_a_dtap", dissect_dtap, proto_a_dtap);
18847         register_dissector("gsm_a_rp", dissect_rp, proto_a_rp);
18848         register_dissector("gsm_a_bssmap", dissect_bssmap, proto_a_bssmap);
18849 }
18850
18851
18852 void
18853 proto_reg_handoff_gsm_a(void)
18854 {
18855
18856     bssmap_handle = create_dissector_handle(dissect_bssmap, proto_a_bssmap);
18857     dtap_handle = find_dissector("gsm_a_dtap");
18858     rp_handle = create_dissector_handle(dissect_rp, proto_a_rp);
18859
18860     dissector_add("bssap.pdu_type",  BSSAP_PDU_TYPE_BSSMAP, bssmap_handle);
18861     dissector_add("bssap.pdu_type",  BSSAP_PDU_TYPE_DTAP, dtap_handle);
18862     dissector_add("ranap.nas_pdu",  BSSAP_PDU_TYPE_DTAP, dtap_handle);
18863     dissector_add("llcgprs.sapi", 1 , dtap_handle); /* GPRS Mobility Management */
18864         dissector_add("llcgprs.sapi", 7 , dtap_handle); /* SMS */
18865     data_handle = find_dissector("data");
18866         gsm_map_handle = find_dissector("gsm_map");
18867 }
18868