Make it possible to dissect proprietarry Opcodes.
[obnox/wireshark/wip.git] / asn1 / gsm_map / packet-gsm_map-template.c
1 /* XXX see bug 1852:
2  *
3  * packet-gsm_map.c: There are 1174 display filter fields registered.  Most are
4  * prefixed appropriately as "gsm_map", but many others are prefixed as
5  * "gsm_old", or even "gad", "gsm_ss", or with no prefix at all.  I don't know
6  * if the ones with "gsm_old" are simply obsolete display filter fields or if
7  * they should be prefixed as "gsm_map.old." or what.  Similar uncertainties
8  * for the others. Someone more knowledgeable than I am with respect to this
9  * dissector should provide a patch for it.
10  */
11
12 /* packet-gsm_map-template.c
13  * Routines for GSM MobileApplication packet dissection
14  * including GSM SS.
15  * Copyright 2004 - 2010 , Anders Broman <anders.broman [AT] ericsson.com>
16  * Based on the dissector by:
17  * Felix Fei <felix.fei [AT] utstar.com>
18  * and Michael Lum <mlum [AT] telostech.com>
19  *
20  * $Id$
21  *
22  * Wireshark - Network traffic analyzer
23  * By Gerald Combs <gerald@wireshark.org>
24  * Copyright 1998 Gerald Combs
25  *
26  * This program is free software; you can redistribute it and/or
27  * modify it under the terms of the GNU General Public License
28  * as published by the Free Software Foundation; either version 2
29  * of the License, or (at your option) any later version.
30  *
31  * This program is distributed in the hope that it will be useful,
32  * but WITHOUT ANY WARRANTY; without even the implied warranty of
33  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
34  * GNU General Public License for more details.
35  *
36  * You should have received a copy of the GNU General Public License
37  * along with this program; if not, write to the Free Software
38  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
39  * References GSM MAP:
40  * ETSI TS 129 002
41  * Updated to ETSI TS 129 002 V7.5.0 (3GPP TS 29.002 V7.5.0 (2006-09) Release 7)
42  * Updated to ETSI TS 129 002 V8.4.0 (3GPP TS 29.002 V8.1.0 (2007-06) Release 8)
43  * References GSM SS
44  * References: 3GPP TS 24.080
45  */
46
47 #ifdef HAVE_CONFIG_H
48 # include "config.h"
49 #endif
50
51 #include <glib.h>
52 #include <epan/packet.h>
53 #include <epan/prefs.h>
54 #include <epan/tap.h>
55 #include <epan/emem.h>
56 #include <epan/oids.h>
57 #include <epan/expert.h>
58
59 #include <string.h>
60
61 #include <epan/asn1.h>
62 #include "packet-ber.h"
63 #include "packet-per.h"
64 #include "packet-q931.h"
65 #include "packet-gsm_map.h"
66 #include "packet-gsm_a_common.h"
67 #include "packet-tcap.h"
68 #include "packet-e164.h"
69 #include "packet-e212.h"
70 #include "packet-smpp.h"
71 #include "packet-gsm_sms.h"
72 #include "packet-ranap.h"
73
74 #define PNAME  "GSM Mobile Application"
75 #define PSNAME "GSM_MAP"
76 #define PFNAME "gsm_map"
77
78 /* Initialize the protocol and registered fields */
79 static int proto_gsm_map = -1;
80 static int proto_gsm_map_dialogue = -1;
81
82 static int hf_gsm_map_old_Component_PDU = -1;
83 static int hf_gsm_map_getPassword = -1;
84 static int hf_gsm_map_currentPassword = -1;
85 static int hf_gsm_map_extension = -1;
86 static int hf_gsm_map_nature_of_number = -1;
87 static int hf_gsm_map_number_plan = -1;
88 static int hf_gsm_map_isdn_address_digits = -1;
89 static int hf_gsm_map_address_digits = -1;
90 static int hf_gsm_map_servicecentreaddress_digits = -1;
91 static int hf_gsm_map_imsi_digits = -1;
92 static int hf_gsm_map_TBCD_digits = -1;
93 static int hf_gsm_map_Ss_Status_unused = -1;
94 static int hf_gsm_map_Ss_Status_q_bit = -1;
95 static int hf_gsm_map_Ss_Status_p_bit = -1;
96 static int hf_gsm_map_Ss_Status_r_bit = -1;
97 static int hf_gsm_map_Ss_Status_a_bit = -1;
98 static int hf_gsm_map_notification_to_forwarding_party = -1;
99 static int hf_gsm_map_redirecting_presentation = -1;
100 static int hf_gsm_map_notification_to_calling_party = -1;
101 static int hf_gsm_map_forwarding_reason = -1;
102 static int hf_gsm_map_pdp_type_org = -1;
103 static int hf_gsm_map_etsi_pdp_type_number = -1;
104 static int hf_gsm_map_ietf_pdp_type_number = -1;
105 static int hf_gsm_map_ext_qos_subscribed_pri = -1;
106
107 static int hf_gsm_map_qos_traffic_cls = -1;
108 static int hf_gsm_map_qos_del_order = -1;
109 static int hf_gsm_map_qos_del_of_err_sdu = -1;
110 static int hf_gsm_map_qos_ber = -1;
111 static int hf_gsm_map_qos_sdu_err_rat = -1;
112 static int hf_gsm_map_qos_traff_hdl_pri = -1;
113 static int hf_gsm_map_qos_max_sdu = -1;
114 static int hf_gsm_map_max_brate_ulink = -1;
115 static int hf_gsm_map_max_brate_dlink = -1;
116 static int hf_gsm_map_qos_transfer_delay = -1;
117 static int hf_gsm_map_guaranteed_max_brate_ulink = -1;
118 static int hf_gsm_map_guaranteed_max_brate_dlink = -1;
119 static int hf_gsm_map_GSNAddress_IPv4 = -1;
120 static int hf_gsm_map_GSNAddress_IPv6 = -1;
121 static int hf_gsm_map_ranap_service_Handover = -1;
122 static int hf_gsm_map_IntegrityProtectionInformation = -1;
123 static int hf_gsm_map_EncryptionInformation = -1;
124 static int hf_gsm_map_PlmnContainer_PDU = -1;
125 static int hf_gsm_map_ss_SS_UserData = -1;
126 static int hf_gsm_map_cbs_coding_grp = -1;
127 static int hf_gsm_map_cbs_coding_grp0_lang = -1;
128 static int hf_gsm_map_cbs_coding_grp1_lang = -1;
129 static int hf_gsm_map_cbs_coding_grp2_lang = -1;
130 static int hf_gsm_map_cbs_coding_grp3_lang = -1;
131 static int hf_gsm_map_cbs_coding_grp4_7_comp = -1;
132 static int hf_gsm_map_cbs_coding_grp4_7_class_ind = -1;
133 static int hf_gsm_map_cbs_coding_grp4_7_char_set = -1;
134 static int hf_gsm_map_cbs_coding_grp4_7_class = -1;
135 static int hf_gsm_map_cbs_coding_grp15_mess_code = -1;
136 static int hf_gsm_map_cbs_coding_grp15_class = -1;
137 static int hf_gsm_map_tmsi = -1;
138 static int hf_gsm_map_ie_tag = -1;
139 static int hf_gsm_map_len = -1;
140 static int hf_gsm_map_disc_par = -1;
141 static int hf_gsm_map_dlci = -1;
142 static int hf_gsm_apn_str = -1;
143
144 #include "packet-gsm_map-hf.c"
145
146 /* Initialize the subtree pointers */
147 static gint ett_gsm_map = -1;
148 static gint ett_gsm_map_InvokeId = -1;
149 static gint ett_gsm_map_InvokePDU = -1;
150 static gint ett_gsm_map_ReturnResultPDU = -1;
151 static gint ett_gsm_map_ReturnErrorPDU = -1;
152 static gint ett_gsm_map_ReturnResult_result = -1;
153 static gint ett_gsm_map_ReturnError_result = -1;
154 static gint ett_gsm_map_GSMMAPPDU = -1;
155 static gint ett_gsm_map_ext_qos_subscribed = -1;
156 static gint ett_gsm_map_pdptypenumber = -1;
157 static gint ett_gsm_map_RAIdentity = -1;
158 static gint ett_gsm_map_LAIFixedLength = -1;
159 static gint ett_gsm_map_isdn_address_string = -1;
160 static gint ett_gsm_map_geo_desc = -1;
161 static gint ett_gsm_map_LongSignalInfo = -1;
162 static gint ett_gsm_map_RadioResourceInformation =-1;
163 static gint ett_gsm_map_MSNetworkCapability =-1;
164 static gint ett_gsm_map_MSRadioAccessCapability = -1;
165 static gint ett_gsm_map_externalsignalinfo = -1;
166 static gint ett_gsm_map_cbs_data_coding = -1;
167 static gint ett_gsm_map_GlobalCellId = -1;
168 static gint ett_gsm_map_GeographicalInformation = -1;
169 static gint ett_gsm_map_apn_str = -1;
170
171 #include "packet-gsm_map-ett.c"
172
173 static dissector_table_t        sms_dissector_table;    /* SMS TPDU */
174 static dissector_handle_t       data_handle;
175 static dissector_handle_t       ranap_handle;
176 static dissector_handle_t       dtap_handle;
177 static dissector_handle_t       map_handle;
178 static dissector_table_t        map_prop_arg_opcode_table; /* prorietary operation codes */
179 static dissector_table_t        map_prop_res_opcode_table; /* prorietary operation codes */
180 static dissector_table_t        map_prop_err_opcode_table; /* prorietary operation codes */
181 /* Preferenc settings default */
182 #define MAX_SSN 254
183 static range_t *global_ssn_range;
184
185 /* Global variables */
186 static guint32 opcode=0;
187 static guint32 errorCode;
188 static proto_tree *top_tree;
189 static int application_context_version;
190 static guint ProtocolId;
191 static guint AccessNetworkProtocolId;
192 static const char *obj_id = NULL;
193 static int gsm_map_tap = -1;
194
195 #define SMS_ENCODING_NOT_SET    0
196 #define SMS_ENCODING_7BIT               1
197 #define SMS_ENCODING_8BIT               2
198 #define SMS_ENCODING_UCS2               3
199 #define SMS_ENCODING_7BIT_LANG  4
200 #define SMS_ENCODING_UCS2_LANG  5
201
202 static guint8 sms_encoding;
203
204 /* Forward declarations */
205 static int dissect_invokeData(proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *actx);
206 static int dissect_returnResultData(proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *actx);
207 static int dissect_returnErrorData(proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *actx);
208 const gchar* gsm_map_opr_code(guint32 val);
209
210 /* Value strings */
211
212 const value_string gsm_map_PDP_Type_Organisation_vals[] = {
213   {  0, "ETSI" },
214   {  1, "IETF" },
215   { 0, NULL }
216 };
217
218 const value_string gsm_map_ietf_defined_pdp_vals[] = {
219   {  0x21, "IPv4 Address" },
220   {  0x57, "IPv6 Address" },
221   { 0, NULL }
222 };
223
224 const value_string gsm_map_etsi_defined_pdp_vals[] = {
225   {  1, "PPP" },
226   { 0, NULL }
227 };
228
229 static const value_string gsm_map_tag_vals[] = {
230   {  0x4, "Bearer Capability" },
231   { 0, NULL }
232 };
233
234 static const value_string gsm_map_disc_par_vals[] = {
235   {  0, "Not Transparent" },
236   {  1, "Transparent" },
237   { 0, NULL }
238 };
239
240 const char *
241 unpack_digits(tvbuff_t *tvb, int offset) {
242
243         int length;
244         guint8 octet;
245         int i=0;
246         char *digit_str;
247
248         length = tvb_length(tvb);
249         if (length < offset)
250                 return "";
251         digit_str = (char *)ep_alloc((length - offset)*2+1);
252
253         while ( offset < length ){
254
255                 octet = tvb_get_guint8(tvb,offset);
256                 digit_str[i] = ((octet & 0x0f) + '0');
257                 i++;
258
259                 /*
260                  * unpack second value in byte
261                  */
262                 octet = octet >> 4;
263
264                 if (octet == 0x0f)      /* odd number bytes - hit filler */
265                         break;
266
267                 digit_str[i] = ((octet & 0x0f) + '0');
268                 i++;
269                 offset++;
270
271         }
272         digit_str[i]= '\0';
273         return digit_str;
274 }
275
276 /* returns value in kb/s */
277 static guint
278 gsm_map_calc_bitrate(guint8 value){
279
280         guint8 granularity;
281         guint returnvalue;
282
283         if (value == 0xff)
284                 return 0;
285
286         granularity = value >> 6;
287         returnvalue = value & 0x7f;
288         switch (granularity){
289         case 0:
290                 break;
291         case 1:
292                 returnvalue = ((returnvalue - 0x40) << 3)+64;
293                 break;
294         case 2:
295                 returnvalue = (returnvalue << 6)+576;
296                 break;
297         case 3:
298                 returnvalue = (returnvalue << 6)+576;
299                 break;
300         }
301         return returnvalue;
302
303 }
304
305 static void
306 dissect_gsm_map_ext_qos_subscribed(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree _U_, asn1_ctx_t *actx){
307         int offset = 0;
308     proto_tree *subtree;
309         guint8 octet;
310         guint16 value;
311
312         subtree = proto_item_add_subtree(actx->created_item, ett_gsm_map_ext_qos_subscribed);
313         /*  OCTET 1:
314                 Allocation/Retention Priority (This octet encodes each priority level defined in
315                 23.107 as the binary value of the priority level, declaration in 29.060)
316                 Octets 2-9 are coded according to 3GPP TS 24.008[35] Quality of Service Octets
317                 6-13.
318          */
319         /* Allocation/Retention Priority */
320         proto_tree_add_item(subtree, hf_gsm_map_ext_qos_subscribed_pri, tvb, offset, 1, FALSE);
321         offset++;
322
323         /* Quality of Service Octets 6-13.( Octet 2 - 9 Here) */
324
325         /* Traffic class, octet 6 (see 3GPP TS 23.107) Bits 8 7 6 */
326         proto_tree_add_item(subtree, hf_gsm_map_qos_traffic_cls, tvb, offset, 1, FALSE);
327         /* Delivery order, octet 6 (see 3GPP TS 23.107) Bits 5 4 */
328         proto_tree_add_item(subtree, hf_gsm_map_qos_del_order, tvb, offset, 1, FALSE);
329         /* Delivery of erroneous SDUs, octet 6 (see 3GPP TS 23.107) Bits 3 2 1 */
330         proto_tree_add_item(subtree, hf_gsm_map_qos_del_of_err_sdu, tvb, offset, 1, FALSE);
331         offset++;
332
333         /* Maximum SDU size, octet 7 (see 3GPP TS 23.107) */
334         octet = tvb_get_guint8(tvb,offset);
335         switch (octet){
336         case 0:
337                 proto_tree_add_text(subtree, tvb, offset, 1, "Subscribed Maximum SDU size/Reserved");
338                 break;
339         case 0x93:
340                 value = 1502;
341                 proto_tree_add_uint(subtree, hf_gsm_map_qos_max_sdu, tvb, offset, 1, value);
342                 break;
343         case 0x98:
344                 value = 1510;
345                 proto_tree_add_uint(subtree, hf_gsm_map_qos_max_sdu, tvb, offset, 1, value);
346                 break;
347         case 0x99:
348                 value = 1532;
349                 proto_tree_add_uint(subtree, hf_gsm_map_qos_max_sdu, tvb, offset, 1, value);
350                 break;
351         default:
352                 if (octet<0x97){
353                         value = octet * 10;
354                         proto_tree_add_uint(subtree, hf_gsm_map_qos_max_sdu, tvb, offset, 1, value);
355                 }else{
356                         proto_tree_add_text(subtree, tvb, offset, 1, "Maximum SDU size value 0x%x not defined in TS 24.008",octet);
357                 }
358         }
359         offset++;
360
361         /* Maximum bit rate for uplink, octet 8 */
362         octet = tvb_get_guint8(tvb,offset);
363         if (octet == 0 ){
364                 proto_tree_add_text(subtree, tvb, offset, 1, "Subscribed Maximum bit rate for uplink/Reserved"  );
365         }else{
366                 proto_tree_add_uint(subtree, hf_gsm_map_max_brate_ulink, tvb, offset, 1, gsm_map_calc_bitrate(octet));
367         }
368         offset++;
369         /* Maximum bit rate for downlink, octet 9 (see 3GPP TS 23.107) */
370         octet = tvb_get_guint8(tvb,offset);
371         if (octet == 0 ){
372                 proto_tree_add_text(subtree, tvb, offset, 1, "Subscribed Maximum bit rate for downlink/Reserved"  );
373         }else{
374                 proto_tree_add_uint(subtree, hf_gsm_map_max_brate_dlink, tvb, offset, 1, gsm_map_calc_bitrate(octet));
375         }
376         offset++;
377         /* Residual Bit Error Rate (BER), octet 10 (see 3GPP TS 23.107) Bits 8 7 6 5 */
378         proto_tree_add_item(subtree, hf_gsm_map_qos_ber, tvb, offset, 1, FALSE);
379         /* SDU error ratio, octet 10 (see 3GPP TS 23.107) */
380         proto_tree_add_item(subtree, hf_gsm_map_qos_sdu_err_rat, tvb, offset, 1, FALSE);
381         offset++;
382
383         /* Transfer delay, octet 11 (See 3GPP TS 23.107) Bits 8 7 6 5 4 3 */
384         proto_tree_add_item(subtree, hf_gsm_map_qos_transfer_delay, tvb, offset, 1, FALSE);
385         /* Traffic handling priority, octet 11 (see 3GPP TS 23.107) Bits 2 1 */
386         proto_tree_add_item(subtree, hf_gsm_map_qos_traff_hdl_pri, tvb, offset, 1, FALSE);
387         offset++;
388
389         /*      Guaranteed bit rate for uplink, octet 12 (See 3GPP TS 23.107)
390                 Coding is identical to that of Maximum bit rate for uplink.
391          */
392         octet = tvb_get_guint8(tvb,offset);
393         if (octet == 0 ){
394                 proto_tree_add_text(subtree, tvb, offset, 1, "Subscribed Guaranteed bit rate for uplink/Reserved"  );
395         }else{
396                 proto_tree_add_uint(subtree, hf_gsm_map_guaranteed_max_brate_ulink, tvb, offset, 1, gsm_map_calc_bitrate(octet));
397         }
398         offset++;
399
400         /*      Guaranteed bit rate for downlink, octet 13(See 3GPP TS 23.107)
401                 Coding is identical to that of Maximum bit rate for uplink.
402          */
403         octet = tvb_get_guint8(tvb,offset);
404         if (octet == 0 ){
405                 proto_tree_add_text(subtree, tvb, offset, 1, "Subscribed Guaranteed bit rate for downlink/Reserved"  );
406         }else{
407                 proto_tree_add_uint(subtree, hf_gsm_map_guaranteed_max_brate_dlink, tvb, offset, 1, gsm_map_calc_bitrate(octet));
408         }
409
410 }
411
412 #define  ELLIPSOID_POINT 0
413 #define  ELLIPSOID_POINT_WITH_UNCERT_CIRC 1
414 #define  ELLIPSOID_POINT_WITH_UNCERT_ELLIPSE 3
415 #define  POLYGON 5
416 #define  ELLIPSOID_POINT_WITH_ALT 8
417 #define  ELLIPSOID_POINT_WITH_ALT_AND_UNCERT_ELLIPSOID 9
418 #define  ELLIPSOID_ARC 10
419 /*
420 4 3 2 1
421 0 0 0 0 Ellipsoid Point
422 0 0 0 1 Ellipsoid point with uncertainty Circle
423 0 0 1 1 Ellipsoid point with uncertainty Ellipse
424 0 1 0 1 Polygon
425 1 0 0 0 Ellipsoid point with altitude
426 1 0 0 1 Ellipsoid point with altitude and uncertainty Ellipsoid
427 1 0 1 0 Ellipsoid Arc
428 other values reserved for future use
429 */
430
431 /* TS 23 032 Table 2a: Coding of Type of Shape */
432 static const value_string type_of_shape_vals[] = {
433         { ELLIPSOID_POINT,                                                                      "Ellipsoid Point"},
434         { ELLIPSOID_POINT_WITH_UNCERT_CIRC,                                     "Ellipsoid point with uncertainty Circle"},
435         { ELLIPSOID_POINT_WITH_UNCERT_ELLIPSE,                          "Ellipsoid point with uncertainty Ellipse"},
436         { POLYGON,                                                                                      "Polygon"},
437         { ELLIPSOID_POINT_WITH_ALT,                                                     "Ellipsoid point with altitude"},
438         { ELLIPSOID_POINT_WITH_ALT_AND_UNCERT_ELLIPSOID,        "Ellipsoid point with altitude and uncertainty Ellipsoid"},
439         { ELLIPSOID_ARC,                                                                        "Ellipsoid Arc"},
440         { 0,    NULL }
441 };
442
443 /* 3GPP TS 23.032 7.3.1 */
444 static const value_string sign_of_latitude_vals[] = {
445         { 0,            "North"},
446         { 1,            "South"},
447         { 0,    NULL }
448 };
449
450 static const value_string dir_of_alt_vals[] = {
451         { 0,            "Altitude expresses height"},
452         { 1,            "Altitude expresses depth"},
453         { 0,    NULL }
454 };
455
456 static const value_string gsm_map_cbs_data_coding_scheme_coding_grp_vals[] = {
457         { 0, "Coding Group 0(Language using the GSM 7 bit default alphabet)" },
458         { 1, "Coding Group 1" },
459         { 2, "Coding Group 2" },
460         { 3, "Coding Group 3" },
461         { 4, "General Data Coding indication" },
462         { 5, "General Data Coding indication" },
463         { 6, "General Data Coding indication" },
464         { 7, "General Data Coding indication" },
465         { 8, "Reserved" },
466         { 9, "Message with User Data Header (UDH) structure" },
467         { 10,"Reserved" },
468         { 11,"Reserved" },
469         { 12,"Reserved" },
470         { 13,"Reserved" },
471         { 14,"Defined by the WAP Forum" },
472         { 15,"Data coding / message handling" },
473         { 0, NULL}
474 };
475 static value_string_ext gsm_map_cbs_data_coding_scheme_coding_grp_vals_ext = VALUE_STRING_EXT_INIT(gsm_map_cbs_data_coding_scheme_coding_grp_vals);
476
477 /* Coding group 0
478  * Bits 3..0 indicate the language:
479  */
480 static const value_string gsm_map_cbs_coding_grp0_lang_vals[] = {
481         { 0, "German"},
482         { 1, "English"},
483         { 2, "Italian"},
484         { 3, "French"},
485         { 4, "Spanish"},
486         { 5, "Dutch"},
487         { 6, "Swedish"},
488         { 7, "Danish"},
489         { 8, "Portuguese"},
490         { 9, "Finnish"},
491         { 10, "Norwegian"},
492         { 11, "Greek"},
493         { 12, "Turkish"},
494         { 13, "Hungarian"},
495         { 14, "Polish"},
496         { 15, "Language unspecified"},
497         { 0,    NULL }
498 };
499 static value_string_ext gsm_map_cbs_coding_grp0_lang_vals_ext = VALUE_STRING_EXT_INIT(gsm_map_cbs_coding_grp0_lang_vals);
500
501 static const value_string gsm_map_cbs_coding_grp1_lang_vals[] = {
502         { 0, "GSM 7 bit default alphabet; message preceded by language indication"},
503         { 1, "UCS2; message preceded by language indication"},
504         { 2, "Reserved"},
505         { 3, "Reserved"},
506         { 4, "Reserved"},
507         { 5, "Reserved"},
508         { 6, "Reserved"},
509         { 7, "Reserved"},
510         { 8, "Reserved"},
511         { 9, "Reserved"},
512         { 10, "Reserved"},
513         { 11, "Reserved"},
514         { 12, "Reserved"},
515         { 13, "Reserved"},
516         { 14, "Reserved"},
517         { 15, "Reserved"},
518         { 0,    NULL }
519 };
520 static value_string_ext gsm_map_cbs_coding_grp1_lang_vals_ext = VALUE_STRING_EXT_INIT(gsm_map_cbs_coding_grp1_lang_vals);
521
522 static const value_string gsm_map_cbs_coding_grp2_lang_vals[] = {
523         { 0, "Czech"},
524         { 1, "Hebrew"},
525         { 2, "Arabic"},
526         { 3, "Russian"},
527         { 4, "Icelandic"},
528         { 5, "Reserved for other languages using the GSM 7 bit default alphabet, with unspecified handling at the MS"},
529         { 6, "Reserved for other languages using the GSM 7 bit default alphabet, with unspecified handling at the MS"},
530         { 7, "Reserved for other languages using the GSM 7 bit default alphabet, with unspecified handling at the MS"},
531         { 8, "Reserved for other languages using the GSM 7 bit default alphabet, with unspecified handling at the MS"},
532         { 9, "Reserved for other languages using the GSM 7 bit default alphabet, with unspecified handling at the MS"},
533         { 10, "Reserved for other languages using the GSM 7 bit default alphabet, with unspecified handling at the MS"},
534         { 11, "Reserved for other languages using the GSM 7 bit default alphabet, with unspecified handling at the MS"},
535         { 12, "Reserved for other languages using the GSM 7 bit default alphabet, with unspecified handling at the MS"},
536         { 13, "Reserved for other languages using the GSM 7 bit default alphabet, with unspecified handling at the MS"},
537         { 14, "Reserved for other languages using the GSM 7 bit default alphabet, with unspecified handling at the MS"},
538         { 15, "Reserved for other languages using the GSM 7 bit default alphabet, with unspecified handling at the MS"},
539         { 0,    NULL }
540 };
541 static value_string_ext gsm_map_cbs_coding_grp2_lang_vals_ext = VALUE_STRING_EXT_INIT(gsm_map_cbs_coding_grp2_lang_vals);
542
543 static const value_string gsm_map_cbs_coding_grp3_lang_vals[] = {
544         { 0, "Reserved for other languages using the GSM 7 bit default alphabet, with unspecified handling at the MS"},
545         { 1, "Reserved for other languages using the GSM 7 bit default alphabet, with unspecified handling at the MS"},
546         { 2, "Reserved for other languages using the GSM 7 bit default alphabet, with unspecified handling at the MS"},
547         { 3, "Reserved for other languages using the GSM 7 bit default alphabet, with unspecified handling at the MS"},
548         { 4, "Reserved for other languages using the GSM 7 bit default alphabet, with unspecified handling at the MS"},
549         { 5, "Reserved for other languages using the GSM 7 bit default alphabet, with unspecified handling at the MS"},
550         { 6, "Reserved for other languages using the GSM 7 bit default alphabet, with unspecified handling at the MS"},
551         { 7, "Reserved for other languages using the GSM 7 bit default alphabet, with unspecified handling at the MS"},
552         { 8, "Reserved for other languages using the GSM 7 bit default alphabet, with unspecified handling at the MS"},
553         { 9, "Reserved for other languages using the GSM 7 bit default alphabet, with unspecified handling at the MS"},
554         { 10, "Reserved for other languages using the GSM 7 bit default alphabet, with unspecified handling at the MS"},
555         { 11, "Reserved for other languages using the GSM 7 bit default alphabet, with unspecified handling at the MS"},
556         { 12, "Reserved for other languages using the GSM 7 bit default alphabet, with unspecified handling at the MS"},
557         { 13, "Reserved for other languages using the GSM 7 bit default alphabet, with unspecified handling at the MS"},
558         { 14, "Reserved for other languages using the GSM 7 bit default alphabet, with unspecified handling at the MS"},
559         { 15, "Reserved for other languages using the GSM 7 bit default alphabet, with unspecified handling at the MS"},
560         { 0,    NULL }
561 };
562 static value_string_ext gsm_map_cbs_coding_grp3_lang_vals_ext = VALUE_STRING_EXT_INIT(gsm_map_cbs_coding_grp3_lang_vals);
563
564 static const true_false_string gsm_map_cbs_coding_grp4_7_comp_vals = {
565   "The text is compressed using the compression algorithm defined in 3GPP TS 23.042",
566   "The text is uncompressed"
567 };
568
569 static const true_false_string gsm_map_cbs_coding_grp4_7_class_ind_vals = {
570   "Bits 1 to 0 have a message class meaning",
571   "Bits 1 to 0 are reserved and have no message class meaning"
572 };
573
574 /* Bits 3 and 2 indicate the character set being used, as follows: */
575
576 static const value_string gsm_map_cbs_coding_grp4_7_char_set_vals[] = {
577         { 0, "GSM 7 bit default alphabet"},
578         { 1, "8 bit data"},
579         { 2, "UCS2 (16 bit)"},
580         { 3, "Reserved"},
581         { 0,    NULL }
582 };
583
584 static const value_string gsm_map_cbs_coding_grp4_7_class_vals[] = {
585         { 0, "Class 0"},
586         { 1, "Class 1 Default meaning: ME-specific"},
587         { 2, "Class 2 (U)SIM specific message"},
588         { 3, "Class 3 Default meaning: TE-specific (see 3GPP TS 27.005"},
589         { 0,    NULL }
590 };
591
592 static const value_string gsm_map_cbs_coding_grp15_mess_code_vals[] = {
593         { 0, "GSM 7 bit default alphabet"},
594         { 1, "8 bit data"},
595         { 0,    NULL }
596 };
597
598 static const value_string gsm_map_cbs_coding_grp15_class_vals[] = {
599         { 0, "GSM 7 bit default alphabet"},
600         { 1, "8 bit data"},
601         { 0,    NULL }
602 };
603
604
605 /* 3GPP TS 23.038 version 7.0.0 Release 7 */
606 guint8
607 dissect_cbs_data_coding_scheme(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
608 {
609         guint8 octet;
610         guint8 coding_grp;
611         guint8 character_set;
612
613         octet = tvb_get_guint8(tvb,0);
614         coding_grp = octet >>4;
615         proto_tree_add_item(tree, hf_gsm_map_cbs_coding_grp, tvb, 0, 1, FALSE);
616
617         sms_encoding = SMS_ENCODING_NOT_SET;
618         switch (coding_grp){
619         case 0:
620                 proto_tree_add_item(tree, hf_gsm_map_cbs_coding_grp0_lang, tvb, 0, 1, FALSE);
621                 sms_encoding = SMS_ENCODING_7BIT;
622                 break;
623         case 1:
624                 proto_tree_add_item(tree, hf_gsm_map_cbs_coding_grp1_lang, tvb, 0, 1, FALSE);
625                 if ((octet & 0x0f)== 0){
626                         sms_encoding = SMS_ENCODING_7BIT_LANG;
627                 }else{
628                         sms_encoding = SMS_ENCODING_UCS2_LANG;
629                 }
630                 break;
631         case 2:
632                 proto_tree_add_item(tree, hf_gsm_map_cbs_coding_grp2_lang, tvb, 0, 1, FALSE);
633                 sms_encoding = SMS_ENCODING_7BIT;
634                 break;
635         case 3:
636                 proto_tree_add_item(tree, hf_gsm_map_cbs_coding_grp3_lang, tvb, 0, 1, FALSE);
637                 sms_encoding = SMS_ENCODING_7BIT;
638                 break;
639                 /* Coding_grp 01xx */
640         case 4:
641                   /* FALLTHRU */
642         case 5:
643                   /* FALLTHRU */
644         case 6:
645                   /* FALLTHRU */
646         case 7:
647                   /* FALLTHRU */
648                 proto_tree_add_item(tree, hf_gsm_map_cbs_coding_grp4_7_comp, tvb, 0, 1, FALSE);
649                 proto_tree_add_item(tree, hf_gsm_map_cbs_coding_grp4_7_class_ind, tvb, 0, 1, FALSE);
650                 proto_tree_add_item(tree, hf_gsm_map_cbs_coding_grp4_7_char_set, tvb, 0, 1, FALSE);
651                 if ((octet & 0x10)== 0x10){
652                         proto_tree_add_item(tree, hf_gsm_map_cbs_coding_grp4_7_class, tvb, 0, 1, FALSE);
653                 }
654                 /* Bits 3 and 2 indicate the character set being used, */
655                 character_set = (octet&0x0c)>>2;
656                 switch (character_set){
657                 case 0:
658                         /* GSM 7 bit default alphabet */
659                         sms_encoding = SMS_ENCODING_7BIT;
660                         break;
661                 case 1:
662                         /* 8 bit data */
663                         sms_encoding = SMS_ENCODING_8BIT;
664                         break;
665                 case 2:
666                         /* UCS2 (16 bit) */
667                         sms_encoding = SMS_ENCODING_UCS2;
668                         break;
669                 case 3:
670                         /* Reserved */
671                         sms_encoding = SMS_ENCODING_NOT_SET;
672                         break;
673                 default:
674                         break;
675                 }
676                 break;
677         case 8:
678                 /* Reserved coding groups */
679                 break;
680         case 9:
681                 /* Message with User Data Header (UDH) structure:*/
682                 proto_tree_add_item(tree, hf_gsm_map_cbs_coding_grp4_7_char_set, tvb, 0, 1, FALSE);
683                 proto_tree_add_item(tree, hf_gsm_map_cbs_coding_grp4_7_class, tvb, 0, 1, FALSE);
684                 character_set = (octet&0x0c)>>2;
685                 switch (character_set){
686                 case 0:
687                         /* GSM 7 bit default alphabet */
688                         sms_encoding = SMS_ENCODING_7BIT;
689                         break;
690                 case 1:
691                         /* 8 bit data */
692                         sms_encoding = SMS_ENCODING_8BIT;
693                         break;
694                 case 2:
695                         /* UCS2 (16 bit) */
696                         sms_encoding = SMS_ENCODING_UCS2;
697                         break;
698                 case 3:
699                         /* Reserved */
700                         sms_encoding = SMS_ENCODING_NOT_SET;
701                         break;
702                 default:
703                         break;
704                 }
705                 break;
706         case 10:
707                 /* FALLTHRU */
708         case 11:
709                 /* FALLTHRU */
710         case 12:
711                 /* FALLTHRU */
712         case 13:
713                 /* FALLTHRU */
714                 /* 1010..1101 Reserved coding groups */
715                 break;
716         case 14:
717                 /* Defined by the WAP Forum
718                  * "Wireless Datagram Protocol Specification", Wireless Application Protocol Forum Ltd.
719                  */
720                 break;
721         case 15:
722                 /* Data coding / message handling */
723                 proto_tree_add_item(tree, hf_gsm_map_cbs_coding_grp15_mess_code, tvb, 0, 1, FALSE);
724                 proto_tree_add_item(tree, hf_gsm_map_cbs_coding_grp15_class, tvb, 0, 1, FALSE);
725                 character_set = (octet&0x04)>>2;
726                 if (character_set == 0){
727                         sms_encoding = SMS_ENCODING_7BIT;
728                 }else{
729                         sms_encoding = SMS_ENCODING_8BIT;
730                 }
731                 break;
732         default:
733                 break;
734         }
735
736         return sms_encoding;
737 }
738 void
739 dissect_gsm_map_msisdn(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
740 {
741  const char     *digit_str;
742  guint8         octet;
743  guint8         na;
744  guint8         np;
745
746  proto_tree_add_item(tree, hf_gsm_map_extension, tvb, 0,1,FALSE);
747  proto_tree_add_item(tree, hf_gsm_map_nature_of_number, tvb, 0,1,FALSE);
748  proto_tree_add_item(tree, hf_gsm_map_number_plan, tvb, 0,1,FALSE);
749
750  digit_str = unpack_digits(tvb, 1);
751
752  proto_tree_add_string(tree, hf_gsm_map_address_digits, tvb, 1, -1, digit_str);
753
754  octet = tvb_get_guint8(tvb,0);
755  na = (octet & 0x70)>>4;
756  np = octet & 0x0f;
757  if ((na == 1) && (np==1))/*International Number & E164*/
758         dissect_e164_cc(tvb, tree, 1, TRUE);
759  else if(np==6)
760         dissect_e212_mcc_mnc_in_address(tvb, pinfo, tree, 1);
761
762 }
763
764 #include "packet-gsm_map-fn.c"
765
766 /* Specific translation for MAP V3 */
767 const value_string gsm_map_V1V2_opr_code_strings[] = {
768   {  44, "forwardSM" },
769   {  45, "sendRoutingInfoForSM" },
770   {  46, "forwardSM" },
771   { 0, NULL }
772 };
773 /* Generic translation for MAP operation */
774 const value_string gsm_map_opr_code_strings[] = {
775 #include "packet-gsm_map-table.c"
776   { 0, NULL }
777 };
778 static const value_string gsm_map_err_code_string_vals[] = {
779 #include "packet-gsm_map-table.c"
780     { 0, NULL }
781 };
782 static const true_false_string gsm_map_extension_value = {
783   "No Extension",
784   "Extension"
785 };
786 static const value_string gsm_map_nature_of_number_values[] = {
787         {   0x00,       "unknown" },
788         {   0x01,       "International Number" },
789         {   0x02,       "National Significant Number" },
790         {   0x03,       "Network Specific Number" },
791         {   0x04,       "Subscriber Number" },
792         {   0x05,       "Reserved" },
793         {   0x06,       "Abbreviated Number" },
794         {   0x07,       "Reserved for extension" },
795         { 0, NULL }
796 };
797 static value_string_ext gsm_map_nature_of_number_values_ext = VALUE_STRING_EXT_INIT(gsm_map_nature_of_number_values);
798
799 static const value_string gsm_map_number_plan_values[] = {
800         {   0x00,       "unknown" },
801         {   0x01,       "ISDN/Telephony Numbering (Rec ITU-T E.164)" },
802         {   0x02,       "spare" },
803         {   0x03,       "Data Numbering (ITU-T Rec. X.121)" },
804         {   0x04,       "Telex Numbering (ITU-T Rec. F.69)" },
805         {   0x05,       "spare" },
806         {   0x06,       "Land Mobile Numbering (ITU-T Rec. E.212)" },
807         {   0x07,       "spare" },
808         {   0x08,       "National Numbering" },
809         {   0x09,       "Private Numbering" },
810         {   0x0f,       "Reserved for extension" },
811         { 0, NULL }
812 };
813 static value_string_ext gsm_map_number_plan_values_ext = VALUE_STRING_EXT_INIT(gsm_map_number_plan_values);
814
815 static const true_false_string gsm_map_Ss_Status_q_bit_values = {
816   "Quiescent",
817   "Operative"
818 };
819 static const true_false_string gsm_map_Ss_Status_p_values = {
820   "Provisioned",
821   "Not Provisioned"
822 };
823 static const true_false_string gsm_map_Ss_Status_r_values = {
824   "Registered",
825   "Not Registered"
826 };
827 static const true_false_string gsm_map_Ss_Status_a_values = {
828   "Active",
829   "not Active"
830 };
831
832 /*
833  * Translate the MAP operation code value to a text string
834  * Take into account the MAP version for ForwardSM
835  */
836 const gchar* gsm_map_opr_code(guint32 val) {
837   switch (val) {
838   case 44: /*mt-forwardSM*/
839           /* FALLTHRU */
840   case 46: /*mo-forwardSM*/
841           /* FALLTHRU */
842     if (application_context_version < 3) {
843       return val_to_str_const(val, gsm_map_V1V2_opr_code_strings, "Unknown GSM-MAP opcode");
844     }
845     /* Else use the default map operation translation */
846   default:
847     return val_to_str_ext_const(val, &gsm_old_GSMMAPOperationLocalvalue_vals_ext, "Unknown GSM-MAP opcode");
848     break;
849   }
850 }
851
852 /* Prototype for a decoding function */
853 typedef int (* dissect_function_t)( gboolean,
854                                     tvbuff_t *,
855                                     int ,
856                                         asn1_ctx_t *,
857                                     proto_tree *,
858                                     int);
859
860 /*
861  * Dissect Multiple Choice Message
862  * This function is used to decode a message, when several encoding may be used.
863  * For exemple, in the last MAP version, the Cancel Location is defined like this:
864  * CancelLocationArg ::= [3] IMPLICIT SEQUENCE
865  * But in the previous MAP version, it was a CHOICE between a SEQUENCE and an IMSI
866  * As ASN1 encoders (or software) still uses the old encoding, this function allows
867  * the decoding of both versions.
868  * Moreover, some optimizations (or bad practice ?) in ASN1 encoder, removes the
869  * SEQUENCE tag, when only one parameter is present in the SEQUENCE.
870  * This explain why the function expects 3 parameters:
871  * - a [3] SEQUENCE corresponding the recent ASN1 MAP encoding
872  * - a SEQUENCE for old style
873  * - and a single parameter, for old version or optimizations
874  *
875  * The analyze of the first ASN1 tag, indicate what kind of decoding should be used,
876  * if the decoding function is provided (so not a NULL function)
877  */
878 static int dissect_mc_message(tvbuff_t *tvb,
879                               int offset,
880                                   asn1_ctx_t *actx,
881                               proto_tree *tree,
882                               gboolean implicit_param _U_, dissect_function_t parameter, int hf_index_param _U_,
883                               gboolean implicit_seq   _U_, dissect_function_t sequence,  int hf_index_seq   _U_,
884                               gboolean implicit_seq3 _U_, dissect_function_t sequence3, int hf_index_seq3 _U_ )
885 {
886   guint8 octet;
887   gint8 bug_class;
888   gboolean bug_pc, bug_ind_field;
889   gint32 bug_tag;
890   guint32 bug_len;
891   proto_item *cause;
892
893   octet = tvb_get_guint8(tvb,0);
894   if ( (octet & 0xf) == 3) {
895     /* XXX  asn2wrs can not yet handle tagged assignment yes so this
896      * XXX is some conformance file magic to work around that bug
897      */
898     offset = get_ber_identifier(tvb, offset, &bug_class, &bug_pc, &bug_tag);
899     offset = get_ber_length(tvb, offset, &bug_len, &bug_ind_field);
900     if (sequence3 != NULL) {
901       offset= (sequence3) (implicit_seq3, tvb, offset, actx, tree, hf_index_seq3);
902     } else {
903       cause=proto_tree_add_text(tree, tvb, offset, -1, "Unknown or not implemented [3] sequence, cannot decode");
904       proto_item_set_expert_flags(cause, PI_UNDECODED, PI_ERROR);
905       expert_add_info_format(actx->pinfo, cause, PI_UNDECODED, PI_ERROR, "Unknown or not implemented [3] sequence");
906     }
907   } else if (octet == 0x30) {
908     if (sequence != NULL) {
909       offset= (sequence) (implicit_seq, tvb, 0, actx, tree, hf_index_seq);
910     } else {
911       cause=proto_tree_add_text(tree, tvb, offset, -1, "Unknown or not implemented sequence");
912       proto_item_set_expert_flags(cause, PI_UNDECODED, PI_ERROR);
913       expert_add_info_format(actx->pinfo, cause, PI_UNDECODED, PI_ERROR, "Unknown or not implemented sequence");
914     }
915   } else {
916     if (parameter != NULL) {
917       offset= (parameter) (implicit_param, tvb, offset, actx, tree, hf_index_param);
918     } else {
919       cause=proto_tree_add_text(tree, tvb, offset, -1, "Unknown or not implemented parameter");
920       proto_item_set_expert_flags(cause, PI_UNDECODED, PI_ERROR);
921       expert_add_info_format(actx->pinfo, cause, PI_UNDECODED, PI_ERROR, "Unknown or not implemented parameter");
922     }
923   }
924   return offset;
925 }
926
927 static int dissect_invokeData(proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *actx) {
928
929   proto_item *cause;
930
931   switch(opcode){
932   case  2: /*updateLocation*/
933     offset=dissect_gsm_map_ms_UpdateLocationArg(FALSE, tvb, offset, actx, tree, -1);
934     break;
935   case  3: /*cancelLocation*/
936     offset=dissect_mc_message(tvb, offset, actx, tree,
937                               FALSE, dissect_gsm_map_Identity, hf_gsm_map_ms_identity,
938                               FALSE, dissect_gsm_map_Identity, hf_gsm_map_ms_identity,
939                               TRUE , dissect_gsm_map_ms_CancelLocationArg, -1);/*undefined*/
940     break;
941   case  4: /*provideRoamingNumber*/
942     offset=dissect_gsm_map_ch_ProvideRoamingNumberArg(FALSE, tvb, offset, actx, tree, -1);
943     break;
944   case  5: /*noteSubscriberDataModified*/
945     offset=dissect_gsm_map_ms_NoteSubscriberDataModifiedArg(FALSE, tvb, offset, actx, tree, -1);
946     break;
947   case  6: /*resumeCallHandling*/
948     offset=dissect_gsm_map_ch_ResumeCallHandlingArg(FALSE, tvb, offset, actx, tree, -1);
949     break;
950   case  7: /*insertSubscriberData*/
951     offset=dissect_gsm_map_ms_InsertSubscriberDataArg(FALSE, tvb, offset, actx, tree, -1);
952     break;
953   case  8: /*deleteSubscriberData*/
954     offset=dissect_gsm_map_ms_DeleteSubscriberDataArg(FALSE, tvb, offset, actx, tree, -1);
955     break;
956     /* TODO find out why this isn't in the ASN1 file */
957     /* reserved sendParameters (9) */
958   case  10: /*registerSS*/
959     offset=dissect_gsm_map_ss_RegisterSS_Arg(FALSE, tvb, offset, actx, tree, -1);
960     break;
961   case  11: /*eraseSS*/
962     offset=dissect_gsm_map_ss_SS_ForBS_Code(FALSE, tvb, offset, actx, tree, -1);
963     break;
964   case 12: /*activateSS*/
965     offset=dissect_gsm_map_ss_SS_ForBS_Code(FALSE, tvb, offset, actx, tree, -1);
966     break;
967   case 13: /*deactivateSS*/
968     offset=dissect_gsm_map_ss_SS_ForBS_Code(FALSE, tvb, offset, actx, tree, -1);
969     break;
970   case 14: /*interrogateSS*/
971     offset=dissect_gsm_map_ss_SS_ForBS_Code(FALSE, tvb, offset, actx, tree, -1);
972     break;
973   case 15: /*authenticationFailureReport*/
974     offset=dissect_gsm_map_ms_AuthenticationFailureReportArg(FALSE, tvb, offset, actx, tree, -1);
975     break;
976   case 16: /*SS-protocol notifySS*/
977     offset=dissect_gsm_ss_NotifySS_Arg(FALSE, tvb, offset, actx, tree, -1);
978     break;
979   case 17: /*registerPassword*/
980     offset=dissect_gsm_map_SS_Code(FALSE, tvb, offset, actx, tree, hf_gsm_map_ss_Code);
981     break;
982   case 18: /*getPassword*/
983     offset=dissect_gsm_old_GetPasswordArg(FALSE, tvb, offset, actx, tree, hf_gsm_map_getPassword);
984     break;
985   case 19: /* SS-Protocol processUnstructuredSS-Data (19) */
986     offset=dissect_gsm_ss_SS_UserData(FALSE, tvb, offset, actx, tree, hf_gsm_map_ss_SS_UserData);
987     break;
988   case 20: /*releaseResources*/
989     offset=dissect_gsm_map_ch_ReleaseResourcesArg(FALSE, tvb, offset, actx, tree, -1);
990     break;
991   case 21: /*mt-ForwardSM-VGCS*/
992     offset=dissect_gsm_map_sm_MT_ForwardSM_VGCS_Arg(FALSE, tvb, offset, actx, tree, -1);
993     break;
994   case 22: /*sendRoutingInfo*/
995           if (application_context_version == 3){
996                   offset=dissect_gsm_map_ch_SendRoutingInfoArg(FALSE, tvb, offset, actx, tree, -1);
997           }else{
998                   offset=dissect_gsm_old_SendRoutingInfoArgV2(FALSE, tvb, offset, actx, tree, -1);
999           }
1000     break;
1001   case 23: /*updateGprsLocation*/
1002     offset=dissect_gsm_map_ms_UpdateGprsLocationArg(FALSE, tvb, offset, actx, tree, -1);
1003     break;
1004   case 24: /*sendRoutingInfoForGprs*/
1005     offset=dissect_gsm_map_ms_SendRoutingInfoForGprsArg(FALSE, tvb, offset, actx, tree, -1);
1006     break;
1007   case 25: /*failureReport*/
1008     offset=dissect_gsm_map_ms_FailureReportArg(FALSE, tvb, offset, actx, tree, -1);
1009     break;
1010   case 26: /*noteMsPresentForGprs*/
1011     offset=dissect_gsm_map_ms_NoteMsPresentForGprsArg(FALSE, tvb, offset, actx, tree, -1);
1012     break;
1013     /* undefined 27 */
1014     /* reserved performHandover (28) */
1015   case 29: /*sendEndSignal*/
1016     offset=dissect_mc_message(tvb, offset, actx, tree,
1017                               FALSE, NULL, -1,
1018                               FALSE, dissect_gsm_old_Bss_APDU, -1,
1019                               TRUE , dissect_gsm_map_ms_SendEndSignal_Arg, -1);
1020     break;
1021     /* reserved performSubsequentHandover (30) */
1022   case 31: /*provideSIWFSNumber*/
1023     offset=dissect_gsm_old_ProvideSIWFSNumberArg(FALSE, tvb, offset, actx, tree, -1);
1024     break;
1025   case 32: /*sIWFSSignallingModify*/
1026     offset=dissect_gsm_old_SIWFSSignallingModifyArg(FALSE, tvb, offset, actx, tree, -1);
1027     break;
1028   case 33: /*processAccessSignalling*/
1029     offset=dissect_mc_message(tvb, offset, actx, tree,
1030                               FALSE, NULL, -1,
1031                               FALSE, dissect_gsm_old_Bss_APDU, -1,
1032                               TRUE , dissect_gsm_map_ms_ProcessAccessSignalling_Arg, -1);
1033     break;
1034   case 34: /*forwardAccessSignalling*/
1035     offset=dissect_mc_message(tvb, offset, actx, tree,
1036                               FALSE, NULL, -1,
1037                               FALSE, dissect_gsm_old_Bss_APDU, -1,
1038                               TRUE , dissect_gsm_map_ms_ForwardAccessSignalling_Arg, -1);
1039     break;
1040     /* reserved noteInternalHandover (35) */
1041     /* undefined 36 */
1042   case 37: /*reset*/
1043     offset=dissect_gsm_map_ms_ResetArg(FALSE, tvb, offset, actx, tree, -1);
1044     break;
1045   case 38: /*forwardCheckSS-Indication*/
1046     return offset;
1047     break;
1048   case 39: /*prepareGroupCall*/
1049     offset=dissect_gsm_map_gr_PrepareGroupCallArg(FALSE, tvb, offset, actx, tree, -1);
1050     break;
1051   case 40: /*sendGroupCallEndSignal*/
1052     offset = dissect_gsm_map_gr_SendGroupCallEndSignalArg(FALSE, tvb, offset, actx, tree, -1);
1053     break;
1054   case 41: /*processGroupCallSignalling*/
1055     offset = dissect_gsm_map_gr_ProcessGroupCallSignallingArg(FALSE, tvb, offset, actx, tree, -1);
1056     break;
1057   case 42: /*forwardGroupCallSignalling*/
1058     offset=dissect_gsm_map_gr_ForwardGroupCallSignallingArg(FALSE, tvb, offset, actx, tree, -1);
1059     break;
1060   case 43: /*checkIMEI*/
1061     offset=dissect_mc_message(tvb, offset, actx, tree,
1062                               FALSE, dissect_gsm_map_IMEI, hf_gsm_map_ms_imei,
1063                               FALSE, dissect_gsm_map_ms_CheckIMEI_Arg, -1,
1064                               TRUE , NULL, -1); /* no [3] SEQUENCE */
1065     break;
1066   case 44: /*mt-forwardSM(v3) or ForwardSM(v1/v2)*/
1067     if (application_context_version == 3)
1068       offset=dissect_gsm_map_sm_MT_ForwardSM_Arg(FALSE, tvb, offset, actx, tree, -1);
1069     else {
1070       offset=dissect_gsm_old_ForwardSM_Arg(FALSE, tvb, offset, actx, tree, -1);
1071     }
1072     break;
1073   case 45: /*sendRoutingInfoForSM*/
1074     offset=dissect_gsm_map_sm_RoutingInfoForSM_Arg(FALSE, tvb, offset, actx, tree, -1);
1075     break;
1076   case 46: /*mo-forwardSM(v3) or ForwardSM(v1/v2)*/
1077     if (application_context_version == 3)
1078       offset=dissect_gsm_map_sm_MO_ForwardSM_Arg(FALSE, tvb, offset, actx, tree, -1);
1079     else {
1080       offset=dissect_gsm_old_ForwardSM_Arg(FALSE, tvb, offset, actx, tree, -1);
1081     }
1082     break;
1083   case 47: /*reportSM-DeliveryStatus*/
1084     offset=dissect_gsm_map_sm_ReportSM_DeliveryStatusArg(FALSE, tvb, offset, actx, tree, -1);
1085     break;
1086     /* reserved noteSubscriberPresent (48) */
1087     /* reserved alertServiceCentreWithoutResult (49)
1088          * ETS 300 599: December 2000 (GSM 09.02 version 4.19.1)
1089          * -- alertServiceCentreWithoutResult must not be used in
1090          * -- version greater 1
1091          */
1092   case 49:
1093         offset = dissect_gsm_map_sm_AlertServiceCentreArg(FALSE, tvb, offset, actx, tree, -1);
1094         break;
1095   case 50: /*activateTraceMode*/
1096     offset=dissect_gsm_map_om_ActivateTraceModeArg(FALSE, tvb, offset, actx, tree, -1);
1097     break;
1098   case 51: /*deactivateTraceMode*/
1099     offset=dissect_gsm_map_om_DeactivateTraceModeArg(FALSE, tvb, offset, actx, tree, -1);
1100     break;
1101     /* reserved traceSubscriberActivity (52) */
1102     /* undefined 53 */
1103   case 54: /*beginSubscriberActivity*/
1104     offset=dissect_gsm_old_BeginSubscriberActivityArg(FALSE, tvb, offset, actx, tree, -1);
1105     break;
1106   case 55: /*sendIdentification*/
1107     offset=dissect_mc_message(tvb, offset, actx, tree,
1108                               FALSE, dissect_gsm_map_TMSI, hf_gsm_map_tmsi,
1109                               FALSE, dissect_gsm_map_ms_SendIdentificationArg, -1,
1110                               TRUE,  NULL, -1);
1111     break;
1112   case 56: /*sendAuthenticationInfo*/
1113     offset=dissect_mc_message(tvb, offset, actx, tree,
1114                               FALSE, dissect_gsm_map_IMSI, hf_gsm_map_imsi,
1115                               FALSE, dissect_gsm_map_ms_SendAuthenticationInfoArg, -1,
1116                               TRUE,  NULL, -1);
1117     break;
1118   case 57: /*restoreData*/
1119     offset=dissect_gsm_map_ms_RestoreDataArg(FALSE, tvb, offset, actx, tree, -1);
1120     break;
1121   case 58: /*sendIMSI*/
1122     offset = dissect_gsm_map_ISDN_AddressString(FALSE, tvb, offset, actx, tree, hf_gsm_map_msisdn);
1123     break;
1124   case 59: /*processUnstructuredSS-Request*/
1125     offset=dissect_gsm_map_ss_USSD_Arg(FALSE, tvb, offset, actx, tree, -1);
1126     break;
1127   case 60: /*unstructuredSS-Request*/
1128     offset=dissect_gsm_map_ss_USSD_Arg(FALSE, tvb, offset, actx, tree, -1);
1129     break;
1130   case 61: /*unstructuredSS-Notify*/
1131     offset=dissect_gsm_map_ss_USSD_Arg(FALSE, tvb, offset, actx, tree, -1);
1132     break;
1133   case 62: /*AnyTimeSubscriptionInterrogation*/
1134     offset=dissect_gsm_map_ms_AnyTimeSubscriptionInterrogationArg(FALSE, tvb, offset, actx, tree, -1);
1135     break;
1136   case 63: /*informServiceCentre*/
1137     offset=dissect_gsm_map_sm_InformServiceCentreArg(FALSE, tvb, offset, actx, tree, -1);
1138     break;
1139   case 64: /*alertServiceCentre*/
1140     offset=dissect_gsm_map_sm_AlertServiceCentreArg(FALSE, tvb, offset, actx, tree, -1);
1141     break;
1142   case 65: /*AnyTimeModification*/
1143     offset=dissect_gsm_map_ms_AnyTimeModificationArg(FALSE, tvb, offset, actx, tree, -1);
1144     break;
1145   case 66: /*readyForSM*/
1146     offset=dissect_gsm_map_sm_ReadyForSM_Arg(FALSE, tvb, offset, actx, tree, -1);
1147     break;
1148   case 67: /*purgeMS*/
1149     offset=dissect_mc_message(tvb, offset, actx, tree,
1150                               FALSE, dissect_gsm_map_IMSI, hf_gsm_map_imsi,
1151                               FALSE, dissect_gsm_old_PurgeMSArgV2, -1, /*undefined*/
1152                               TRUE , dissect_gsm_map_ms_PurgeMS_Arg, -1);
1153     break;
1154   case 68: /*prepareHandover*/
1155     offset=dissect_mc_message(tvb, offset, actx, tree,
1156                               FALSE, NULL, -1,
1157                               FALSE, dissect_gsm_old_PrepareHO_ArgOld, -1,
1158                               TRUE, dissect_gsm_map_ms_PrepareHO_Arg, -1);
1159     break;
1160   case 69: /*prepareSubsequentHandover*/
1161     offset=dissect_mc_message(tvb, offset, actx, tree,
1162                               FALSE, NULL, -1,
1163                               FALSE, NULL, -1,
1164                               TRUE, dissect_gsm_map_ms_PrepareSubsequentHO_Arg, -1);
1165     break;
1166   case 70: /*provideSubscriberInfo*/
1167     offset=dissect_gsm_map_ms_ProvideSubscriberInfoArg(FALSE, tvb, offset, actx, tree, -1);
1168     break;
1169   case 71: /*anyTimeInterrogation*/
1170     offset=dissect_gsm_map_ms_AnyTimeInterrogationArg(FALSE, tvb, offset, actx, tree, -1);
1171     break;
1172   case 72: /*ss-InvocationNotificatio*/
1173     offset=dissect_gsm_map_ss_SS_InvocationNotificationArg(FALSE, tvb, offset, actx, tree, -1);
1174     break;
1175   case 73: /*setReportingState*/
1176     offset=dissect_gsm_map_ch_SetReportingStateArg(FALSE, tvb, offset, actx, tree, -1);
1177     break;
1178   case 74: /*statusReport*/
1179     offset=dissect_gsm_map_ch_StatusReportArg(FALSE, tvb, offset, actx, tree, -1);
1180     break;
1181   case 75: /*remoteUserFree*/
1182     offset=dissect_gsm_map_ch_RemoteUserFreeArg(FALSE, tvb, offset, actx, tree, -1);
1183     break;
1184   case 76: /*registerCC-Entry*/
1185     offset=dissect_gsm_map_ss_RegisterCC_EntryArg(FALSE, tvb, offset, actx, tree, -1);
1186     break;
1187   case 77: /*eraseCC-Entry*/
1188     offset=dissect_gsm_map_ss_EraseCC_EntryArg(FALSE, tvb, offset, actx, tree, -1);
1189     break;
1190   case 78: /*secureTransportClass1*/
1191   case 79: /*secureTransportClass1*/
1192   case 80: /*secureTransportClass1*/
1193   case 81: /*secureTransportClass1*/
1194     offset=dissect_gsm_old_SecureTransportArg(FALSE, tvb, offset, actx, tree, -1);
1195     break;
1196     /* undefined 82 */
1197   case 83: /*provideSubscriberLocation*/
1198     offset=dissect_gsm_map_lcs_ProvideSubscriberLocation_Arg(FALSE, tvb, offset, actx, tree, -1);
1199     break;
1200   case 84: /*sendGroupCallInfo*/
1201     offset=dissect_gsm_map_gr_SendGroupCallInfoArg(FALSE, tvb, offset, actx, tree, -1);
1202     break;
1203   case 85: /*sendRoutingInfoForLCS*/
1204     offset=dissect_gsm_map_lcs_RoutingInfoForLCS_Arg(FALSE, tvb, offset, actx, tree, -1);
1205     break;
1206   case 86: /*subscriberLocationReport*/
1207     offset=dissect_gsm_map_lcs_SubscriberLocationReport_Arg(FALSE, tvb, offset, actx, tree, -1);
1208     break;
1209   case 87: /*ist-Alert*/
1210     offset=dissect_gsm_map_ch_IST_AlertArg(FALSE, tvb, offset, actx, tree, -1);
1211     break;
1212   case 88: /*ist-Command*/
1213     offset=dissect_gsm_map_ch_IST_CommandArg(FALSE, tvb, offset, actx, tree, -1);
1214     break;
1215   case 89: /*noteMM-Event*/
1216     offset=dissect_gsm_map_ms_NoteMM_EventArg(FALSE, tvb, offset, actx, tree, -1);
1217     break;
1218   case 109: /*SS-protocol lcs-PeriodicLocationCancellation*/
1219     offset=dissect_gsm_ss_LCS_PeriodicLocationCancellationArg(FALSE, tvb, offset, actx, tree, -1);
1220     break;
1221   case 110: /*SS-protocol lcs-LocationUpdate*/
1222     offset=dissect_gsm_ss_LCS_LocationUpdateArg(FALSE, tvb, offset, actx, tree, -1);
1223     break;
1224   case 111: /*SS-protocol lcs-PeriodicLocationRequest*/
1225     offset=dissect_gsm_ss_LCS_PeriodicLocationRequestArg(FALSE, tvb, offset, actx, tree, -1);
1226     break;
1227   case 112: /*SS-protocol lcs-AreaEventCancellation*/
1228     offset=dissect_gsm_ss_LCS_AreaEventCancellationArg(FALSE, tvb, offset, actx, tree, -1);
1229     break;
1230   case 113: /*SS-protocol lcs-AreaEventReport*/
1231     offset=dissect_gsm_ss_LCS_AreaEventReportArg(FALSE, tvb, offset, actx, tree, -1);
1232     break;
1233   case 114: /*SS-protocol lcs-AreaEventRequest*/
1234     offset=dissect_gsm_ss_LCS_AreaEventRequestArg(FALSE, tvb, offset, actx, tree, -1);
1235     break;
1236   case 115: /*SS-protocol lcs-MOLR*/
1237     offset=dissect_gsm_ss_LCS_MOLRArg(FALSE, tvb, offset, actx, tree, -1);
1238     break;
1239   case 116: /*SS-protocol lcs-LocationNotification*/
1240     offset=dissect_gsm_ss_LocationNotificationArg(FALSE, tvb, offset, actx, tree, -1);
1241     break;
1242   case 117: /*SS-protocol callDeflection*/
1243     offset=dissect_gsm_ss_CallDeflectionArg(FALSE, tvb, offset, actx, tree, -1);
1244     break;
1245   case 118: /*SS-protocol userUserService*/
1246     offset=dissect_gsm_ss_UserUserServiceArg(FALSE, tvb, offset, actx, tree, -1);
1247     break;
1248   case 119: /*SS-protocol accessRegisterCCEntry*/
1249     offset=dissect_gsm_ss_AccessRegisterCCEntryArg(FALSE, tvb, offset, actx, tree, -1);
1250     break;
1251   case 120: /*SS-protocol forwardCUG-Info*/
1252         application_context_version = 3;
1253     offset=dissect_gsm_ss_ForwardCUG_InfoArg(FALSE, tvb, offset, actx, tree, -1);
1254     break;
1255   case 121: /*SS-protocol splitMPTY no Argument*/
1256     break;
1257   case 122: /*SS-protocol retrieveMPTY no Argument*/
1258     break;
1259   case 123: /*SS-protocol holdMPTY no Argument*/
1260     break;
1261   case 124: /*SS-protocol buildMPTY no Argument*/
1262     break;
1263   case 125: /*SS-protocol forwardChargeAdvice*/
1264     offset=dissect_gsm_ss_ForwardChargeAdviceArg(FALSE, tvb, offset, actx, tree, -1);
1265     break;
1266   case 126: /*SS-protocol explicitCT no Argument*/
1267     break;
1268   default:
1269     if(!dissector_try_uint(map_prop_arg_opcode_table, (guint8)opcode, tvb, actx->pinfo, tree)){
1270         cause=proto_tree_add_text(tree, tvb, offset, -1, "Unknown invokeData blob");
1271         proto_item_set_expert_flags(cause, PI_MALFORMED, PI_WARN);
1272         expert_add_info_format(actx->pinfo, cause, PI_MALFORMED, PI_WARN, "Unknown invokeData %d",opcode);
1273         }
1274         offset+= tvb_length_remaining(tvb,offset);
1275         break;
1276   }
1277   return offset;
1278 }
1279
1280
1281 static int dissect_returnResultData(proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *actx) {
1282
1283   proto_item *cause;
1284
1285   switch(opcode){
1286   case  2: /*updateLocation*/
1287     offset=dissect_mc_message(tvb, offset, actx, tree,
1288                               FALSE, dissect_gsm_map_IMSI, hf_gsm_map_imsi,
1289                               FALSE, dissect_gsm_map_ms_UpdateLocationRes, -1,
1290                               TRUE , NULL, -1);
1291     break;
1292   case  3: /*cancelLocation*/
1293     offset=dissect_gsm_map_ms_CancelLocationRes(FALSE, tvb, offset, actx, tree, -1);
1294     break;
1295   case  4: /*provideRoamingNumber*/
1296     offset=dissect_mc_message(tvb, offset, actx, tree,
1297                               FALSE, dissect_gsm_map_ISDN_AddressString, hf_gsm_map_msisdn,
1298                               FALSE, dissect_gsm_map_ch_ProvideRoamingNumberRes, -1,
1299                               TRUE , NULL, -1);/*undefined*/
1300     break;
1301   case  5: /*noteSubscriberDataModified*/
1302     offset=dissect_gsm_map_ms_NoteSubscriberDataModifiedRes(FALSE, tvb, offset, actx, tree, -1);
1303     break;
1304   case  6: /*resumeCallHandling*/
1305     offset=dissect_gsm_map_ch_ResumeCallHandlingRes(FALSE, tvb, offset, actx, tree, -1);
1306     break;
1307   case  7: /*insertSubscriberData*/
1308     offset=dissect_gsm_map_ms_InsertSubscriberDataRes(FALSE, tvb, offset, actx, tree, -1);
1309     break;
1310   case  8: /*deleteSubscriberData*/
1311     offset=dissect_gsm_map_ms_DeleteSubscriberDataRes(FALSE, tvb, offset, actx, tree, -1);
1312     break;
1313         /* TODO find out why this isn't in the ASN1 file
1314   case  9: sendParameters
1315     offset=dissect_gsm_map_DeleteSubscriberDataArg(FALSE, tvb, offset, actx, tree, -1);
1316     break;
1317         */
1318   case  10: /*registerSS*/
1319     offset=dissect_gsm_map_ss_SS_Info(FALSE, tvb, offset, actx, tree, -1);
1320     break;
1321   case  11: /*eraseSS*/
1322     offset=dissect_gsm_map_ss_SS_Info(FALSE, tvb, offset, actx, tree, -1);
1323     break;
1324   case 12: /*activateSS*/
1325     offset=dissect_gsm_map_ss_SS_Info(FALSE, tvb, offset, actx, tree, -1);
1326     break;
1327   case 13: /*deactivateSS*/
1328     offset=dissect_gsm_map_ss_SS_Info(FALSE, tvb, offset, actx, tree, -1);
1329     break;
1330   case 14: /*interrogateSS*/
1331     offset=dissect_gsm_map_ss_InterrogateSS_Res(FALSE, tvb, offset, actx, tree, -1);
1332     break;
1333   case 15: /*authenticationFailureReport*/
1334     offset=dissect_gsm_map_ms_AuthenticationFailureReportRes(FALSE, tvb, offset, actx, tree, -1);
1335     break;
1336   case 17: /*registerPassword*/
1337     /* change hf_gsm_map_ss_Code to something with password */
1338     offset=dissect_gsm_old_NewPassword(FALSE, tvb, offset, actx, tree, hf_gsm_map_ss_Code);
1339     break;
1340   case 18: /*getPassword*/
1341     offset=dissect_gsm_old_CurrentPassword(FALSE, tvb, offset, actx, tree, hf_gsm_map_currentPassword);
1342     break;
1343   case 19: /* SS-Protocol processUnstructuredSS-Data (19) */
1344     offset=dissect_gsm_ss_SS_UserData(FALSE, tvb, offset, actx, tree, hf_gsm_map_ss_SS_UserData);
1345     break;
1346   case 20: /*releaseResources*/
1347     offset=dissect_gsm_map_ch_ReleaseResourcesRes(FALSE, tvb, offset, actx, tree, -1);
1348     break;
1349   case 21: /*mt-ForwardSM-VGCS*/
1350     offset=dissect_gsm_map_sm_MT_ForwardSM_VGCS_Res(FALSE, tvb, offset, actx, tree, -1);
1351     break;
1352   case 22: /*sendRoutingInfo*/
1353           if (application_context_version == 3){
1354                   /* If the tag is missing use SendRoutingInfoRes_U */
1355                   offset=dissect_mc_message(tvb, offset, actx, tree,
1356                               FALSE, NULL, -1,
1357                               FALSE, dissect_gsm_map_ch_SendRoutingInfoRes_U, -1,
1358                               TRUE , dissect_gsm_map_ch_SendRoutingInfoRes, -1);
1359           }else{
1360                   offset=dissect_mc_message(tvb, offset, actx, tree,
1361                               FALSE, dissect_gsm_map_IMSI, hf_gsm_map_imsi,
1362                               FALSE, dissect_gsm_old_SendRoutingInfoResV2, -1,
1363                               TRUE , dissect_gsm_map_ch_SendRoutingInfoRes, -1);
1364           }
1365     break;
1366   case 23: /*updateGprsLocation*/
1367     offset=dissect_gsm_map_ms_UpdateGprsLocationRes(FALSE, tvb, offset, actx, tree, -1);
1368     break;
1369   case 24: /*sendRoutingInfoForGprs*/
1370     offset=dissect_gsm_map_ms_SendRoutingInfoForGprsRes(FALSE, tvb, offset, actx, tree, -1);
1371     break;
1372   case 25: /*failureReport*/
1373     offset=dissect_gsm_map_ms_FailureReportRes(FALSE, tvb, offset, actx, tree, -1);
1374     break;
1375   case 26: /*noteMsPresentForGprs*/
1376     offset=dissect_gsm_map_ms_NoteMsPresentForGprsRes(FALSE, tvb, offset, actx, tree, -1);
1377     break;
1378   case 29: /*sendEndSignal*/
1379           /* Taken from MAP-MobileServiceOperations{ 0 identified-organization (4) etsi (0) mobileDomain
1380            * (0) gsm-Network (1) modules (3) map-MobileServiceOperations (5) version9 (9) }
1381            */
1382     offset=dissect_gsm_map_ms_SendEndSignal_Res(FALSE, tvb, offset, actx, tree, -1);
1383     break;
1384   case 31: /*provideSIWFSNumber*/
1385     offset=dissect_gsm_old_ProvideSIWFSNumberRes(FALSE, tvb, offset, actx, tree, -1);
1386     break;
1387   case 32: /*provideSIWFSSignallingModify*/
1388     offset=dissect_gsm_old_SIWFSSignallingModifyRes(FALSE, tvb, offset, actx, tree, -1);
1389     break;
1390   case 39: /*prepareGroupCall*/
1391     offset=dissect_gsm_map_gr_PrepareGroupCallRes(FALSE, tvb, offset, actx, tree, -1);
1392     break;
1393   case 40: /*sendGroupCallEndSignal*/
1394     offset=dissect_gsm_map_gr_SendGroupCallEndSignalRes(FALSE, tvb, offset, actx, tree, -1);
1395     break;
1396   case 43: /*checkIMEI*/
1397     offset=dissect_mc_message(tvb, offset, actx, tree,
1398                               FALSE, dissect_gsm_map_ms_EquipmentStatus, hf_gsm_map_ms_equipmentStatus,
1399                               FALSE, dissect_gsm_map_ms_CheckIMEI_Res, -1,
1400                               TRUE,  NULL, -1);
1401     break;
1402   case 44: /*mt-forwardSM*/
1403     offset=dissect_gsm_map_sm_MT_ForwardSM_Res(FALSE, tvb, offset, actx, tree, -1);
1404     break;
1405   case 45: /*sendRoutingInfoForSM*/
1406     offset=dissect_gsm_map_sm_RoutingInfoForSM_Res(FALSE, tvb, offset, actx, tree, -1);
1407     break;
1408   case 46: /*mo-forwardSM*/
1409     offset=dissect_gsm_map_sm_MO_ForwardSM_Res(FALSE, tvb, offset, actx, tree, -1);
1410     break;
1411   case 47: /*reportSM-DeliveryStatus*/
1412     offset=dissect_mc_message(tvb, offset, actx, tree,
1413                               FALSE, dissect_gsm_map_ISDN_AddressString, hf_gsm_map_sm_storedMSISDN,
1414                               FALSE, NULL, -1,
1415                               FALSE , dissect_gsm_map_sm_ReportSM_DeliveryStatusRes, -1);/*undefined*/
1416
1417     break;
1418   case 48: /*noteSubscriberPresent*/
1419     break;
1420   case 50: /*activateTraceMode*/
1421     offset=dissect_gsm_map_om_ActivateTraceModeRes(FALSE, tvb, offset, actx, tree, -1);
1422     break;
1423   case 51: /*deactivateTraceMode*/
1424     offset=dissect_gsm_map_om_DeactivateTraceModeRes(FALSE, tvb, offset, actx, tree, -1);
1425     break;
1426   case 55: /*sendIdentification */
1427     offset=dissect_mc_message(tvb, offset, actx, tree,
1428                               FALSE, dissect_gsm_map_IMSI, hf_gsm_map_imsi,
1429                               FALSE, dissect_gsm_old_SendIdentificationResV2, -1,/*undefined*/
1430                               TRUE,  dissect_gsm_map_ms_SendIdentificationRes, -1);
1431     break;
1432   case 56: /*sendAuthenticationInfo*/
1433     offset=dissect_mc_message(tvb, offset, actx, tree,
1434                               FALSE, NULL, -1,
1435                               FALSE, dissect_gsm_old_SendAuthenticationInfoResOld, -1,
1436                               TRUE , dissect_gsm_map_ms_SendAuthenticationInfoRes, -1);
1437     break;
1438   case 57: /*restoreData*/
1439     offset=dissect_gsm_map_ms_RestoreDataRes(FALSE, tvb, offset, actx, tree, -1);
1440     break;
1441   case 58: /*sendIMSI*/
1442     offset=dissect_gsm_map_IMSI(FALSE, tvb, offset, actx, tree, hf_gsm_map_ms_imsi);
1443     break;
1444   case 59: /*unstructuredSS-Request*/
1445     offset=dissect_gsm_map_ss_USSD_Res(FALSE, tvb, offset, actx, tree, -1);
1446     break;
1447   case 60: /*unstructuredSS-Request*/
1448     offset=dissect_gsm_map_ss_USSD_Res(FALSE, tvb, offset, actx, tree, -1);
1449     break;
1450   case 61: /*unstructuredSS-Notify*/
1451     /* TRUE ? */
1452     proto_tree_add_text(tree, tvb, offset, -1, "Unknown returnResultData blob");
1453     break;
1454   case 62: /*AnyTimeSubscriptionInterrogation*/
1455     offset=dissect_gsm_map_ms_AnyTimeSubscriptionInterrogationRes(FALSE, tvb, offset, actx, tree, -1);
1456     break;
1457   case 64: /*alertServiceCentre*/
1458     /* TRUE */
1459     break;
1460   case 65: /*AnyTimeModification*/
1461     offset=dissect_gsm_map_ms_AnyTimeModificationRes(FALSE, tvb, offset, actx, tree, -1);
1462     break;
1463   case 66: /*readyForSM*/
1464     offset=dissect_gsm_map_sm_ReadyForSM_Res(FALSE, tvb, offset, actx, tree, -1);
1465     break;
1466   case 67: /*purgeMS*/
1467     offset=dissect_gsm_map_ms_PurgeMS_Res(FALSE, tvb, offset, actx, tree, -1);
1468     break;
1469   case 68: /*prepareHandover*/
1470     offset=dissect_mc_message(tvb, offset, actx, tree,
1471                               FALSE, NULL, -1,
1472                               FALSE, dissect_gsm_old_PrepareHO_ResOld, -1,
1473                               TRUE , dissect_gsm_map_ms_PrepareHO_Res, -1);
1474     break;
1475   case 69: /*prepareSubsequentHandover*/
1476     offset=dissect_mc_message(tvb, offset, actx, tree,
1477                               FALSE, NULL, -1,
1478                               FALSE, NULL, -1,
1479                               TRUE , dissect_gsm_map_ms_PrepareSubsequentHO_Res, -1);
1480     break;
1481   case 70: /*provideSubscriberInfo*/
1482     offset=dissect_gsm_map_ms_ProvideSubscriberInfoRes(FALSE, tvb, offset, actx, tree, -1);
1483     break;
1484   case 71: /*anyTimeInterrogation*/
1485     offset=dissect_gsm_map_ms_AnyTimeInterrogationRes(FALSE, tvb, offset, actx, tree, -1);
1486     break;
1487   case 72: /*ss-InvocationNotificatio*/
1488     offset=dissect_gsm_map_ss_SS_InvocationNotificationRes(FALSE, tvb, offset, actx, tree, -1);
1489     break;
1490   case 73: /*setReportingState*/
1491     offset=dissect_gsm_map_ch_SetReportingStateRes(FALSE, tvb, offset, actx, tree, -1);
1492     break;
1493   case 74: /*statusReport*/
1494     offset=dissect_gsm_map_ch_StatusReportRes(FALSE, tvb, offset, actx, tree, -1);
1495     break;
1496   case 75: /*remoteUserFree*/
1497     offset=dissect_gsm_map_ch_RemoteUserFreeRes(FALSE, tvb, offset, actx, tree, -1);
1498     break;
1499   case 76: /*registerCC-Entry*/
1500     offset=dissect_gsm_map_ss_RegisterCC_EntryRes(FALSE, tvb, offset, actx, tree, -1);
1501     break;
1502   case 77: /*eraseCC-Entry*/
1503     offset=dissect_gsm_map_ss_EraseCC_EntryRes(FALSE, tvb, offset, actx, tree, -1);
1504     break;
1505   case 78: /*secureTransportClass1*/
1506   case 79: /*secureTransportClass2*/
1507   case 80: /*secureTransportClass3*/
1508   case 81: /*secureTransportClass4*/
1509     offset=dissect_gsm_old_SecureTransportRes(FALSE, tvb, offset, actx, tree, -1);
1510     break;
1511   case 83: /*provideSubscriberLocation*/
1512     offset=dissect_gsm_map_lcs_ProvideSubscriberLocation_Res(FALSE, tvb, offset, actx, tree, -1);
1513     break;
1514   case 84: /*sendGroupCallInfo*/
1515     offset=dissect_gsm_map_gr_SendGroupCallInfoRes(FALSE, tvb, offset, actx, tree, -1);
1516     break;
1517   case 85: /*sendRoutingInfoForLCS*/
1518     offset=dissect_gsm_map_lcs_RoutingInfoForLCS_Res(FALSE, tvb, offset, actx, tree, -1);
1519     break;
1520   case 86: /*subscriberLocationReport*/
1521     offset=dissect_gsm_map_lcs_SubscriberLocationReport_Res(FALSE, tvb, offset, actx, tree, -1);
1522     break;
1523   case 87: /*ist-Alert*/
1524     offset=dissect_gsm_map_ch_IST_AlertRes(FALSE, tvb, offset, actx, tree, -1);
1525     break;
1526   case 88: /*ist-Command*/
1527     offset=dissect_gsm_map_ch_IST_CommandRes(FALSE, tvb, offset, actx, tree, -1);
1528     break;
1529   case 89: /*noteMM-Event*/
1530     offset=dissect_gsm_map_ms_NoteMM_EventRes(FALSE, tvb, offset, actx, tree, -1);
1531     break;
1532   case 109: /*SS-protocol lcs-PeriodicLocationCancellation*/
1533           /* No parameter */
1534     break;
1535   case 110: /*SS-protocol lcs-LocationUpdate*/
1536           offset=dissect_gsm_ss_LCS_LocationUpdateRes(FALSE, tvb, offset, actx, tree, -1);
1537     break;
1538   case 111: /*SS-protocol lcs-PeriodicLocationRequest*/
1539     offset=dissect_gsm_ss_LCS_PeriodicLocationRequestRes(FALSE, tvb, offset, actx, tree, -1);
1540     break;
1541   case 112: /*SS-protocol lcs-AreaEventCancellation*/
1542     break;
1543   case 113: /*SS-protocol lcs-AreaEventReport*/
1544     break;
1545   case 114: /*SS-protocol lcs-AreaEventRequest No RESULT data*/
1546     break;
1547   case 115: /*SS-protocol lcs-MOLR*/
1548     offset=dissect_gsm_ss_LCS_MOLRRes(FALSE, tvb, offset, actx, tree, -1);
1549     break;
1550   case 116: /*SS-protocol lcs-LocationNotification*/
1551     offset=dissect_gsm_ss_LocationNotificationRes(FALSE, tvb, offset, actx, tree, -1);
1552     break;
1553   case 117: /*SS-protocol callDeflection no RESULT*/
1554     break;
1555   case 118: /*SS-protocol userUserService no RESULT*/
1556     break;
1557   case 119: /*SS-protocol accessRegisterCCEntry*/
1558     offset=dissect_gsm_map_ss_RegisterCC_EntryRes(FALSE, tvb, offset, actx, tree, -1);
1559     break;
1560   case 120: /*SS-protocol forwardCUG-Info*/
1561           /* No RETURN RESULT*/
1562     break;
1563   case 121: /*SS-protocol splitMPTY no RESULT*/
1564     break;
1565   case 122: /*SS-protocol retrieveMPTY no RESULT*/
1566     break;
1567   case 123: /*SS-protocol holdMPTY no RESULT*/
1568     break;
1569   case 124: /*SS-protocol buildMPTY no RESULT*/
1570     break;
1571   case 125: /*SS-protocol forwardChargeAdvice no RESULT*/
1572     break;
1573   case 126: /*SS-protocol explicitCT no RESULT*/
1574     break;
1575
1576  default:
1577    if(!dissector_try_uint(map_prop_res_opcode_table, (guint8)opcode, tvb, actx->pinfo, tree)){
1578        cause=proto_tree_add_text(tree, tvb, offset, -1, "Unknown returnResultData blob");
1579        proto_item_set_expert_flags(cause, PI_MALFORMED, PI_WARN);
1580        expert_add_info_format(actx->pinfo, cause, PI_MALFORMED, PI_WARN, "Unknown invokeData %d",opcode);
1581    }
1582    offset+= tvb_length_remaining(tvb,offset);
1583    break;
1584   }
1585   return offset;
1586 }
1587
1588
1589
1590 static int dissect_returnErrorData(proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *actx) {
1591   proto_item *cause;
1592
1593   switch(errorCode){
1594   case 1: /* UnknownSubscriberParam */
1595           offset=dissect_gsm_map_er_UnknownSubscriberParam(FALSE, tvb, offset, actx, tree, -1);
1596           break;
1597   case 4: /* SecureTransportErrorParam */
1598           offset=dissect_gsm_old_SecureTransportErrorParam(FALSE, tvb, offset, actx, tree, -1);
1599           break;
1600   case 5: /* UnidentifiedSubParam */
1601           offset=dissect_gsm_map_er_UnidentifiedSubParam(FALSE, tvb, offset, actx, tree, -1);
1602           break;
1603   case 6: /* AbsentSubscriberSM-Param */
1604           offset=dissect_gsm_map_er_AbsentSubscriberSM_Param(FALSE, tvb, offset, actx, tree, -1);
1605           break;
1606   case 8: /* RoamingNotAllowedParam */
1607           offset=dissect_gsm_map_er_RoamingNotAllowedParam(FALSE, tvb, offset, actx, tree, -1);
1608           break;
1609   case 9: /* IllegalSubscriberParam */
1610           offset=dissect_gsm_map_er_IllegalSubscriberParam(FALSE, tvb, offset, actx, tree, -1);
1611           break;
1612   case 10: /* BearerServNotProvParam */
1613           offset=dissect_gsm_map_er_BearerServNotProvParam(FALSE, tvb, offset, actx, tree, -1);
1614           break;
1615   case 11: /* TeleservNotProvParam */
1616           offset=dissect_gsm_map_er_TeleservNotProvParam(FALSE, tvb, offset, actx, tree, -1);
1617           break;
1618   case 12: /* IllegalEquipmentParam */
1619           offset=dissect_gsm_map_er_IllegalEquipmentParam(FALSE, tvb, offset, actx, tree, -1);
1620           break;
1621   case 13: /* CallBarredParam */
1622           offset=dissect_gsm_map_er_CallBarredParam(FALSE, tvb, offset, actx, tree, -1);
1623           break;
1624   case 14: /* ForwardingViolationParam */
1625           offset=dissect_gsm_map_er_ForwardingViolationParam(FALSE, tvb, offset, actx, tree, -1);
1626           break;
1627   case 15: /* CUG-RejectParam */
1628           offset=dissect_gsm_map_er_CUG_RejectParam(FALSE, tvb, offset, actx, tree, -1);
1629           break;
1630   case 16: /* IllegalSS-OperationParam */
1631           offset=dissect_gsm_map_er_IllegalSS_OperationParam(FALSE, tvb, offset, actx, tree, -1);
1632           break;
1633   case 17: /* SS-ErrorStatus */
1634           offset=dissect_gsm_map_ss_SS_Status(FALSE, tvb, offset, actx, tree, hf_gsm_map_ss_ss_Status);
1635           break;
1636   case 18: /* SS-NotAvailableParam */
1637           offset=dissect_gsm_map_er_SS_NotAvailableParam(FALSE, tvb, offset, actx, tree, -1);
1638           break;
1639   case 19: /* SS-SubscriptionViolationParam */
1640           offset=dissect_gsm_map_er_SS_SubscriptionViolationParam(FALSE, tvb, offset, actx, tree, -1);
1641           break;
1642   case 20: /* SS-IncompatibilityCause */
1643           offset=dissect_gsm_map_er_SS_IncompatibilityCause(FALSE, tvb, offset, actx, tree, -1);
1644           break;
1645   case 21: /* FacilityNotSupParam */
1646           offset=dissect_gsm_map_er_FacilityNotSupParam(FALSE, tvb, offset, actx, tree, -1);
1647           break;
1648   case 22: /* OngoingGroupCallParam */
1649       offset=dissect_gsm_map_er_OngoingGroupCallParam(FALSE, tvb, offset, actx, tree, -1);
1650       break;
1651   case 27: /* AbsentSubscriberParam */
1652           offset=dissect_gsm_map_er_AbsentSubscriberParam(FALSE, tvb, offset, actx, tree, -1);
1653           break;
1654   case 28: /* IncompatibleTerminalParam */
1655           offset=dissect_gsm_map_er_IncompatibleTerminalParam(FALSE, tvb, offset, actx, tree, -1);
1656           break;
1657   case 29: /* ShortTermDenialParam */
1658           offset=dissect_gsm_map_er_ShortTermDenialParam(FALSE, tvb, offset, actx, tree, -1);
1659           break;
1660   case 30: /* LongTermDenialParam */
1661           offset=dissect_gsm_map_er_LongTermDenialParam(FALSE, tvb, offset, actx, tree, -1);
1662           break;
1663   case 31: /* SubBusyForMT-SMS-Param */
1664           offset=dissect_gsm_map_er_SubBusyForMT_SMS_Param(FALSE, tvb, offset, actx, tree, -1);
1665           break;
1666   case 32: /* SM-DeliveryFailureCause */
1667           offset=dissect_gsm_map_er_SM_DeliveryFailureCause(FALSE, tvb, offset, actx, tree, -1);
1668           break;
1669   case 33: /* MessageWaitListFullParam */
1670           offset=dissect_gsm_map_er_MessageWaitListFullParam(FALSE, tvb, offset, actx, tree, -1);
1671           break;
1672   case 34: /* SystemFailureParam */
1673           offset=dissect_gsm_map_er_SystemFailureParam(FALSE, tvb, offset, actx, tree, -1);
1674           break;
1675   case 35: /* DataMissingParam */
1676           offset=dissect_gsm_map_er_DataMissingParam(FALSE, tvb, offset, actx, tree, -1);
1677           break;
1678   case 36: /* UnexpectedDataParam */
1679           offset=dissect_gsm_map_er_UnexpectedDataParam(FALSE, tvb, offset, actx, tree, -1);
1680           break;
1681   case 37: /* PW-RegistrationFailureCause */
1682           offset=dissect_gsm_map_er_PW_RegistrationFailureCause(FALSE, tvb, offset, actx, tree, -1);
1683           break;
1684   case 39: /* NoRoamingNbParam */
1685           offset=dissect_gsm_map_er_NoRoamingNbParam(FALSE, tvb, offset, actx, tree, -1);
1686           break;
1687   case 40: /* TracingBufferFullParam */
1688           offset=dissect_gsm_map_er_TracingBufferFullParam(FALSE, tvb, offset, actx, tree, -1);
1689           break;
1690   case 42: /* TargetCellOutsideGCA-Param */
1691           offset=dissect_gsm_map_er_TargetCellOutsideGCA_Param(FALSE, tvb, offset, actx, tree, -1);
1692           break;
1693   case 44: /* NumberChangedParam */
1694           offset=dissect_gsm_map_er_NumberChangedParam(FALSE, tvb, offset, actx, tree, -1);
1695           break;
1696   case 45: /* BusySubscriberParam */
1697           offset=dissect_gsm_map_er_BusySubscriberParam(FALSE, tvb, offset, actx, tree, -1);
1698           break;
1699   case 46: /* NoSubscriberReplyParam */
1700           offset=dissect_gsm_map_er_NoSubscriberReplyParam(FALSE, tvb, offset, actx, tree, -1);
1701           break;
1702   case 47: /* ForwardingFailedParam */
1703           offset=dissect_gsm_map_er_ForwardingFailedParam(FALSE, tvb, offset, actx, tree, -1);
1704           break;
1705   case 48: /* OR-NotAllowedParam */
1706           offset=dissect_gsm_map_er_OR_NotAllowedParam(FALSE, tvb, offset, actx, tree, -1);
1707           break;
1708   case 49: /* ATI-NotAllowedParam */
1709           offset=dissect_gsm_map_er_ATI_NotAllowedParam(FALSE, tvb, offset, actx, tree, -1);
1710           break;
1711   case 50: /* NoGroupCallNbParam */
1712           offset=dissect_gsm_map_er_NoGroupCallNbParam(FALSE, tvb, offset, actx, tree, -1);
1713           break;
1714   case 51: /* ResourceLimitationParam */
1715           offset=dissect_gsm_map_er_ResourceLimitationParam(FALSE, tvb, offset, actx, tree, -1);
1716           break;
1717   case 52: /* UnauthorizedRequestingNetwork-Param */
1718           offset=dissect_gsm_map_er_UnauthorizedRequestingNetwork_Param(FALSE, tvb, offset, actx, tree, -1);
1719           break;
1720   case 53: /* UnauthorizedLCSClient-Param */
1721           offset=dissect_gsm_map_er_UnauthorizedLCSClient_Param(FALSE, tvb, offset, actx, tree, -1);
1722           break;
1723   case 54: /* PositionMethodFailure-Param */
1724           offset=dissect_gsm_map_er_PositionMethodFailure_Param(FALSE, tvb, offset, actx, tree, -1);
1725           break;
1726   case 58: /* UnknownOrUnreachableLCSClient-Param */
1727           offset=dissect_gsm_map_er_UnknownOrUnreachableLCSClient_Param(FALSE, tvb, offset, actx, tree, -1);
1728           break;
1729   case 59: /* MM-EventNotSupported-Param */
1730           offset=dissect_gsm_map_er_MM_EventNotSupported_Param(FALSE, tvb, offset, actx, tree, -1);
1731           break;
1732   case 60: /* ATSI-NotAllowedParam */
1733           offset=dissect_gsm_map_er_ATSI_NotAllowedParam(FALSE, tvb, offset, actx, tree, -1);
1734           break;
1735   case 61: /* ATM-NotAllowedParam */
1736           offset=dissect_gsm_map_er_ATM_NotAllowedParam(FALSE, tvb, offset, actx, tree, -1);
1737           break;
1738   case 62: /* InformationNotAvailableParam */
1739           offset=dissect_gsm_map_er_InformationNotAvailableParam(FALSE, tvb, offset, actx, tree, -1);
1740           break;
1741   default:
1742     if(!dissector_try_uint(map_prop_err_opcode_table, (guint8)opcode, tvb, actx->pinfo, tree)){
1743         cause=proto_tree_add_text(tree, tvb, offset, -1, "Unknown returnErrorData blob");
1744         proto_item_set_expert_flags(cause, PI_MALFORMED, PI_WARN);
1745         expert_add_info_format(actx->pinfo, cause, PI_MALFORMED, PI_WARN, "Unknown invokeData %d",errorCode);
1746     }
1747         offset+= tvb_length_remaining(tvb,offset);
1748     break;
1749   }
1750   return offset;
1751 }
1752
1753 /* Private extension container for PLMN Data */
1754 static void dissect_gsm_mapext_PlmnContainer(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) {
1755   proto_item    *item=NULL;
1756   proto_tree    *tree=NULL;
1757   asn1_ctx_t asn1_ctx;
1758   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
1759   /* create display subtree for the protocol */
1760   if(parent_tree){
1761     item = proto_tree_add_text(parent_tree, tvb, 0, -1, "MAP Ext. Plmn Container");
1762     tree = proto_item_add_subtree(item, ett_gsm_old_PlmnContainer_U);
1763   }
1764   dissect_gsm_old_PlmnContainer(FALSE, tvb, 0, &asn1_ctx, tree, -1);
1765 }
1766
1767
1768 static guint8 gsmmap_pdu_type = 0;
1769 static guint8 gsm_map_pdu_size = 0;
1770
1771 static int
1772 dissect_gsm_map_GSMMAPPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index _U_) {
1773
1774   char *version_ptr;
1775   struct tcap_private_t * p_private_tcap;
1776
1777   opcode = 0;
1778   application_context_version = 0;
1779   if (actx->pinfo->private_data != NULL){
1780     p_private_tcap=actx->pinfo->private_data;
1781     if (p_private_tcap->acv==TRUE ){
1782       version_ptr = strrchr(p_private_tcap->oid,'.');
1783       if (version_ptr){
1784                   application_context_version = atoi(version_ptr+1);
1785           }
1786     }
1787   }
1788
1789   gsmmap_pdu_type = tvb_get_guint8(tvb, offset)&0x0f;
1790   /* Get the length and add 2 */
1791   gsm_map_pdu_size = tvb_get_guint8(tvb, offset+1)+2;
1792
1793   col_add_str(actx->pinfo->cinfo, COL_INFO, val_to_str_const(gsmmap_pdu_type, gsm_old_Component_vals, "Unknown GSM-MAP Component"));
1794   col_append_fstr(actx->pinfo->cinfo, COL_INFO, " ");
1795   offset = dissect_gsm_old_Component(FALSE, tvb, 0, actx, tree, hf_gsm_map_old_Component_PDU);
1796 /*
1797   offset = dissect_ber_choice(pinfo, tree, tvb, offset,
1798                               GSMMAPPDU_choice, hf_index, ett_gsm_map_GSMMAPPDU, NULL);
1799 */
1800
1801   return offset;
1802 }
1803
1804 static void
1805 dissect_gsm_map(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
1806 {
1807     proto_item          *item=NULL;
1808     proto_tree          *tree=NULL;
1809     /* Used for gsm_map TAP */
1810     static              gsm_map_tap_rec_t tap_rec;
1811     gint                op_idx;
1812         asn1_ctx_t asn1_ctx;
1813
1814         asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
1815
1816     col_set_str(pinfo->cinfo, COL_PROTOCOL, "GSM MAP");
1817
1818     top_tree = parent_tree;
1819
1820     /* create display subtree for the protocol */
1821     if(parent_tree){
1822         item = proto_tree_add_item(parent_tree, proto_gsm_map, tvb, 0, -1, FALSE);
1823         tree = proto_item_add_subtree(item, ett_gsm_map);
1824     }
1825
1826     dissect_gsm_map_GSMMAPPDU(FALSE, tvb, 0, &asn1_ctx, tree, -1);
1827     match_strval_idx(opcode, gsm_map_opr_code_strings, &op_idx);
1828
1829     tap_rec.invoke = FALSE;
1830     if ( gsmmap_pdu_type  == 1 )
1831         tap_rec.invoke = TRUE;
1832     tap_rec.opr_code_idx = op_idx;
1833     tap_rec.size = gsm_map_pdu_size;
1834
1835     tap_queue_packet(gsm_map_tap, pinfo, &tap_rec);
1836 }
1837
1838 const value_string ssCode_vals[] = {
1839   { 0x00, "allSS - all SS" },
1840   { 0x10 ,"allLineIdentificationSS - all line identification SS" },
1841   { 0x11 ,"clip - calling line identification presentation" },
1842   { 0x12 ,"clir - calling line identification restriction" },
1843   { 0x13 ,"colp - connected line identification presentation" },
1844   { 0x14 ,"colr - connected line identification restriction" },
1845   { 0x15 ,"mci - malicious call identification" },
1846   { 0x18 ,"allNameIdentificationSS - all name identification SS" },
1847   { 0x19 ,"cnap - calling name presentation" },
1848   { 0x20 ,"allForwardingSS - all forwarding SS" },
1849   { 0x21 ,"cfu - call forwarding unconditional" },
1850   { 0x28 ,"allCondForwardingSS - all conditional forwarding SS" },
1851   { 0x29 ,"cfb - call forwarding busy" },
1852   { 0x2a ,"cfnry - call forwarding on no reply" },
1853   { 0x2b ,"cfnrc - call forwarding on mobile subscriber not reachable" },
1854   { 0x24 ,"cd - call deflection" },
1855   { 0x30 ,"allCallOfferingSS - all call offering SS includes also all forwarding SS" },
1856   { 0x31 ,"ect - explicit call transfer" },
1857   { 0x32 ,"mah - mobile access hunting" },
1858   { 0x40 ,"allCallCompletionSS - all Call completion SS" },
1859   { 0x41 ,"cw - call waiting" },
1860   { 0x42 ,"hold - call hold" },
1861   { 0x43 ,"ccbs-A - completion of call to busy subscribers, originating side" },
1862   { 0x44 ,"ccbs-B - completion of call to busy subscribers, destination side" },
1863   { 0x45 ,"mc - multicall" },
1864   { 0x50 ,"allMultiPartySS - all multiparty SS" },
1865   { 0x51 ,"multiPTY - multiparty" },
1866   { 0x60 ,"allCommunityOfInterestSS - all community of interest SS" },
1867   { 0x61 ,"cug - closed user group" },
1868   { 0x70 ,"allChargingSS - all charging SS" },
1869   { 0x71 ,"aoci - advice of charge information" },
1870   { 0x72 ,"aocc - advice of charge charging" },
1871   { 0x80 ,"allAdditionalInfoTransferSS - all additional information transfer SS" },
1872   { 0x81 ,"uus1 - UUS1 user-to-user signalling" },
1873   { 0x82 ,"uus2 - UUS2 user-to-user signalling" },
1874   { 0x83 ,"uus3 - UUS3 user-to-user signalling" },
1875   { 0x90 ,"allCallRestrictionSS - all Callrestriction SS" },
1876   { 0x91 ,"barringOfOutgoingCalls" },
1877   { 0x92 ,"baoc - barring of all outgoing calls" },
1878   { 0x93 ,"boic - barring of outgoing international calls" },
1879   { 0x94 ,"boicExHC - barring of outgoing international calls except those directed to the home PLMN" },
1880   { 0x99 ,"barringOfIncomingCalls" },
1881   { 0x9a ,"baic - barring of all incoming calls" },
1882   { 0x9b ,"bicRoam - barring of incoming calls when roaming outside home PLMN Country" },
1883   { 0xf0 ,"allPLMN-specificSS" },
1884   { 0xa0 ,"allCallPrioritySS - all call priority SS" },
1885   { 0xa1 ,"emlpp - enhanced Multilevel Precedence Pre-emption (EMLPP) service" },
1886   { 0xb0 ,"allLCSPrivacyException - all LCS Privacy Exception Classes" },
1887   { 0xb1 ,"universal - allow location by any LCS client" },
1888   { 0xb2 ,"callrelated - allow location by any value added LCS client to which a call is established from the target MS" },
1889   { 0xb3 ,"callunrelated - allow location by designated external value added LCS clients" },
1890   { 0xb4 ,"plmnoperator - allow location by designated PLMN operator LCS clients" },
1891   { 0xb5 ,"serviceType - allow location by LCS clients of a designated LCS service type" },
1892   { 0xc0 ,"allMOLR-SS - all Mobile Originating Location Request Classes" },
1893   { 0xc1 ,"basicSelfLocation - allow an MS to request its own location" },
1894   { 0xc2 ,"autonomousSelfLocation - allow an MS to perform self location without interaction with the PLMN for a predetermined period of time" },
1895   { 0xc3 ,"transferToThirdParty - allow an MS to request transfer of its location to another LCS client" },
1896
1897   { 0xf1 ,"plmn-specificSS-1" },
1898   { 0xf2 ,"plmn-specificSS-2" },
1899   { 0xf3 ,"plmn-specificSS-3" },
1900   { 0xf4 ,"plmn-specificSS-4" },
1901   { 0xf5 ,"plmn-specificSS-5" },
1902   { 0xf6 ,"plmn-specificSS-6" },
1903   { 0xf7 ,"plmn-specificSS-7" },
1904   { 0xf8 ,"plmn-specificSS-8" },
1905   { 0xf9 ,"plmn-specificSS-9" },
1906   { 0xfa ,"plmn-specificSS-a" },
1907   { 0xfb ,"plmn-specificSS-b" },
1908   { 0xfc ,"plmn-specificSS-c" },
1909   { 0xfd ,"plmn-specificSS-d" },
1910   { 0xfe ,"plmn-specificSS-e" },
1911   { 0xff ,"plmn-specificSS-f" },
1912   { 0, NULL }
1913 };
1914
1915 static const value_string Teleservice_vals[] = {
1916 {0x00, "allTeleservices" },
1917 {0x10, "allSpeechTransmissionServices" },
1918 {0x11, "telephony" },
1919 {0x12, "emergencyCalls" },
1920 {0x20, "allShortMessageServices" },
1921 {0x21, "shortMessageMT-PP" },
1922 {0x22, "shortMessageMO-PP" },
1923 {0x60, "allFacsimileTransmissionServices" },
1924 {0x61, "facsimileGroup3AndAlterSpeech" },
1925 {0x62, "automaticFacsimileGroup3" },
1926 {0x63, "facsimileGroup4" },
1927
1928 {0x70, "allDataTeleservices" },
1929 {0x80, "allTeleservices-ExeptSMS" },
1930
1931 {0x90, "allVoiceGroupCallServices" },
1932 {0x91, "voiceGroupCall" },
1933 {0x92, "voiceBroadcastCall" },
1934
1935 {0xd0, "allPLMN-specificTS" },
1936 {0xd1, "plmn-specificTS-1" },
1937 {0xd2, "plmn-specificTS-2" },
1938 {0xd3, "plmn-specificTS-3" },
1939 {0xd4, "plmn-specificTS-4" },
1940 {0xd5, "plmn-specificTS-5" },
1941 {0xd6, "plmn-specificTS-6" },
1942 {0xd7, "plmn-specificTS-7" },
1943 {0xd8, "plmn-specificTS-8" },
1944 {0xd9, "plmn-specificTS-9" },
1945 {0xda, "plmn-specificTS-A" },
1946 {0xdb, "plmn-specificTS-B" },
1947 {0xdc, "plmn-specificTS-C" },
1948 {0xdd, "plmn-specificTS-D" },
1949 {0xde, "plmn-specificTS-E" },
1950 {0xdf, "plmn-specificTS-F" },
1951   { 0, NULL }
1952 };
1953
1954 static const value_string Bearerservice_vals[] = {
1955 {0x00, "allBearerServices" },
1956 {0x10, "allDataCDA-Services" },
1957 {0x11, "dataCDA-300bps" },
1958 {0x12, "dataCDA-1200bps" },
1959 {0x13, "dataCDA-1200-75bps" },
1960 {0x14, "dataCDA-2400bps" },
1961 {0x15, "dataCDA-4800bps" },
1962 {0x16, "dataCDA-9600bps" },
1963 {0x17, "general-dataCDA" },
1964
1965 {0x18, "allDataCDS-Services" },
1966 {0x1A, "dataCDS-1200bps" },
1967 {0x1C, "dataCDS-2400bps" },
1968 {0x1D, "dataCDS-4800bps" },
1969 {0x1E, "dataCDS-9600bps" },
1970 {0x1F, "general-dataCDS" },
1971
1972 {0x20, "allPadAccessCA-Services" },
1973 {0x21, "padAccessCA-300bps" },
1974 {0x22, "padAccessCA-1200bps" },
1975 {0x23, "padAccessCA-1200-75bps" },
1976 {0x24, "padAccessCA-2400bps" },
1977 {0x25, "padAccessCA-4800bps" },
1978 {0x26, "padAccessCA-9600bps" },
1979 {0x27, "general-padAccessCA" },
1980
1981 {0x28, "allDataPDS-Services" },
1982 {0x2C, "dataPDS-2400bps" },
1983 {0x2D, "dataPDS-4800bps" },
1984 {0x2E, "dataPDS-9600bps" },
1985 {0x2F, "general-dataPDS" },
1986
1987 {0x30, "allAlternateSpeech-DataCDA" },
1988 {0x38, "allAlternateSpeech-DataCDS" },
1989 {0x40, "allSpeechFollowedByDataCDA" },
1990 {0x48, "allSpeechFollowedByDataCDS" },
1991
1992 {0x50, "allDataCircuitAsynchronous" },
1993 {0x60, "allAsynchronousServices" },
1994 {0x58, "allDataCircuitSynchronous" },
1995 {0x68, "allSynchronousServices" },
1996
1997 {0xD0, "allPLMN-specificBS" },
1998 {0xD1, "plmn-specificBS-1" },
1999 {0xD2, "plmn-specificBS-2" },
2000 {0xD3, "plmn-specificBS-3" },
2001 {0xD4, "plmn-specificBS-4" },
2002 {0xD5, "plmn-specificBS-5" },
2003 {0xD6, "plmn-specificBS-6" },
2004 {0xD7, "plmn-specificBS-7" },
2005 {0xD8, "plmn-specificBS-8" },
2006 {0xD9, "plmn-specificBS-9" },
2007 {0xDA, "plmn-specificBS-A" },
2008 {0xDB, "plmn-specificBS-B" },
2009 {0xDC, "plmn-specificBS-C" },
2010 {0xDD, "plmn-specificBS-D" },
2011 {0xDE, "plmn-specificBS-E" },
2012 {0xDF, "plmn-specificBS-F" },
2013
2014 { 0, NULL }
2015 };
2016
2017 /* ForwardingOptions
2018
2019 -- bit 8: notification to forwarding party
2020 -- 0 no notification
2021 -- 1 notification
2022 */
2023 static const true_false_string notification_value  = {
2024   "Notification",
2025   "No notification"
2026 };
2027 /*
2028 -- bit 7: redirecting presentation
2029 -- 0 no presentation
2030 -- 1 presentation
2031 */
2032 static const true_false_string redirecting_presentation_value  = {
2033   "Presentation",
2034   "No presentationn"
2035 };
2036 /*
2037 -- bit 6: notification to calling party
2038 -- 0 no notification
2039 -- 1 notification
2040 */
2041 /*
2042 -- bit 5: 0 (unused)
2043 -- bits 43: forwarding reason
2044 -- 00 ms not reachable
2045 -- 01 ms busy
2046 -- 10 no reply
2047 -- 11 unconditional when used in a SRI Result,
2048 -- or call deflection when used in a RCH Argument
2049 */
2050 static const value_string forwarding_reason_values[] = {
2051 {0x0, "ms not reachable" },
2052 {0x1, "ms busy" },
2053 {0x2, "no reply" },
2054 {0x3, "unconditional when used in a SRI Result or call deflection when used in a RCH Argument" },
2055 { 0, NULL }
2056 };
2057 /*
2058 -- bits 21: 00 (unused)
2059 */
2060
2061 static const value_string pdp_type_org_values[] = {
2062 {0x0, "ETSI" },
2063 {0x1, "IETF" },
2064 {0xf, "Empty PDP type" },
2065 { 0, NULL }
2066 };
2067
2068 static const value_string etsi_pdp_type_number_values[] = {
2069 {0x0, "Reserved, used in earlier version of this protocol" },
2070 {0x1, "PPP" },
2071 { 0, NULL }
2072 };
2073
2074 static const value_string ietf_pdp_type_number_values[] = {
2075 {0x21, "IPv4 Address" },
2076 {0x57, "IPv6 Address" },
2077 { 0, NULL }
2078 };
2079
2080 /*
2081 ChargingCharacteristics ::= OCTET STRING (SIZE (2))
2082 -- Octets are coded according to 3GPP TS 32.015.
2083 -- From 3GPP TS 32.015.
2084 --
2085 -- Descriptions for the bits of the flag set:
2086 --
2087 -- Bit 1: H (Hot billing) := '00000001'B
2088 -- Bit 2: F (Flat rate) := '00000010'B
2089 -- Bit 3: P (Prepaid service) := '00000100'B
2090 -- Bit 4: N (Normal billing) := '00001000'B
2091 -- Bit 5: - (Reserved, set to 0) := '00010000'B
2092 -- Bit 6: - (Reserved, set to 0) := '00100000'B
2093 -- Bit 7: - (Reserved, set to 0) := '01000000'B
2094 -- Bit 8: - (Reserved, set to 0) := '10000000'B
2095 */
2096 static const value_string chargingcharacteristics_values[] = {
2097 {0x1, "H (Hot billing)" },
2098 {0x2, "F (Flat rate)" },
2099 {0x4, "P (Prepaid service)" },
2100 {0x8, "N (Normal billing)" },
2101 { 0, NULL }
2102 };
2103
2104 /*--- proto_reg_handoff_gsm_map ---------------------------------------*/
2105 static void range_delete_callback(guint32 ssn)
2106 {
2107     if (ssn) {
2108         delete_itu_tcap_subdissector(ssn, map_handle);
2109     }
2110 }
2111
2112 static void range_add_callback(guint32 ssn)
2113 {
2114     if (ssn) {
2115         add_itu_tcap_subdissector(ssn, map_handle);
2116     }
2117 }
2118
2119 void proto_reg_handoff_gsm_map(void) {
2120
2121     static gboolean map_prefs_initialized = FALSE;
2122     static range_t *ssn_range;
2123
2124     if (!map_prefs_initialized) {
2125         map_prefs_initialized = TRUE;
2126         data_handle = find_dissector("data");
2127         ranap_handle = find_dissector("ranap");
2128         dtap_handle = find_dissector("gsm_a_dtap");
2129
2130         map_handle = find_dissector("gsm_map");
2131         register_ber_oid_dissector_handle("0.4.0.0.1.0.1.3", map_handle, proto_gsm_map,"networkLocUpContext-v3");
2132         register_ber_oid_dissector_handle("0.4.0.0.1.0.1.2", map_handle, proto_gsm_map,"networkLocUpContext-v2" );
2133         register_ber_oid_dissector_handle("0.4.0.0.1.0.1.1", map_handle, proto_gsm_map,"networkLocUpContext-v1" );
2134         register_ber_oid_dissector_handle("0.4.0.0.1.0.2.3", map_handle, proto_gsm_map,"locationCancellationContext-v3" );
2135         register_ber_oid_dissector_handle("0.4.0.0.1.0.2.2", map_handle, proto_gsm_map,"locationCancellationContext-v2" );
2136         register_ber_oid_dissector_handle("0.4.0.0.1.0.2.1", map_handle, proto_gsm_map,"locationCancellationContext-v1" );
2137         register_ber_oid_dissector_handle("0.4.0.0.1.0.3.3", map_handle, proto_gsm_map,"roamingNumberEnquiryContext-v3" );
2138         register_ber_oid_dissector_handle("0.4.0.0.1.0.3.2", map_handle, proto_gsm_map,"roamingNumberEnquiryContext-v2" );
2139         register_ber_oid_dissector_handle("0.4.0.0.1.0.3.1", map_handle, proto_gsm_map,"roamingNumberEnquiryContext-v1" );
2140         register_ber_oid_dissector_handle("0.4.0.0.1.0.4.3", map_handle, proto_gsm_map,"istAlertingContext-v3" );
2141         register_ber_oid_dissector_handle("0.4.0.0.1.0.5.3", map_handle, proto_gsm_map,"locationInfoRetrievalContext-v3" );
2142         register_ber_oid_dissector_handle("0.4.0.0.1.0.5.2", map_handle, proto_gsm_map,"locationInfoRetrievalContext-v2" );
2143         register_ber_oid_dissector_handle("0.4.0.0.1.0.5.1", map_handle, proto_gsm_map,"locationInfoRetrievalContext-v1" );
2144         register_ber_oid_dissector_handle("0.4.0.0.1.0.6.4", map_handle, proto_gsm_map,"callControlTransferContext-v4" );
2145         register_ber_oid_dissector_handle("0.4.0.0.1.0.6.3", map_handle, proto_gsm_map,"callControlTransferContext-v3" );
2146         register_ber_oid_dissector_handle("0.4.0.0.1.0.7.3", map_handle, proto_gsm_map,"reportingContext-v3" );
2147         register_ber_oid_dissector_handle("0.4.0.0.1.0.8.3", map_handle, proto_gsm_map,"callCompletionContext-v3" );
2148         register_ber_oid_dissector_handle("0.4.0.0.1.0.9.3", map_handle, proto_gsm_map,"serviceTerminationContext-v3" );
2149         register_ber_oid_dissector_handle("0.4.0.0.1.0.10.2", map_handle, proto_gsm_map,"resetContext-v2" );
2150         register_ber_oid_dissector_handle("0.4.0.0.1.0.10.1", map_handle, proto_gsm_map,"resetContext-v1" );
2151         register_ber_oid_dissector_handle("0.4.0.0.1.0.11.3", map_handle, proto_gsm_map,"handoverControlContext-v3" );
2152         register_ber_oid_dissector_handle("0.4.0.0.1.0.11.2", map_handle, proto_gsm_map,"handoverControlContext-v2" );
2153         register_ber_oid_dissector_handle("0.4.0.0.1.0.11.1", map_handle, proto_gsm_map,"handoverControlContext-v1" );
2154         register_ber_oid_dissector_handle("0.4.0.0.1.0.12.3", map_handle, proto_gsm_map,"sIWFSAllocationContext-v3" );
2155         register_ber_oid_dissector_handle("0.4.0.0.1.0.13.3", map_handle, proto_gsm_map,"equipmentMngtContext-v3" );
2156         register_ber_oid_dissector_handle("0.4.0.0.1.0.13.2", map_handle, proto_gsm_map,"equipmentMngtContext-v2" );
2157         register_ber_oid_dissector_handle("0.4.0.0.1.0.13.1", map_handle, proto_gsm_map,"equipmentMngtContext-v1" );
2158         register_ber_oid_dissector_handle("0.4.0.0.1.0.14.3", map_handle, proto_gsm_map,"infoRetrievalContext-v3" );
2159         register_ber_oid_dissector_handle("0.4.0.0.1.0.14.2", map_handle, proto_gsm_map,"infoRetrievalContext-v2" );
2160         register_ber_oid_dissector_handle("0.4.0.0.1.0.14.1", map_handle, proto_gsm_map,"infoRetrievalContext-v1" );
2161         /* fallback to infoRetrieval(14) version1(1) and not interVlrInfoRetrieval(15) version1(1) */
2162         /*register_ber_oid_dissector_handle("0.4.0.0.1.0.15.1", map_handle, proto_gsm_map,"map-ac interVlrInfoRetrieval(15) version1(1)" );*/
2163         register_ber_oid_dissector_handle("0.4.0.0.1.0.15.2", map_handle, proto_gsm_map,"interVlrInfoRetrievalContext-v2" );
2164         register_ber_oid_dissector_handle("0.4.0.0.1.0.15.3", map_handle, proto_gsm_map,"interVlrInfoRetrievalContext-v3" );
2165         register_ber_oid_dissector_handle("0.4.0.0.1.0.16.3", map_handle, proto_gsm_map,"subscriberDataMngtContext-v3" );
2166         register_ber_oid_dissector_handle("0.4.0.0.1.0.16.2", map_handle, proto_gsm_map,"subscriberDataMngtContext-v2" );
2167         register_ber_oid_dissector_handle("0.4.0.0.1.0.16.1", map_handle, proto_gsm_map,"subscriberDataMngtContext-v1" );
2168         register_ber_oid_dissector_handle("0.4.0.0.1.0.17.3", map_handle, proto_gsm_map,"tracingContext-v3" );
2169         register_ber_oid_dissector_handle("0.4.0.0.1.0.17.2", map_handle, proto_gsm_map,"tracingContext-v2" );
2170         register_ber_oid_dissector_handle("0.4.0.0.1.0.17.1", map_handle, proto_gsm_map,"tracingContext-v1" );
2171         register_ber_oid_dissector_handle("0.4.0.0.1.0.18.2", map_handle, proto_gsm_map,"networkFunctionalSsContext-v2" );
2172         register_ber_oid_dissector_handle("0.4.0.0.1.0.18.1", map_handle, proto_gsm_map,"networkFunctionalSsContext-v1" );
2173         register_ber_oid_dissector_handle("0.4.0.0.1.0.19.2", map_handle, proto_gsm_map,"networkUnstructuredSsContext-v2" );
2174         register_ber_oid_dissector_handle("0.4.0.0.1.0.20.3", map_handle, proto_gsm_map,"shortMsgGatewayContext-v3" );
2175         register_ber_oid_dissector_handle("0.4.0.0.1.0.20.2", map_handle, proto_gsm_map,"shortMsgGatewayContext-v2" );
2176         register_ber_oid_dissector_handle("0.4.0.0.1.0.20.1", map_handle, proto_gsm_map,"shortMsgGatewayContext-v1" );
2177         register_ber_oid_dissector_handle("0.4.0.0.1.0.21.3", map_handle, proto_gsm_map,"shortMsgMO-RelayContext-v3" );
2178         register_ber_oid_dissector_handle("0.4.0.0.1.0.21.2", map_handle, proto_gsm_map,"shortMsgMO-RelayContext-v2" );
2179         register_ber_oid_dissector_handle("0.4.0.0.1.0.21.1", map_handle, proto_gsm_map,"shortMsgRelayContext-v1" );
2180         register_ber_oid_dissector_handle("0.4.0.0.1.0.22.3", map_handle, proto_gsm_map,"subscriberDataModificationNotificationContext-v3" );
2181         register_ber_oid_dissector_handle("0.4.0.0.1.0.23.2", map_handle, proto_gsm_map,"shortMsgAlertContext-v2" );
2182         register_ber_oid_dissector_handle("0.4.0.0.1.0.23.1", map_handle, proto_gsm_map,"shortMsgAlertContext-v1" );
2183         register_ber_oid_dissector_handle("0.4.0.0.1.0.24.3", map_handle, proto_gsm_map,"mwdMngtContext-v3" );
2184         register_ber_oid_dissector_handle("0.4.0.0.1.0.24.2", map_handle, proto_gsm_map,"mwdMngtContext-v2" );
2185         register_ber_oid_dissector_handle("0.4.0.0.1.0.24.1", map_handle, proto_gsm_map,"mwdMngtContext-v1" );
2186         register_ber_oid_dissector_handle("0.4.0.0.1.0.25.3", map_handle, proto_gsm_map,"shortMsgMT-RelayContext-v3" );
2187         register_ber_oid_dissector_handle("0.4.0.0.1.0.25.2", map_handle, proto_gsm_map,"shortMsgMT-RelayContext-v2" );
2188         register_ber_oid_dissector_handle("0.4.0.0.1.0.26.2", map_handle, proto_gsm_map,"imsiRetrievalContext-v2" );
2189         register_ber_oid_dissector_handle("0.4.0.0.1.0.27.2", map_handle, proto_gsm_map,"msPurgingContext-v2" );
2190         register_ber_oid_dissector_handle("0.4.0.0.1.0.27.3", map_handle, proto_gsm_map,"msPurgingContext-v3" );
2191         register_ber_oid_dissector_handle("0.4.0.0.1.0.28.3", map_handle, proto_gsm_map,"subscriberInfoEnquiryContext-v3" );
2192         register_ber_oid_dissector_handle("0.4.0.0.1.0.29.3", map_handle, proto_gsm_map,"anyTimeInfoEnquiryContext-v3" );
2193         register_ber_oid_dissector_handle("0.4.0.0.1.0.31.3", map_handle, proto_gsm_map,"groupCallControlContext-v3" );
2194         register_ber_oid_dissector_handle("0.4.0.0.1.0.32.3", map_handle, proto_gsm_map,"gprsLocationUpdateContext-v3" );
2195         register_ber_oid_dissector_handle("0.4.0.0.1.0.33.4", map_handle, proto_gsm_map,"gprsLocationInfoRetrievalContext-v4" );
2196         register_ber_oid_dissector_handle("0.4.0.0.1.0.33.3", map_handle, proto_gsm_map,"gprsLocationInfoRetrievalContext-v3" );
2197         register_ber_oid_dissector_handle("0.4.0.0.1.0.34.3", map_handle, proto_gsm_map,"failureReportContext-v3" );
2198         register_ber_oid_dissector_handle("0.4.0.0.1.0.35.3", map_handle, proto_gsm_map,"gprsNotifyContext-v3" );
2199         register_ber_oid_dissector_handle("0.4.0.0.1.0.36.3", map_handle, proto_gsm_map,"ss-InvocationNotificationContext-v3" );
2200         register_ber_oid_dissector_handle("0.4.0.0.1.0.37.3", map_handle, proto_gsm_map,"locationSvcGatewayContext-v3" );
2201         register_ber_oid_dissector_handle("0.4.0.0.1.0.38.3", map_handle, proto_gsm_map,"locationSvcEnquiryContext-v3" );
2202         register_ber_oid_dissector_handle("0.4.0.0.1.0.39.3", map_handle, proto_gsm_map,"authenticationFailureReportContext-v3" );
2203         register_ber_oid_dissector_handle("0.4.0.0.1.0.40.3", map_handle, proto_gsm_map,"secureTransportHandlingContext-v3" );
2204         register_ber_oid_dissector_handle("0.4.0.0.1.0.41.3", map_handle, proto_gsm_map,"shortMsgMT-Relay-VGCS-Context-v3" );
2205         register_ber_oid_dissector_handle("0.4.0.0.1.0.42.3", map_handle, proto_gsm_map,"mm-EventReportingContext-v3" );
2206         register_ber_oid_dissector_handle("0.4.0.0.1.0.43.3", map_handle, proto_gsm_map,"anyTimeInfoHandlingContext-v3" );
2207         register_ber_oid_dissector_handle("0.4.0.0.1.0.44.3", map_handle, proto_gsm_map,"resourceManagementContext-v3" );
2208         register_ber_oid_dissector_handle("0.4.0.0.1.0.45.3", map_handle, proto_gsm_map,"groupCallInfoRetrievalContext-v3" );
2209         /* Private extension container */
2210         register_ber_oid_dissector("1.3.12.2.1006.53.2.1.3", dissect_gsm_mapext_PlmnContainer, proto_gsm_map,"alcatel-E10-MAP-extension-PlmnContainer" );
2211     }
2212     else {
2213         range_foreach(ssn_range, range_delete_callback);
2214         g_free(ssn_range);
2215     }
2216
2217     ssn_range = range_copy(global_ssn_range);
2218     range_foreach(ssn_range, range_add_callback);
2219
2220 }
2221
2222 /*--- proto_register_gsm_map -------------------------------------------*/
2223 void proto_register_gsm_map(void) {
2224         module_t *gsm_map_module;
2225
2226   /* List of fields */
2227   static hf_register_info hf[] = {
2228       { &hf_gsm_map_old_Component_PDU,
2229         { "Component", "gsm_map.old.Component",
2230           FT_UINT32, BASE_DEC, VALS(gsm_old_Component_vals), 0,
2231           NULL, HFILL }},
2232       { &hf_gsm_map_getPassword,
2233         { "getPassword", "gsm_map.getPassword",
2234           FT_UINT8, BASE_DEC, VALS(gsm_old_GetPasswordArg_vals), 0,
2235           NULL, HFILL }},
2236       { &hf_gsm_map_currentPassword,
2237         { "currentPassword", "gsm_map.currentPassword",
2238           FT_STRING, BASE_NONE, NULL, 0,
2239           NULL, HFILL }},
2240       { &hf_gsm_map_extension,
2241         { "Extension", "gsm_map.extension",
2242           FT_BOOLEAN, 8, TFS(&gsm_map_extension_value), 0x80,
2243           NULL, HFILL }},
2244       { &hf_gsm_map_nature_of_number,
2245         { "Nature of number", "gsm_map.nature_of_number",
2246           FT_UINT8, BASE_HEX|BASE_EXT_STRING, &gsm_map_nature_of_number_values_ext, 0x70,
2247           NULL, HFILL }},
2248       { &hf_gsm_map_number_plan,
2249         { "Number plan", "gsm_map.number_plan",
2250           FT_UINT8, BASE_HEX|BASE_EXT_STRING, &gsm_map_number_plan_values_ext, 0x0f,
2251           NULL, HFILL }},
2252       { &hf_gsm_map_isdn_address_digits,
2253         { "ISDN Address digits", "gsm_map.isdn.address.digits",
2254           FT_STRING, BASE_NONE, NULL, 0,
2255           NULL, HFILL }},
2256       { &hf_gsm_map_address_digits,
2257         { "Address digits", "gsm_map.address.digits",
2258           FT_STRING, BASE_NONE, NULL, 0,
2259           NULL, HFILL }},
2260       { &hf_gsm_map_servicecentreaddress_digits,
2261         { "ServiceCentreAddress digits", "gsm_map.servicecentreaddress_digits",
2262           FT_STRING, BASE_NONE, NULL, 0,
2263           NULL, HFILL }},
2264       { &hf_gsm_map_imsi_digits,
2265         { "IMSI digits", "gsm_map.imsi_digits",
2266           FT_STRING, BASE_NONE, NULL, 0,
2267           NULL, HFILL }},
2268       { &hf_gsm_map_TBCD_digits,
2269         { "TBCD digits", "gsm_map.imsi_digits",
2270           FT_STRING, BASE_NONE, NULL, 0,
2271           NULL, HFILL }},
2272       { &hf_gsm_map_Ss_Status_unused,
2273         { "Unused", "gsm_map.unused",
2274           FT_UINT8, BASE_HEX, NULL, 0xf0,
2275           NULL, HFILL }},
2276       { &hf_gsm_map_Ss_Status_q_bit,
2277         { "Q bit", "gsm_map.ss_status_q_bit",
2278           FT_BOOLEAN, 8, TFS(&gsm_map_Ss_Status_q_bit_values), 0x08,
2279           NULL, HFILL }},
2280       { &hf_gsm_map_Ss_Status_p_bit,
2281         { "P bit", "gsm_map.ss_status_p_bit",
2282           FT_BOOLEAN, 8, TFS(&gsm_map_Ss_Status_p_values), 0x04,
2283           NULL, HFILL }},
2284       { &hf_gsm_map_Ss_Status_r_bit,
2285         { "R bit", "gsm_map.ss_status_r_bit",
2286           FT_BOOLEAN, 8, TFS(&gsm_map_Ss_Status_r_values), 0x02,
2287           NULL, HFILL }},
2288       { &hf_gsm_map_Ss_Status_a_bit,
2289         { "A bit", "gsm_map.ss_status_a_bit",
2290           FT_BOOLEAN, 8, TFS(&gsm_map_Ss_Status_a_values), 0x01,
2291           NULL, HFILL }},
2292       { &hf_gsm_map_notification_to_forwarding_party,
2293         { "Notification to forwarding party", "gsm_map.notification_to_forwarding_party",
2294           FT_BOOLEAN, 8, TFS(&notification_value), 0x80,
2295           NULL, HFILL }},
2296       { &hf_gsm_map_redirecting_presentation,
2297         { "Redirecting presentation", "gsm_map.redirecting_presentation",
2298           FT_BOOLEAN, 8, TFS(&redirecting_presentation_value), 0x40,
2299           NULL, HFILL }},
2300       { &hf_gsm_map_notification_to_calling_party,
2301         { "Notification to calling party", "gsm_map.notification_to_clling_party",
2302           FT_BOOLEAN, 8, TFS(&notification_value), 0x20,
2303           NULL, HFILL }},
2304       { &hf_gsm_map_forwarding_reason,
2305         { "Forwarding reason", "gsm_map.forwarding_reason",
2306           FT_UINT8, BASE_HEX, VALS(forwarding_reason_values), 0x0c,
2307           NULL, HFILL }},
2308       { &hf_gsm_map_pdp_type_org,
2309         { "PDP Type Organization", "gsm_map.pdp_type_org",
2310           FT_UINT8, BASE_HEX, VALS(pdp_type_org_values), 0x0f,
2311           NULL, HFILL }},
2312       { &hf_gsm_map_etsi_pdp_type_number,
2313         { "PDP Type Number", "gsm_map.pdp_type_org",
2314           FT_UINT8, BASE_HEX, VALS(etsi_pdp_type_number_values), 0,
2315           "ETSI PDP Type Number", HFILL }},
2316       { &hf_gsm_map_ietf_pdp_type_number,
2317         { "PDP Type Number", "gsm_map.ietf_pdp_type_number",
2318           FT_UINT8, BASE_HEX, VALS(ietf_pdp_type_number_values), 0,
2319           "IETF PDP Type Number", HFILL }},
2320       { &hf_gsm_map_ext_qos_subscribed_pri,
2321         { "Allocation/Retention priority", "gsm_map.ext_qos_subscribed_pri",
2322           FT_UINT8, BASE_DEC, NULL, 0xff,
2323           NULL, HFILL }},
2324       { &hf_gsm_map_qos_traffic_cls,
2325         { "Traffic class", "gsm_map.qos.traffic_cls",
2326           FT_UINT8, BASE_DEC, VALS(gsm_a_qos_traffic_cls_vals), 0xe0,
2327           NULL, HFILL }},
2328       { &hf_gsm_map_qos_del_order,
2329         { "Delivery order", "gsm_map.qos.del_order",
2330           FT_UINT8, BASE_DEC, VALS(gsm_a_qos_traffic_cls_vals), 0x18,
2331           NULL, HFILL }},
2332       { &hf_gsm_map_qos_del_of_err_sdu,
2333         { "Delivery of erroneous SDUs", "gsm_map.qos.del_of_err_sdu",
2334           FT_UINT8, BASE_DEC, VALS(gsm_a_qos_del_of_err_sdu_vals), 0x03,
2335           NULL, HFILL }},
2336       { &hf_gsm_map_qos_ber,
2337         { "Residual Bit Error Rate (BER)", "gsm_map.qos.ber",
2338           FT_UINT8, BASE_DEC, VALS(gsm_a_qos_ber_vals), 0xf0,
2339           NULL, HFILL }},
2340       { &hf_gsm_map_qos_sdu_err_rat,
2341         { "SDU error ratio", "gsm_map.qos.sdu_err_rat",
2342           FT_UINT8, BASE_DEC, VALS(gsm_a_qos_sdu_err_rat_vals), 0x0f,
2343           NULL, HFILL }},
2344       { &hf_gsm_map_qos_traff_hdl_pri,
2345         { "Traffic handling priority", "gsm_map.qos.traff_hdl_pri",
2346           FT_UINT8, BASE_DEC, VALS(gsm_a_qos_traff_hdl_pri_vals), 0x03,
2347           NULL, HFILL }},
2348
2349       { &hf_gsm_map_qos_max_sdu,
2350         { "Maximum SDU size", "gsm_map.qos.max_sdu",
2351           FT_UINT32, BASE_DEC, NULL, 0x0,
2352           NULL, HFILL }},
2353       { &hf_gsm_map_max_brate_ulink,
2354         { "Maximum bit rate for uplink in kbit/s", "gsm_map.qos.max_brate_ulink",
2355           FT_UINT32, BASE_DEC, NULL, 0x0,
2356           "Maximum bit rate for uplink", HFILL }},
2357       { &hf_gsm_map_max_brate_dlink,
2358         { "Maximum bit rate for downlink in kbit/s", "gsm_map.qos.max_brate_dlink",
2359           FT_UINT32, BASE_DEC, NULL, 0x0,
2360           "Maximum bit rate for downlink", HFILL }},
2361       { &hf_gsm_map_qos_transfer_delay,
2362         { "Transfer delay (Raw data see TS 24.008 for interpretation)", "gsm_map.qos.transfer_delay",
2363           FT_UINT8, BASE_DEC, NULL, 0xfc,
2364           "Transfer delay", HFILL }},
2365       { &hf_gsm_map_guaranteed_max_brate_ulink,
2366         { "Guaranteed bit rate for uplink in kbit/s", "gsm_map.qos.brate_ulink",
2367           FT_UINT32, BASE_DEC, NULL, 0x0,
2368           "Guaranteed bit rate for uplink", HFILL }},
2369       { &hf_gsm_map_guaranteed_max_brate_dlink,
2370         { "Guaranteed bit rate for downlink in kbit/s", "gsm_map.qos.brate_dlink",
2371           FT_UINT32, BASE_DEC, NULL, 0x0,
2372           "Guaranteed bit rate for downlink", HFILL }},
2373       { &hf_gsm_map_GSNAddress_IPv4,
2374         { "GSN-Address IPv4",  "gsm_map.gsnaddress_ipv4",
2375           FT_IPv4, BASE_NONE, NULL, 0,
2376           "IPAddress IPv4", HFILL }},
2377       { &hf_gsm_map_GSNAddress_IPv6,
2378         { "GSN Address IPv6",  "gsm_map.gsnaddress_ipv6",
2379           FT_IPv4, BASE_NONE, NULL, 0,
2380           "IPAddress IPv6", HFILL }},
2381       { &hf_gsm_map_ranap_service_Handover,
2382         { "service-Handover", "gsm_map.ranap.service_Handover",
2383           FT_UINT32, BASE_DEC, VALS(ranap_Service_Handover_vals), 0,
2384           "gsm_map.ranap.Service_Handover", HFILL }},
2385       { &hf_gsm_map_IntegrityProtectionInformation,
2386         { "IntegrityProtectionInformation", "gsm_map.ranap.IntegrityProtectionInformation",
2387           FT_NONE, BASE_NONE, NULL, 0,
2388           "gsm_map.ranap.IntegrityProtectionInformation", HFILL }},
2389       { &hf_gsm_map_EncryptionInformation,
2390         { "EncryptionInformation", "gsm_map.ranap.EncryptionInformation",
2391           FT_NONE, BASE_NONE, NULL, 0,
2392           "gsm_map.ranap.EncryptionInformation", HFILL }},
2393       { &hf_gsm_map_PlmnContainer_PDU,
2394         { "PlmnContainer", "gsm_map.PlmnContainer",
2395           FT_NONE, BASE_NONE, NULL, 0,
2396           "gsm_map.PlmnContainer", HFILL }},
2397       { &hf_gsm_map_ss_SS_UserData,
2398         { "SS-UserData", "gsm_ss.SS_UserData",
2399           FT_STRING, BASE_NONE, NULL, 0,
2400           "gsm_map.ss.SS_UserData", HFILL }},
2401       { &hf_gsm_map_cbs_coding_grp,
2402         { "Coding Group","gsm_map.cbs.coding_grp",
2403           FT_UINT8,BASE_DEC|BASE_EXT_STRING, &gsm_map_cbs_data_coding_scheme_coding_grp_vals_ext, 0xf0,
2404           NULL, HFILL }
2405       },
2406       { &hf_gsm_map_cbs_coding_grp0_lang,
2407         { "Language","gsm_map.cbs.coding_grp0_lang",
2408           FT_UINT8,BASE_DEC|BASE_EXT_STRING, &gsm_map_cbs_coding_grp0_lang_vals_ext, 0x0f,
2409           NULL, HFILL }
2410       },
2411       { &hf_gsm_map_cbs_coding_grp1_lang,
2412         { "Language","gsm_map.cbs.coding_grp1_lang",
2413           FT_UINT8,BASE_DEC|BASE_EXT_STRING, &gsm_map_cbs_coding_grp1_lang_vals_ext, 0x0f,
2414           NULL, HFILL }
2415       },
2416       { &hf_gsm_map_cbs_coding_grp2_lang,
2417         { "Language","gsm_map.cbs.coding_grp2_lang",
2418           FT_UINT8,BASE_DEC|BASE_EXT_STRING, &gsm_map_cbs_coding_grp2_lang_vals_ext, 0x0f,
2419           NULL, HFILL }
2420       },
2421       { &hf_gsm_map_cbs_coding_grp3_lang,
2422         { "Language","gsm_map.cbs.coding_grp3_lang",
2423           FT_UINT8,BASE_DEC|BASE_EXT_STRING, &gsm_map_cbs_coding_grp3_lang_vals_ext, 0x0f,
2424           NULL, HFILL }
2425       },
2426       { &hf_gsm_map_cbs_coding_grp4_7_comp,
2427         { "Compressed indicator","gsm_map.cbs.coding_grp4_7_comp",
2428           FT_BOOLEAN, 8, TFS(&gsm_map_cbs_coding_grp4_7_comp_vals), 0x20,
2429           NULL, HFILL }
2430       },
2431       { &hf_gsm_map_cbs_coding_grp4_7_class_ind,
2432         { "Message Class present","gsm_map.cbs.coding_grp4_7_class_ind",
2433           FT_BOOLEAN, 8, TFS(&gsm_map_cbs_coding_grp4_7_class_ind_vals), 0x10,
2434           NULL, HFILL }
2435       },
2436       { &hf_gsm_map_cbs_coding_grp4_7_char_set,
2437         { "Character set being used","gsm_map.cbs.coding_grp4_7_char_set",
2438           FT_UINT8,BASE_DEC, VALS(gsm_map_cbs_coding_grp4_7_char_set_vals), 0x0c,
2439           NULL, HFILL }
2440       },
2441       { &hf_gsm_map_cbs_coding_grp4_7_class,
2442         { "Message Class","gsm_map.cbs.coding_grp4_7_class",
2443           FT_UINT8,BASE_DEC, VALS(gsm_map_cbs_coding_grp4_7_class_vals), 0x03,
2444           NULL, HFILL }
2445       },
2446       { &hf_gsm_map_cbs_coding_grp15_mess_code,
2447         { "Message coding","gsm_map.cbs.cbs_coding_grp15_mess_code",
2448           FT_UINT8,BASE_DEC, VALS(gsm_map_cbs_coding_grp15_mess_code_vals), 0x04,
2449           NULL, HFILL }
2450       },
2451       { &hf_gsm_map_cbs_coding_grp15_class,
2452         { "Message Class","gsm_map.cbs.gsm_map_cbs_coding_grp15_class",
2453           FT_UINT8,BASE_DEC, VALS(gsm_map_cbs_coding_grp15_class_vals), 0x03,
2454           NULL, HFILL }
2455       },
2456       { &hf_gsm_map_tmsi,
2457         { "tmsi", "gsm_map.tmsi",
2458           FT_BYTES, BASE_NONE, NULL, 0,
2459           "gsm_map.TMSI", HFILL }},
2460
2461       { &hf_gsm_map_ie_tag,
2462         { "Tag", "gsm_map.ie_tag",
2463           FT_UINT8, BASE_DEC, VALS(gsm_map_tag_vals), 0,
2464           "GSM 04.08 tag", HFILL }},
2465       { &hf_gsm_map_len,
2466         { "Length", "gsm_map.length",
2467           FT_UINT8, BASE_DEC, NULL, 0,
2468           NULL, HFILL }},
2469       { &hf_gsm_map_disc_par,
2470         { "Discrimination parameter", "gsm_map.disc_par",
2471           FT_UINT8, BASE_DEC, VALS(gsm_map_disc_par_vals), 0,
2472           NULL, HFILL }},
2473       { &hf_gsm_map_dlci,
2474         { "DLCI", "gsm_map.disc_par",
2475           FT_UINT8, BASE_DEC, NULL, 0,
2476           "Data Link Connection Indicator", HFILL }},
2477       { &hf_gsm_apn_str,
2478         { "APN", "gsm_map.apn_str",
2479           FT_STRING, BASE_NONE, NULL, 0,
2480           NULL, HFILL }},
2481
2482 #include "packet-gsm_map-hfarr.c"
2483   };
2484
2485   /* List of subtrees */
2486   static gint *ett[] = {
2487     &ett_gsm_map,
2488     &ett_gsm_map_InvokeId,
2489     &ett_gsm_map_InvokePDU,
2490     &ett_gsm_map_ReturnResultPDU,
2491     &ett_gsm_map_ReturnErrorPDU,
2492     &ett_gsm_map_ReturnResult_result,
2493     &ett_gsm_map_ReturnError_result,
2494     &ett_gsm_map_GSMMAPPDU,
2495     &ett_gsm_map_ext_qos_subscribed,
2496     &ett_gsm_map_pdptypenumber,
2497     &ett_gsm_map_RAIdentity,
2498     &ett_gsm_map_LAIFixedLength,
2499     &ett_gsm_map_isdn_address_string,
2500     &ett_gsm_map_geo_desc,
2501     &ett_gsm_map_LongSignalInfo,
2502     &ett_gsm_map_RadioResourceInformation,
2503     &ett_gsm_map_MSNetworkCapability,
2504     &ett_gsm_map_MSRadioAccessCapability,
2505     &ett_gsm_map_externalsignalinfo,
2506     &ett_gsm_map_cbs_data_coding,
2507     &ett_gsm_map_GlobalCellId,
2508     &ett_gsm_map_GeographicalInformation,
2509         &ett_gsm_map_apn_str,
2510
2511 #include "packet-gsm_map-ettarr.c"
2512   };
2513
2514   /* Register protocol */
2515   proto_gsm_map_dialogue =proto_gsm_map = proto_register_protocol(PNAME, PSNAME, PFNAME);
2516
2517   register_dissector("gsm_map", dissect_gsm_map, proto_gsm_map);
2518
2519   /* Register fields and subtrees */
2520   proto_register_field_array(proto_gsm_map, hf, array_length(hf));
2521   proto_register_subtree_array(ett, array_length(ett));
2522
2523   sms_dissector_table = register_dissector_table("gsm_map.sms_tpdu",
2524                                                  "GSM SMS TPDU", FT_UINT8,
2525                                                  BASE_DEC);
2526
2527   map_prop_arg_opcode_table = register_dissector_table("gsm_map.prop.arg.opcode", "Proprietary Opcodes", FT_UINT8, BASE_DEC);
2528   map_prop_res_opcode_table = register_dissector_table("gsm_map.prop.res.opcode", "Proprietary Opcodes", FT_UINT8, BASE_DEC);
2529   map_prop_err_opcode_table = register_dissector_table("gsm_map.prop.err.opcode", "Proprietary Opcodes", FT_UINT8, BASE_DEC);
2530
2531   gsm_map_tap = register_tap("gsm_map");
2532
2533 #include "packet-gsm_map-dis-tab.c" */
2534   oid_add_from_string("ericsson-gsm-Map-Ext","1.2.826.0.1249.58.1.0" );
2535   oid_add_from_string("accessTypeNotAllowed-id","1.3.12.2.1107.3.66.1.2");
2536   /*oid_add_from_string("map-ac networkLocUp(1) version3(3)","0.4.0.0.1.0.1.3" );
2537    *
2538    * Register our configuration options, particularly our ssn:s
2539    * Set default SSNs
2540    */
2541   range_convert_str(&global_ssn_range, "6-9", MAX_SSN);
2542
2543   gsm_map_module = prefs_register_protocol(proto_gsm_map, proto_reg_handoff_gsm_map);
2544
2545   prefs_register_range_preference(gsm_map_module, "tcap.ssn", "TCAP SSNs",
2546                                   "TCAP Subsystem numbers used for GSM MAP",
2547                                   &global_ssn_range, MAX_SSN);
2548 }