Fix to SendAuthenticationInfoRes.
[metze/wireshark/wip.git] / asn1 / gsmmap / packet-gsm_map-template.c
1 /* packet-gsm_map-template.c
2  * Routines for GSM MobileApplication packet dissection
3  * Copyright 2004 - 2005 , Anders Broman <anders.broman@ericsson.com>
4  * Based on the dissector by:
5  * Felix Fei <felix.fei [AT] utstar.com>
6  * and Michael Lum <mlum [AT] telostech.com>
7  *
8  * $Id$
9  *
10  * Ethereal - Network traffic analyzer
11  * By Gerald Combs <gerald@ethereal.com>
12  * Copyright 1998 Gerald Combs
13  *
14  * This program is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU General Public License
16  * as published by the Free Software Foundation; either version 2
17  * of the License, or (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to the Free Software
26  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
27  * References: ETSI TS 129 002
28  * Updated to ETSI TS 129 002 V6.9.0 (2005-3GPP TS 29.002 version 6.9.0 Release 6)
29  */
30
31 #ifdef HAVE_CONFIG_H
32 # include "config.h"
33 #endif
34
35 #include <glib.h>
36 #include <epan/packet.h>
37 #include <epan/prefs.h>
38 #include <epan/conversation.h>
39 #include <epan/tap.h>
40
41 #include <stdio.h>
42 #include <string.h>
43
44 #include "packet-ber.h"
45 #include "packet-q931.h"
46 #include "packet-gsm_map.h"
47
48 #define PNAME  "GSM Mobile Application"
49 #define PSNAME "GSM_MAP"
50 #define PFNAME "gsm_map"
51
52 /* Initialize the protocol and registered fields */
53 int proto_gsm_map = -1;
54 static int hf_gsm_map_invokeCmd = -1;             /* Opcode */
55 static int hf_gsm_map_invokeid = -1;              /* INTEGER */
56 static int hf_gsm_map_absent = -1;                /* NULL */
57 static int hf_gsm_map_invokeId = -1;              /* InvokeId */
58 static int hf_gsm_map_invoke = -1;                /* InvokePDU */
59 static int hf_gsm_map_returnResult = -1;          /* InvokePDU */
60 static int hf_gsm_map_returnResult_result = -1;
61 static int hf_gsm_map_returnError_result = -1;
62 static int hf_gsm_map_returnError = -1;
63 static int hf_gsm_map_local_errorCode = -1;
64 static int hf_gsm_map_global_errorCode_oid = -1;
65 static int hf_gsm_map_global_errorCode = -1;
66 static int hf_gsm_map_SendAuthenticationInfoArg = -1;
67 static int hf_gsm_map_SendAuthenticationInfoRes = -1;
68 static int hf_gsm_mapSendEndSignal = -1;
69 static int hf_gsm_map_getPassword = -1;  
70 static int hf_gsm_map_currentPassword = -1;
71 static int hf_gsm_map_extension = -1;
72 static int hf_gsm_map_nature_of_number = -1;
73 static int hf_gsm_map_number_plan = -1;
74 static int hf_gsm_map_isdn_address_digits = -1;
75 static int hf_gsm_map_servicecentreaddress_digits = -1;
76 static int hf_gsm_map_imsi_digits = -1;
77 static int hf_gsm_map_Ss_Status_unused = -1;
78 static int hf_gsm_map_Ss_Status_q_bit = -1;
79 static int hf_gsm_map_Ss_Status_p_bit = -1;
80 static int hf_gsm_map_Ss_Status_r_bit = -1;
81 static int hf_gsm_map_Ss_Status_a_bit = -1;
82
83 #include "packet-gsm_map-hf.c"
84
85 /* Initialize the subtree pointers */
86 static gint ett_gsm_map = -1;
87 static gint ett_gsm_map_InvokeId = -1;
88 static gint ett_gsm_map_InvokePDU = -1;
89 static gint ett_gsm_map_ReturnResultPDU = -1;
90 static gint ett_gsm_map_ReturnErrorPDU = -1;
91 static gint ett_gsm_map_ReturnResult_result = -1;
92 static gint ett_gsm_map_ReturnError_result = -1;
93 static gint ett_gsm_map_GSMMAPPDU = -1;
94
95 #include "packet-gsm_map-ett.c"
96
97 static dissector_table_t        sms_dissector_table;    /* SMS TPDU */
98 static dissector_handle_t data_handle;
99
100 /* Preferenc settings default */
101 #define MAX_SSN 254
102 static range_t *global_ssn_range;
103 static range_t *ssn_range;
104 dissector_handle_t      map_handle;
105
106 /* Global variables */
107
108 static proto_tree *top_tree;
109 static int application_context_version;
110 gint protocolId;
111 static int gsm_map_tap = -1;
112
113
114 char*
115 unpack_digits(tvbuff_t *tvb, int offset){
116
117         int length;
118         guint8 octet;
119         int i=0;
120         char *digit_str;
121
122         length = tvb_length(tvb);
123         if (length < offset)
124                 return NULL;
125         length = length - offset;
126         digit_str = g_malloc(length*2+1);
127
128         while ( offset <= length ){
129
130                 octet = tvb_get_guint8(tvb,offset);
131                 digit_str[i] = ((octet & 0x0f) + 0x30);
132                 i++;
133
134                 /*
135                  * unpack second value in byte
136                  */
137                 octet = octet >> 4;
138
139                 if (octet == 0x0f)      /* odd number bytes - hit filler */
140                         break;
141
142                 digit_str[i] = ((octet & 0x0f) + 0x30);
143                 i++;
144                 offset++;
145
146         }
147         digit_str[i]= '\0';
148         return digit_str;
149 }
150
151
152 #include "packet-gsm_map-fn.c"
153
154 const value_string gsm_map_opr_code_strings[] = {
155   {   2, "updateLocation" },
156   {   3, "cancelLocation" },
157   {   4, "provideRoamingNumber" },
158   {       5, "noteSubscriberDataModified" },    
159   {   6, "resumeCallHandling" },
160   {   7, "insertSubscriberData" },
161   {   8, "deleteSubscriberData" },
162   {   9, "sendParameters" },                                    /* map-ac infoRetrieval (14) version1 (1)*/
163   {  10, "registerSS" },
164   {  11, "eraseSS" },
165   {  12, "activateSS" },
166   {  13, "deactivateSS" },
167   {  14, "interrogateSS" },
168   {      15, "authenticationFailureReport" },   
169   {  17, "registerPassword" },
170   {  18, "getPassword" },
171   {  19, "processUnstructuredSS-Data" },                /* map-ac networkFunctionalSs (18) version1 (1) */
172   {  20, "releaseResources" },
173   {  22, "sendRoutingInfo" },
174   {  23, "updateGprsLocation" },
175   {  24, "sendRoutingInfoForGprs" },
176   {  25, "failureReport" },
177   {  26, "noteMsPresentForGprs" },
178   {  28, "performHandover" },                                   /* map-ac handoverControl (11) version1 (1)*/
179   {  29, "sendEndSignal" },
180   {  30, "performSubsequentHandover" },                 /* map-ac handoverControl (11) version1 (1) */
181   {  31, "provideSIWFSNumber" },
182   {  32, "sIWFSSignallingModify" },
183   {  33, "processAccessSignalling" },
184   {  34, "forwardAccessSignalling" },
185   {  35, "noteInternalHandover" },                              /* map-ac handoverControl (11) version1 (1) */
186   {  37, "reset" },
187   {  38, "forwardCheckSS-Indication" },
188   {  39, "prepareGroupCall" },
189   {  40, "sendGroupCallEndSignal" },
190   {  41, "processGroupCallSignalling" },
191   {  42, "forwardGroupCallSignalling" },
192   {  43, "checkIMEI" },
193   {  44, "mt-forwardSM" },
194   {  45, "sendRoutingInfoForSM" },
195   {  46, "mo-forwardSM" },
196   {  47, "reportSM-DeliveryStatus" },
197   {  48, "noteSubscriberPresent" },                             /* map-ac mwdMngt (24) version1 (1) */
198   {  49, "alertServiceCentreWithoutResult" },   /* map-ac shortMsgAlert (23) version1 (1) */
199   {  50, "activateTraceMode" },
200   {  51, "deactivateTraceMode" },
201   {  52, "traceSubscriberActivity" },                   /* map-ac handoverControl (11) version1 (1) */
202   {  54, "beginSubscriberActivity" },                   /* map-ac networkFunctionalSs (18) version1 (1) */
203   {  55, "sendIdentification" },
204   {  56, "sendAuthenticationInfo" },
205   {  57, "restoreData" },
206   {  58, "sendIMSI" },
207   {  59, "processUnstructuredSS-Request" },
208   {  60, "unstructuredSS-Request" },
209   {  61, "unstructuredSS-Notify" },
210   {  62, "anyTimeSubscriptionInterrogation" },
211   {  63, "informServiceCentre" },
212   {  64, "alertServiceCentre" },
213   {  65, "anyTimeModification" },
214   {  66, "readyForSM" },
215   {  67, "purgeMS" },
216   {  68, "prepareHandover" },
217   {  69, "prepareSubsequentHandover" },
218   {  70, "provideSubscriberInfo" },
219   {  71, "anyTimeInterrogation" },
220   {  72, "ss-InvocationNotification" },
221   {  73, "setReportingState" },
222   {  74, "statusReport" },
223   {  75, "remoteUserFree" },
224   {  76, "registerCC-Entry" },
225   {  77, "eraseCC-Entry" },
226   {  78, "secureTransportClass1" },
227   {  79, "secureTransportClass2" },
228   {  80, "secureTransportClass3" },
229   {  81, "secureTransportClass4" },
230   {  83, "provideSubscriberLocation" },
231   {  85, "sendRoutingInfoForLCS" },
232   {  86, "subscriberLocationReport" },
233   {      87, "ist-Alert" },
234   {      88, "ist-Command" },
235   {  89, "noteMM-Event" },
236   { 0, NULL }
237 };
238 static const value_string gsm_map_err_code_string_vals[] = {
239     { 1,        "Unknown Subscriber" },
240     { 3,        "Unknown MSC" },
241     { 5,        "Unidentified Subscriber" },
242     { 6,        "Absent Subscriber SM" },
243     { 7,        "Unknown Equipment" },
244     { 8,        "Roaming Not Allowed" },
245     { 9,        "Illegal Subscriber" },
246     { 10,       "Bearer Service Not Provisioned" },
247     { 11,       "Teleservice Not Provisioned" },
248     { 12,       "Illegal Equipment" },
249     { 13,       "Call Barred" },
250     { 14,       "Forwarding Violation" },
251     { 15,       "CUG Reject" },
252     { 16,       "Illegal SS Operation" },
253     { 17,       "SS Error Status" },
254     { 18,       "SS Not Available" },
255     { 19,       "SS Subscription Violation" },
256     { 20,       "SS Incompatibility" },
257     { 21,       "Facility Not Supported" },
258     { 25,       "No Handover Number Available" },
259     { 26,       "Subsequent Handover Failure" },
260     { 27,       "Absent Subscriber" },
261     { 28,       "Incompatible Terminal" },
262     { 29,       "Short Term Denial" },
263     { 30,       "Long Term Denial" },
264     { 31,       "Subscriber Busy For MT SMS" },
265     { 32,       "SM Delivery Failure" },
266     { 33,       "Message Waiting List Full" },
267     { 34,       "System Failure" },
268     { 35,       "Data Missing" },
269     { 36,       "Unexpected Data Value" },
270     { 37,       "PW Registration Failure" },
271     { 38,       "Negative PW Check" },
272     { 39,       "No Roaming Number Available" },
273     { 40,       "Tracing Buffer Full" },
274     { 42,       "Target Cell Outside Group Call Area" },
275     { 43,       "Number Of PW Attempts Violation" },
276     { 44,       "Number Changed" },
277     { 45,       "Busy Subscriber" },
278     { 46,       "No Subscriber Reply" },
279     { 47,       "Forwarding Failed" },
280     { 48,       "OR Not Allowed" },
281     { 49,       "ATI Not Allowed" },
282     { 50,       "No Group Call Number Available" },
283     { 51,       "Resource Limitation" },
284     { 52,       "Unauthorized Requesting Network" },
285     { 53,       "Unauthorized LCS Client" },
286     { 54,       "Position Method Failure" },
287     { 58,       "Unknown Or Unreachable LCS Client" },
288     { 59,       "MM Event Not Supported" },
289     { 60,       "ATSI Not Allowed" },
290     { 61,       "ATM Not Allowed" },
291     { 62,       "Information Not Available" },
292     { 71,       "Unknown Alphabet" },
293     { 72,       "USSD Busy" },
294     { 120,      "Nbr Sb Exceeded" },
295     { 121,      "Rejected By User" },
296     { 122,      "Rejected By Network" },
297     { 123,      "Deflection To Served Subscriber" },
298     { 124,      "Special Service Code" },
299     { 125,      "Invalid Deflected To Number" },
300     { 126,      "Max Number Of MPTY Participants Exceeded" },
301     { 127,      "Resources Not Available" },
302     { 0, NULL }
303 };
304 static const true_false_string gsm_map_extension_value = {
305   "No Extension",
306   "Extension"
307 };
308 static const value_string gsm_map_nature_of_number_values[] = {
309         {   0x00,       "unknown" },
310         {   0x01,       "International Number" },
311         {   0x02,       "National Significant Number" },
312         {   0x03,       "Network Specific Number" },
313         {   0x04,       "Subscriber Number" },
314         {   0x05,       "Reserved" },
315         {   0x06,       "Abbreviated Number" },
316         {   0x07,       "Reserved for extension" },
317         { 0, NULL }
318 };
319 static const value_string gsm_map_number_plan_values[] = {
320         {   0x00,       "unknown" },
321         {   0x01,       "ISDN/Telephony Numbering (Rec ITU-T E.164)" },
322         {   0x02,       "spare" },
323         {   0x03,       "Data Numbering (ITU-T Rec. X.121)" },
324         {   0x04,       "Telex Numbering (ITU-T Rec. F.69)" },
325         {   0x05,       "spare" },
326         {   0x06,       "Land Mobile Numbering (ITU-T Rec. E.212)" },
327         {   0x07,       "spare" },
328         {   0x08,       "National Numbering" },
329         {   0x09,       "Private Numbering" },
330         {   0x0f,       "Reserved for extension" },
331         { 0, NULL }
332 };
333
334 static const true_false_string gsm_map_Ss_Status_q_bit_values = {
335   "Quiescent",
336   "Operative"
337 };
338 static const true_false_string gsm_map_Ss_Status_p_values = {
339   "Provisioned",
340   "Not Provisioned"
341 };
342 static const true_false_string gsm_map_Ss_Status_r_values = {
343   "Registered",
344   "Not Registered"
345 };
346 static const true_false_string gsm_map_Ss_Status_a_values = {
347   "Active",
348   "not Active"
349 };
350
351 static guint32 opcode=0;
352
353 static int
354 dissect_gsm_map_Opcode(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
355   offset = dissect_ber_integer(FALSE, pinfo, tree, tvb, offset, hf_index, &opcode);
356
357   if (check_col(pinfo->cinfo, COL_INFO)){
358     col_append_fstr(pinfo->cinfo, COL_INFO, val_to_str(opcode, gsm_map_opr_code_strings, "Unknown GSM-MAP (%u)"));
359   }
360
361   return offset;
362 }
363
364 static int dissect_invokeData(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
365
366   guint8 octet;
367
368   switch(opcode){
369   case  2: /*updateLocation*/   
370           offset=dissect_gsm_map_UpdateLocationArg(FALSE, tvb, offset, pinfo, tree, -1);
371     break;
372   case  3: /*cancelLocation*/
373         octet = tvb_get_guint8(tvb,0) & 0xf;
374         if ( octet == 3){ /*   */
375                 offset = offset +2;
376                 offset=dissect_gsm_map_CancelLocationArg(TRUE, tvb, offset, pinfo, tree, -1);
377         }else{
378     offset=dissect_gsm_map_CancelLocationArg(FALSE, tvb, offset, pinfo, tree, -1);
379         }
380     break;
381   case  4: /*provideRoamingNumber*/
382     offset=dissect_gsm_map_ProvideRoamingNumberArg(FALSE, tvb, offset, pinfo, tree, -1);
383     break;
384   case  6: /*resumeCallHandling*/
385     offset=dissect_gsm_map_ResumeCallHandlingArg(FALSE, tvb, offset, pinfo, tree, -1);
386     break;
387   case  7: /*insertSubscriberData*/
388     offset=dissect_gsm_map_InsertSubscriberDataArg(FALSE, tvb, offset, pinfo, tree, -1);
389     break;
390   case  8: /*deleteSubscriberData*/
391     offset=dissect_gsm_map_DeleteSubscriberDataArg(FALSE, tvb, offset, pinfo, tree, -1);
392     break;
393         /* TODO find out why this isn't in the ASN1 file
394   case  9: sendParameters
395     offset=dissect_gsm_map_DeleteSubscriberDataArg(FALSE, tvb, offset, pinfo, tree, -1);
396     break;
397         */
398   case  10: /*registerSS*/
399     offset=dissect_gsm_map_RegisterSS_Arg(FALSE, tvb, offset, pinfo, tree, -1);
400     break;
401   case  11: /*eraseSS*/
402     offset=dissect_gsm_map_SS_ForBS_Code(FALSE, tvb, offset, pinfo, tree, -1);
403     break;
404   case 12: /*activateSS*/
405     offset=dissect_gsm_map_SS_ForBS_Code(FALSE, tvb, offset, pinfo, tree, -1);
406     break;
407   case 13: /*deactivateSS*/
408     offset=dissect_gsm_map_SS_ForBS_Code(FALSE, tvb, offset, pinfo, tree, -1);
409     break;
410   case 14: /*interrogateSS*/
411     offset=dissect_gsm_map_SS_ForBS_Code(FALSE, tvb, offset, pinfo, tree, -1);
412     break;
413   case 15: /*authenticationFailureReport*/
414           offset=dissect_gsm_map_AuthenticationFailureReportArg(FALSE, tvb, offset, pinfo, tree, -1);
415           break;
416   case 17: /*registerPassword*/
417     offset=dissect_gsm_map_SS_Code(FALSE, tvb, offset, pinfo, tree, hf_gsm_map_ss_Code);
418     break;
419   case 18: /*getPassword*/
420     offset=dissect_gsm_map_GetPasswordArg(FALSE, tvb, offset, pinfo, tree, hf_gsm_map_getPassword);
421     break;
422   case 20: /*releaseResources*/
423     offset=dissect_gsm_map_ReleaseResourcesArg(FALSE, tvb, offset, pinfo, tree, -1);
424     break;
425   case 22: /*sendRoutingInfo*/
426     offset=dissect_gsm_map_SendRoutingInfoArg(FALSE, tvb, offset, pinfo, tree, -1);
427     break;
428   case 23: /*updateGprsLocation*/
429     offset=dissect_gsm_map_UpdateGprsLocationArg(FALSE, tvb, offset, pinfo, tree, -1);
430     break;
431   case 24: /*sendRoutingInfoForGprs*/
432     offset=dissect_gsm_map_SendRoutingInfoForGprsArg(FALSE, tvb, offset, pinfo, tree, -1);
433     break;
434   case 25: /*failureReport*/
435     offset=dissect_gsm_map_FailureReportArg(FALSE, tvb, offset, pinfo, tree, -1);
436     break;
437   case 26: /*noteMsPresentForGprs*/
438     offset=dissect_gsm_map_NoteMsPresentForGprsArg(FALSE, tvb, offset, pinfo, tree, -1);
439     break;
440   case 29: /*sendEndSignal*/
441         octet = tvb_get_guint8(tvb,0) & 0xf;
442         if ( octet == 3){ /* This is a V3 message ??? */
443                 offset = offset +2;
444                 offset=dissect_gsm_map_SendEndSignalArgV3(TRUE, tvb, offset, pinfo, tree, hf_gsm_mapSendEndSignal);
445         }else{
446                 offset=dissect_gsm_map_Bss_APDU(FALSE, tvb, offset, pinfo, tree, hf_gsm_mapSendEndSignal);
447         }
448     break;
449   case 31: /*provideSIWFSNumbe*/
450     offset=dissect_gsm_map_ProvideSIWFSNumberArg(FALSE, tvb, offset, pinfo, tree, -1);
451     break;
452   case 32: /*sIWFSSignallingModify*/
453     offset=dissect_gsm_map_SIWFSSignallingModifyArg(FALSE, tvb, offset, pinfo, tree, -1);
454     break;
455   case 33: /*processAccessSignalling*/
456         octet = tvb_get_guint8(tvb,0) & 0xf;
457         if ( octet == 3){ /* This is a V3 message ??? */
458                 offset = offset +2;
459                 offset = dissect_gsm_map_ProcessAccessSignallingArgV3(TRUE, tvb, offset, pinfo, tree, hf_gsm_mapSendEndSignal);
460         }else{
461     offset=dissect_gsm_map_Bss_APDU(FALSE, tvb, offset, pinfo, tree, -1);
462         }
463     break;
464   case 34: /*forwardAccessSignalling*/
465         octet = tvb_get_guint8(tvb,0) & 0xf;
466         if ( octet == 3){ /* This is a V3 message ??? */
467                 offset = offset +2;
468                 offset=dissect_gsm_map_ForwardAccessSignallingArgV3(TRUE, tvb, offset, pinfo, tree, -1);
469         }else{
470                  offset=dissect_gsm_map_Bss_APDU(FALSE, tvb, offset, pinfo, tree, -1);
471         }
472     break;
473   case 37: /*reset*/
474     offset=dissect_gsm_map_ResetArg(FALSE, tvb, offset, pinfo, tree, -1);
475     break;
476   case 38: /*forwardCheckSS-Indication*/
477     return offset;
478     break;
479   case 39: /*prepareGroupCall*/
480     offset=dissect_gsm_map_PrepareGroupCallArg(FALSE, tvb, offset, pinfo, tree, -1);
481     break;
482   case 40: /*sendGroupCallEndSignal*/
483     dissect_gsm_map_SendGroupCallEndSignalArg(FALSE, tvb, offset, pinfo, tree, -1);
484     break;
485   case 42: /*processGroupCallSignalling*/
486     offset=dissect_gsm_map_ProcessGroupCallSignallingArg(FALSE, tvb, offset, pinfo, tree, -1);
487     break;
488   case 43: /*checkIMEI*/
489           if (application_context_version < 2 ){
490                   offset=dissect_gsm_map_CheckIMEIArgV2(FALSE, tvb, offset, pinfo, tree, -1);
491           }else{
492                   offset=dissect_gsm_map_CheckIMEIArgV2(FALSE, tvb, offset, pinfo, tree, -1);
493           }
494     break;
495   case 44: /*mt-forwardSM*/
496     offset=dissect_gsm_map_Mt_forwardSM_Arg(FALSE, tvb, offset, pinfo, tree, -1);
497     break;
498   case 45: /*sendRoutingInfoForSM*/
499     offset=dissect_gsm_map_RoutingInfoForSMArg(FALSE, tvb, offset, pinfo, tree, -1);
500     break;
501   case 46: /*mo-forwardSM*/
502     offset=dissect_gsm_map_Mo_forwardSM_Arg(FALSE, tvb, offset, pinfo, tree, -1);
503     break;
504   case 47: /*reportSM-DeliveryStatus*/
505     offset=dissect_gsm_map_ReportSM_DeliveryStatusArg(FALSE, tvb, offset, pinfo, tree, -1);
506     break;
507   case 50: /*activateTraceMode*/
508     offset=dissect_gsm_map_ActivateTraceModeArg(FALSE, tvb, offset, pinfo, tree, -1);
509     break;
510   case 51: /*deactivateTraceMode*/
511     offset=dissect_gsm_map_DeactivateTraceModeArg(FALSE, tvb, offset, pinfo, tree, -1);
512     break;
513   case 55: /*sendIdentification*/
514     offset=dissect_gsm_map_TMSI(FALSE, tvb, offset, pinfo, tree, -1);
515     break;
516   case 56: /*sendAuthenticationInfo*/
517           if (application_context_version < 2 ){
518                   offset=dissect_gsm_map_SendAuthenticationInfoArg(FALSE, tvb, offset, pinfo, tree, hf_gsm_map_imsi);
519           }else{
520                   offset=dissect_gsm_map_SendAuthenticationInfoArgV2(FALSE, tvb, offset, pinfo, tree, hf_gsm_map_SendAuthenticationInfoArg);
521           }
522         break;
523   case 57: /*restoreData*/
524         offset=dissect_gsm_map_RestoreDataArg(FALSE, tvb, offset, pinfo, tree, -1);
525         break;
526   case 58: /*sendIMSI*/
527         offset = dissect_gsm_map_ISDN_AddressString(FALSE, tvb, offset, pinfo, tree, -1);
528         break;
529   case 59: /*processUnstructuredSS-Request*/
530     offset=dissect_gsm_map_Ussd_Arg(FALSE, tvb, offset, pinfo, tree, -1);
531     break;
532   case 60: /*unstructuredSS-Request*/
533     offset=dissect_gsm_map_Ussd_Arg(FALSE, tvb, offset, pinfo, tree, -1);
534     break;
535   case 61: /*unstructuredSS-Notify*/
536     offset=dissect_gsm_map_Ussd_Arg(FALSE, tvb, offset, pinfo, tree, -1);
537     break;
538   case 62: /*AnyTimeSubscriptionInterrogation*/
539           offset=dissect_gsm_map_AnyTimeSubscriptionInterrogationArg(FALSE, tvb, offset, pinfo, tree, -1);
540           break;
541   case 63: /*informServiceCentre*/
542     offset=dissect_gsm_map_InformServiceCentreArg(FALSE, tvb, offset, pinfo, tree, -1);
543     break;
544   case 64: /*alertServiceCentre*/
545     offset=dissect_gsm_map_AlertServiceCentreArg(FALSE, tvb, offset, pinfo, tree, -1);
546     break;
547   case 65: /*AnyTimeModification*/
548           offset=dissect_gsm_map_AnyTimeModificationArg(FALSE, tvb, offset, pinfo, tree, -1);
549           break;
550   case 66: /*readyForSM*/
551     offset=dissect_gsm_map_ReadyForSM_Arg(FALSE, tvb, offset, pinfo, tree, -1);
552     break;
553   case 67: /*purgeMS*/
554     offset=dissect_gsm_map_PurgeMSArg(FALSE, tvb, offset, pinfo, tree, -1);
555     break;
556   case 68: /*prepareHandover*/
557         octet = tvb_get_guint8(tvb,0) & 0xf;
558         if ( octet == 3){ /* This is a V3 message ??? */
559                 offset = offset +2;
560                 offset=dissect_gsm_map_PrepareHO_ArgV3(TRUE, tvb, offset, pinfo, tree, -1);
561         }else{
562                 offset=dissect_gsm_map_PrepareHO_Arg(FALSE, tvb, offset, pinfo, tree, -1);
563         }
564     break;
565   case 69: /*prepareSubsequentHandover*/
566     offset=dissect_gsm_map_PrepareSubsequentHOArg(FALSE, tvb, offset, pinfo, tree, -1);
567     break;
568   case 70: /*provideSubscriberInfo*/
569     offset=dissect_gsm_map_ProvideSubscriberInfoArg(FALSE, tvb, offset, pinfo, tree, -1);
570     break;
571   case 71: /*anyTimeInterrogation*/
572     offset=dissect_gsm_map_AnyTimeInterrogationArg(FALSE, tvb, offset, pinfo, tree, -1);
573     break;
574   case 72: /*ss-InvocationNotificatio*/
575     offset=dissect_gsm_map_Ss_InvocationNotificationArg(FALSE, tvb, offset, pinfo, tree, -1);
576     break;
577   case 73: /*setReportingState*/
578     offset=dissect_gsm_map_SetReportingStateArg(FALSE, tvb, offset, pinfo, tree, -1);
579     break;
580   case 74: /*statusReport*/
581     offset=dissect_gsm_map_StatusReportArg(FALSE, tvb, offset, pinfo, tree, -1);
582     break;
583   case 75: /*remoteUserFree*/
584     offset=dissect_gsm_map_RemoteUserFreeArg(FALSE, tvb, offset, pinfo, tree, -1);
585     break;
586   case 76: /*registerCC-Entry*/
587     offset=dissect_gsm_map_RegisterCC_EntryArg(FALSE, tvb, offset, pinfo, tree, -1);
588     break;
589   case 77: /*eraseCC-Entry*/
590     offset=dissect_gsm_map_EraseCC_EntryArg(FALSE, tvb, offset, pinfo, tree, -1);
591     break;
592   case 78: /*secureTransportClass1*/
593   case 79: /*secureTransportClass1*/
594   case 80: /*secureTransportClass1*/
595   case 81: /*secureTransportClass1*/
596     offset=dissect_gsm_map_SecureTransportArg(FALSE, tvb, offset, pinfo, tree, -1);
597     break;
598   case 83: /*provideSubscriberLocation*/
599     offset=dissect_gsm_map_EraseCC_EntryArg(FALSE, tvb, offset, pinfo, tree, -1);
600     break;
601     offset=dissect_gsm_map_ProvideSubscriberLocation_Arg(FALSE, tvb, offset, pinfo, tree, -1);
602     break;
603   case 85: /*sendRoutingInfoForLCS*/
604     offset=dissect_gsm_map_RoutingInfoForLCS_Arg(FALSE, tvb, offset, pinfo, tree, -1);
605     break;
606   case 86: /*subscriberLocationReport*/
607     offset=dissect_gsm_map_SubscriberLocationReport_Arg(FALSE, tvb, offset, pinfo, tree, -1);
608     break;
609   case 87: /*ist-Alert*/
610     offset=dissect_gsm_map_IST_AlertArg(FALSE, tvb, offset, pinfo, tree, -1);
611     break;
612   case 88: /*ist-Command*/
613     offset=dissect_gsm_map_IST_CommandArg(FALSE, tvb, offset, pinfo, tree, -1);
614     break;
615   case 89: /*noteMM-Event*/
616     offset=dissect_gsm_map_NoteMM_EventArg(FALSE, tvb, offset, pinfo, tree, -1);
617     break;
618   default:
619     proto_tree_add_text(tree, tvb, offset, -1, "Unknown invokeData blob");
620   }
621   return offset;
622 }
623
624
625 static int dissect_returnResultData(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
626         
627   guint8 octet;
628   switch(opcode){
629   case  2: /*updateLocation*/
630           octet = tvb_get_guint8(tvb,offset);
631           /* As it seems like SEQUENCE OF sometimes is omitted, find out if it's there */
632           if ( octet == 0x30 ){ /* Class 0 Univerasl, P/C 1 Constructed,Tag 16 Sequence OF */
633     offset=dissect_gsm_map_UpdateLocationRes(FALSE, tvb, offset, pinfo, tree, -1);
634           }else{ /* Try decoding with IMPLICIT flag set */ 
635                   offset=dissect_gsm_map_UpdateLocationRes(TRUE, tvb, offset, pinfo, tree, -1);
636           }
637     break;
638   case  3: /*cancelLocation*/
639     offset=dissect_gsm_map_CancelLocationRes(FALSE, tvb, offset, pinfo, tree, -1);
640     break;
641   case  4: /*provideRoamingNumber*/
642     offset=dissect_gsm_map_ProvideRoamingNumberRes(FALSE, tvb, offset, pinfo, tree, -1);
643     break;
644   case  6: /*resumeCallHandling*/
645     offset=dissect_gsm_map_ResumeCallHandlingRes(FALSE, tvb, offset, pinfo, tree, -1);
646     break;
647   case  7: /*insertSubscriberData*/
648     offset=dissect_gsm_map_InsertSubscriberDataRes(FALSE, tvb, offset, pinfo, tree, -1);
649     break;
650   case  8: /*deleteSubscriberData*/
651     offset=dissect_gsm_map_DeleteSubscriberDataRes(FALSE, tvb, offset, pinfo, tree, -1);
652     break;
653         /* TODO find out why this isn't in the ASN1 file
654   case  9: sendParameters
655     offset=dissect_gsm_map_DeleteSubscriberDataArg(FALSE, tvb, offset, pinfo, tree, -1);
656     break;
657         */
658   case  10: /*registerSS*/
659     offset=dissect_gsm_map_SS_Info(FALSE, tvb, offset, pinfo, tree, -1);
660     break;
661   case  11: /*eraseSS*/
662     offset=dissect_gsm_map_SS_Info(FALSE, tvb, offset, pinfo, tree, -1);
663     break;
664   case 12: /*activateSS*/
665     offset=dissect_gsm_map_SS_Info(FALSE, tvb, offset, pinfo, tree, -1);
666     break;
667   case 13: /*deactivateSS*/
668     offset=dissect_gsm_map_SS_Info(FALSE, tvb, offset, pinfo, tree, -1);
669     break;
670   case 14: /*interrogateSS*/
671     offset=dissect_gsm_map_InterrogateSS_Res(FALSE, tvb, offset, pinfo, tree, -1);
672     break;
673   case 15: /*authenticationFailureReport*/
674           offset=dissect_gsm_map_AuthenticationFailureReportArg(FALSE, tvb, offset, pinfo, tree, -1);
675           break;
676   case 17: /*registerPassword*/
677     offset=dissect_gsm_map_NewPassword(FALSE, tvb, offset, pinfo, tree, hf_gsm_map_ss_Code);
678     break;
679   case 18: /*getPassword*/
680     offset=dissect_gsm_map_CurrentPassword(FALSE, tvb, offset, pinfo, tree, hf_gsm_map_currentPassword);
681     break;
682   case 20: /*releaseResources*/
683     offset=dissect_gsm_map_ReleaseResourcesRes(FALSE, tvb, offset, pinfo, tree, -1);
684     break;
685   case 22: /*sendRoutingInfo*/
686           /* This is done to get around a problem with IMPLICIT tag:s */
687     offset = offset +2;
688     offset=dissect_gsm_map_SendRoutingInfoRes(TRUE, tvb, offset, pinfo, tree, -1);
689     break;
690   case 23: /*updateGprsLocation*/
691     offset=dissect_gsm_map_UpdateGprsLocationRes(FALSE, tvb, offset, pinfo, tree, -1);
692     break;
693   case 24: /*sendRoutingInfoForGprs*/
694     offset=dissect_gsm_map_SendRoutingInfoForGprsRes(FALSE, tvb, offset, pinfo, tree, -1);
695     break;
696   case 25: /*failureReport*/
697     offset=dissect_gsm_map_FailureReportRes(FALSE, tvb, offset, pinfo, tree, -1);
698     break;
699   case 26: /*noteMsPresentForGprs*/
700     offset=dissect_gsm_map_NoteMsPresentForGprsRes(FALSE, tvb, offset, pinfo, tree, -1);
701     break;
702   case 29: /*sendEndSignal*/
703           /* Taken from MAP-MobileServiceOperations{ 0 identified-organization (4) etsi (0) mobileDomain 
704            * (0) gsm-Network (1) modules (3) map-MobileServiceOperations (5) version9 (9) }
705            */
706     offset=dissect_gsm_map_SendEndSignalRes(FALSE, tvb, offset, pinfo, tree, -1);
707     break;
708   case 31: /*provideSIWFSNumbe*/
709     offset=dissect_gsm_map_ProvideSIWFSNumberRes(FALSE, tvb, offset, pinfo, tree, -1);
710     break;
711   case 32: /*provideSIWFSNumbe*/
712     offset=dissect_gsm_map_SIWFSSignallingModifyRes(FALSE, tvb, offset, pinfo, tree, -1);
713     break;
714   case 39: /*prepareGroupCall*/
715     offset=dissect_gsm_map_PrepareGroupCallRes(FALSE, tvb, offset, pinfo, tree, -1);
716     break;
717   case 40: /*sendGroupCallEndSignal*/
718     dissect_gsm_map_SendGroupCallEndSignalRes(FALSE, tvb, offset, pinfo, tree, -1);
719     break;
720   case 43: /*checkIMEI*/
721     offset=dissect_gsm_map_CheckIMEIRes(FALSE, tvb, offset, pinfo, tree, -1);
722     break;
723   case 44: /*mt-forwardSM*/
724     offset=dissect_gsm_map_Mt_forwardSM_Res(FALSE, tvb, offset, pinfo, tree, -1);
725     break;
726   case 45: /*sendRoutingInfoForSM*/
727     offset=dissect_gsm_map_RoutingInfoForSM_Res(FALSE, tvb, offset, pinfo, tree, -1);
728     break;
729   case 46: /*mo-forwardSM*/
730     offset=dissect_gsm_map_Mo_forwardSM_Res(FALSE, tvb, offset, pinfo, tree, -1);
731     break;
732   case 48: /*reportSM-DeliveryStatus*/
733     offset=dissect_gsm_map_ReportSM_DeliveryStatusRes(FALSE, tvb, offset, pinfo, tree, -1);
734     break;
735   case 50: /*activateTraceMode*/
736     offset=dissect_gsm_map_ActivateTraceModeRes(FALSE, tvb, offset, pinfo, tree, -1);
737     break;
738   case 51: /*deactivateTraceMode*/
739     offset=dissect_gsm_map_DeactivateTraceModeRes(FALSE, tvb, offset, pinfo, tree, -1);
740     break;
741   case 55: /*sendIdentification*/
742     offset=dissect_gsm_map_SendIdentificationRes(FALSE, tvb, offset, pinfo, tree, -1);
743     break;
744   case 56: /*sendAuthenticationInfo*/
745         octet = tvb_get_guint8(tvb,0) & 0xf;
746         if ( octet == 3){ /* This is a V3 message ??? */
747                 offset = offset +2;
748                 offset=dissect_gsm_map_SendAuthenticationInfoResV3(TRUE, tvb, offset, pinfo, tree, hf_gsm_map_SendAuthenticationInfoRes);
749         }else{
750                 offset=dissect_gsm_map_SendAuthenticationInfoRes(FALSE, tvb, offset, pinfo, tree, -1);
751         }
752         break;
753   case 57: /*restoreData*/
754     offset=dissect_gsm_map_RestoreDataRes(FALSE, tvb, offset, pinfo, tree, -1);
755     break;
756   case 58: /*sendIMSI*/
757     offset=dissect_gsm_map_IMSI(FALSE, tvb, offset, pinfo, tree,hf_gsm_map_imsi);
758     break;
759   case 59: /*unstructuredSS-Request*/
760     offset=dissect_gsm_map_Ussd_Res(FALSE, tvb, offset, pinfo, tree, -1);
761     break;
762   case 60: /*unstructuredSS-Request*/
763     offset=dissect_gsm_map_Ussd_Res(FALSE, tvb, offset, pinfo, tree, -1);
764     break;
765   case 61: /*unstructuredSS-Notify*/
766     /* TRUE ? */
767     proto_tree_add_text(tree, tvb, offset, -1, "Unknown returnResultData blob");
768     break;
769   case 62: /*AnyTimeSubscriptionInterrogation*/
770           offset=dissect_gsm_map_AnyTimeSubscriptionInterrogationRes(FALSE, tvb, offset, pinfo, tree, -1);
771           break;
772   case 65: /*AnyTimeModification*/
773           offset=dissect_gsm_map_AnyTimeModificationRes(FALSE, tvb, offset, pinfo, tree, -1);
774           break;
775   case 66: /*readyForSM*/
776     offset=dissect_gsm_map_ReadyForSM_Res(FALSE, tvb, offset, pinfo, tree, -1);
777     break;
778   case 67: /*purgeMS*/
779     offset=dissect_gsm_map_PurgeMSRes(FALSE, tvb, offset, pinfo, tree, -1);
780     break;
781   case 68: /*prepareHandover*/
782         octet = tvb_get_guint8(tvb,0) & 0xf;
783         if ( octet == 3){ /* This is a V3 message ??? */
784                 offset = offset +2;
785                 offset=dissect_gsm_map_PrepareHO_ResV3(TRUE, tvb, offset, pinfo, tree, hf_gsm_mapSendEndSignal);
786         }else{
787                 offset=dissect_gsm_map_PrepareHO_Res(FALSE, tvb, offset, pinfo, tree, -1);
788         }
789     break;
790   case 69: /*prepareSubsequentHandover*/
791      offset=dissect_gsm_map_Bss_APDU(FALSE, tvb, offset, pinfo, tree, -1);
792     break;
793   case 70: /*provideSubscriberInfo*/
794     offset=dissect_gsm_map_ProvideSubscriberInfoRes(FALSE, tvb, offset, pinfo, tree, -1);
795     break;
796   case 71: /*anyTimeInterrogation*/
797     offset=dissect_gsm_map_AnyTimeInterrogationRes(FALSE, tvb, offset, pinfo, tree, -1);
798     break;
799   case 72: /*ss-InvocationNotificatio*/
800     offset=dissect_gsm_map_Ss_InvocationNotificationRes(FALSE, tvb, offset, pinfo, tree, -1);
801     break;
802   case 73: /*setReportingState*/
803     offset=dissect_gsm_map_SetReportingStateRes(FALSE, tvb, offset, pinfo, tree, -1);
804     break;
805   case 74: /*statusReport*/
806     offset=dissect_gsm_map_StatusReportRes(FALSE, tvb, offset, pinfo, tree, -1);
807     break;
808   case 75: /*remoteUserFree*/
809     offset=dissect_gsm_map_RemoteUserFreeRes(FALSE, tvb, offset, pinfo, tree, -1);
810     break;
811   case 76: /*registerCC-Entry*/
812     offset=dissect_gsm_map_RegisterCC_EntryRes(FALSE, tvb, offset, pinfo, tree, -1);
813     break;
814   case 77: /*eraseCC-Entry*/
815     offset=dissect_gsm_map_EraseCC_EntryRes(FALSE, tvb, offset, pinfo, tree, -1);
816     break;
817   case 78: /*secureTransportClass1*/
818   case 79: /*secureTransportClass2*/
819   case 80: /*secureTransportClass3*/
820   case 81: /*secureTransportClass4*/
821     offset=dissect_gsm_map_SecureTransportRes(FALSE, tvb, offset, pinfo, tree, -1);
822     break;
823   case 83: /*provideSubscriberLocation*/
824     offset=dissect_gsm_map_ProvideSubscriberLocation_Res(FALSE, tvb, offset, pinfo, tree, -1);
825     break;
826   case 85: /*sendRoutingInfoForLCS*/
827     offset=dissect_gsm_map_RoutingInfoForLCS_Arg(FALSE, tvb, offset, pinfo, tree, -1);
828     break;
829   case 86: /*subscriberLocationReport*/
830     offset=dissect_gsm_map_SubscriberLocationReport_Res(FALSE, tvb, offset, pinfo, tree, -1);
831     break;
832   case 87: /*ist-Alert*/
833     offset=dissect_gsm_map_IST_AlertRes(FALSE, tvb, offset, pinfo, tree, -1);
834     break;
835   case 88: /*ist-Command*/
836     offset=dissect_gsm_map_IST_CommandRes(FALSE, tvb, offset, pinfo, tree, -1);
837     break;
838   case 89: /*noteMM-Event*/
839     offset=dissect_gsm_map_NoteMM_EventRes(FALSE, tvb, offset, pinfo, tree, -1);
840     break;
841  default:
842     proto_tree_add_text(tree, tvb, offset, -1, "Unknown returnResultData blob");
843   }
844   return offset;
845 }
846
847 static int 
848 dissect_invokeCmd(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
849   return dissect_gsm_map_Opcode(FALSE, tvb, offset, pinfo, tree, hf_gsm_map_invokeCmd);
850 }
851
852 static int dissect_invokeid(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
853   return dissect_ber_integer(FALSE, pinfo, tree, tvb, offset, hf_gsm_map_invokeid, NULL);
854 }
855
856
857 static const value_string InvokeId_vals[] = {
858   {   0, "invokeid" },
859   {   1, "absent" },
860   { 0, NULL }
861 };
862
863 static int dissect_absent(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
864   return dissect_gsm_map_NULL(FALSE, tvb, offset, pinfo, tree, hf_gsm_map_absent);
865 }
866
867
868 static const ber_choice_t InvokeId_choice[] = {
869   {   0, BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_invokeid },
870   {   1, BER_CLASS_UNI, BER_UNI_TAG_NULL, BER_FLAGS_NOOWNTAG, dissect_absent },
871   { 0, 0, 0, 0, NULL }
872 };
873
874 static int
875 dissect_gsm_map_InvokeId(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
876   offset = dissect_ber_CHOICE(pinfo, tree, tvb, offset,
877                               InvokeId_choice, hf_index, ett_gsm_map_InvokeId, NULL);
878
879   return offset;
880 }
881 static int dissect_invokeId(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
882   return dissect_gsm_map_InvokeId(FALSE, tvb, offset, pinfo, tree, hf_gsm_map_invokeId);
883 }
884
885 static const ber_sequence_t InvokePDU_sequence[] = {
886   { BER_CLASS_UNI, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_invokeId },
887   { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_invokeCmd },
888   { BER_CLASS_UNI, -1/*depends on Cmd*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_invokeData },
889   { 0, 0, 0, NULL }
890 };
891
892 static int
893 dissect_gsm_map_InvokePDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
894   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
895                                 InvokePDU_sequence, hf_index, ett_gsm_map_InvokePDU);
896
897   return offset;
898 }
899 static int dissect_invoke_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
900   return dissect_gsm_map_InvokePDU(TRUE, tvb, offset, pinfo, tree, hf_gsm_map_invoke);
901 }
902
903 static const ber_sequence_t ReturnResult_result_sequence[] = {
904   { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_invokeCmd },
905   { BER_CLASS_UNI, -1/*depends on Cmd*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_returnResultData },
906   { 0, 0, 0, NULL }
907 };
908 static int
909 dissect_returnResult_result(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
910   offset = dissect_ber_sequence(FALSE, pinfo, tree, tvb, offset,
911                                 ReturnResult_result_sequence, hf_gsm_map_returnResult_result, ett_gsm_map_ReturnResult_result);
912
913   return offset;
914 }
915
916 static const ber_sequence_t ReturnResultPDU_sequence[] = {
917   { BER_CLASS_UNI, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_invokeId },
918   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_returnResult_result },
919   { 0, 0, 0, NULL }
920 };
921
922 static int
923 dissect_gsm_map_returnResultPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
924   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
925                                 ReturnResultPDU_sequence, hf_index, ett_gsm_map_ReturnResultPDU);
926
927   return offset;
928 }
929 static int dissect_returnResult_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
930   return dissect_gsm_map_returnResultPDU(TRUE, tvb, offset, pinfo, tree, hf_gsm_map_returnResult);
931 }
932
933 static int
934 dissect_local_errorCode(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
935   return dissect_ber_integer(FALSE, pinfo, tree, tvb, offset, hf_gsm_map_local_errorCode, NULL);
936 }
937
938 static int
939 dissect_global_errorCode(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
940   offset =  dissect_ber_object_identifier(FALSE, pinfo, tree, tvb, offset,
941                                          hf_gsm_map_global_errorCode_oid, NULL);
942   return dissect_ber_integer(FALSE, pinfo, tree, tvb, offset, hf_gsm_map_global_errorCode, NULL);
943 }
944 static const ber_choice_t ReturnError_result_choice[] = {
945   {   0, BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_local_errorCode },
946   {   1, BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_global_errorCode },
947   {   0, 0, 0, 0, NULL }
948 };
949
950
951 static int
952 dissect_ReturnError_result(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
953
954   offset = dissect_ber_CHOICE(pinfo, tree, tvb, offset,
955                               ReturnError_result_choice, hf_gsm_map_returnError_result, ett_gsm_map_ReturnError_result, NULL);
956
957   return offset;
958 }
959
960 static const ber_sequence_t ReturnErrorPDU_sequence[] = {
961   { BER_CLASS_UNI, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_invokeId },
962   { BER_CLASS_UNI, -1/*choice*/,BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_ReturnError_result },
963   { 0, 0, 0, NULL }
964 };
965
966 static int
967 dissect_gsm_map_ReturnErrorPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
968   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
969                                 ReturnErrorPDU_sequence, hf_index, ett_gsm_map_ReturnErrorPDU);
970
971   return offset;
972 }
973 static int dissect_returnError_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
974   return dissect_gsm_map_ReturnErrorPDU(TRUE, tvb, offset, pinfo, tree, hf_gsm_map_returnError);
975 }
976
977
978 static const value_string GSMMAPPDU_vals[] = {
979   {   1, "Invoke " },
980   {   2, "ReturnResult " },
981   {   3, "ReturnError " },
982   {   4, "Reject " },
983   { 0, NULL }
984 };
985
986 static const ber_choice_t GSMMAPPDU_choice[] = {
987   {   1, BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_invoke_impl },
988   {   2, BER_CLASS_CON, 2, BER_FLAGS_IMPLTAG, dissect_returnResult_impl },
989   {   3, BER_CLASS_CON, 3, BER_FLAGS_IMPLTAG, dissect_returnError_impl },
990 #ifdef REMOVED
991   {   4, BER_CLASS_CON, 4, BER_FLAGS_IMPLTAG, dissect_reject_impl },
992 #endif
993   { 0, 0, 0, 0, NULL }
994 };
995
996 static guint8 gsmmap_pdu_type = 0;
997 static guint8 gsm_map_pdu_size = 0;
998
999 static int
1000 dissect_gsm_map_GSMMAPPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo , proto_tree *tree, int hf_index) {
1001
1002   char *version_ptr, *version_str;
1003
1004   opcode = 0;
1005   application_context_version = 0;
1006   if (pinfo->private_data != NULL){
1007     version_ptr = strrchr(pinfo->private_data,'.');
1008         if (version_ptr) {
1009                 version_str = g_strdup(version_ptr+1);
1010                 application_context_version = atoi(version_str);
1011         }
1012   }
1013
1014   gsmmap_pdu_type = tvb_get_guint8(tvb, offset)&0x0f;
1015   /* Get the length and add 2 */
1016   gsm_map_pdu_size = tvb_get_guint8(tvb, offset+1)+2;
1017
1018   if (check_col(pinfo->cinfo, COL_INFO)){
1019     col_set_str(pinfo->cinfo, COL_INFO, val_to_str(gsmmap_pdu_type, GSMMAPPDU_vals, "Unknown GSM-MAP PDU (%u)"));
1020   }
1021
1022   offset = dissect_ber_CHOICE(pinfo, tree, tvb, offset,
1023                               GSMMAPPDU_choice, hf_index, ett_gsm_map_GSMMAPPDU, NULL);
1024
1025
1026   return offset;
1027 }
1028
1029
1030
1031
1032 static void
1033 dissect_gsm_map(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
1034 {
1035     proto_item          *item=NULL;
1036     proto_tree          *tree=NULL;
1037     /* Used for gsm_map TAP */
1038     static              gsm_map_tap_rec_t tap_rec;
1039     gint                op_idx;
1040
1041
1042     if (check_col(pinfo->cinfo, COL_PROTOCOL))
1043     {
1044         col_set_str(pinfo->cinfo, COL_PROTOCOL, "GSM MAP");
1045     }
1046
1047     top_tree = parent_tree;
1048     dissector_add("tcap.itu_ssn",pinfo->match_port, map_handle);
1049     /* create display subtree for the protocol */
1050     if(parent_tree){
1051         item = proto_tree_add_item(parent_tree, proto_gsm_map, tvb, 0, -1, FALSE);
1052         tree = proto_item_add_subtree(item, ett_gsm_map);
1053     }
1054
1055     dissect_gsm_map_GSMMAPPDU(FALSE, tvb, 0, pinfo, tree, -1);
1056     match_strval_idx(opcode, gsm_map_opr_code_strings, &op_idx);
1057
1058     tap_rec.invoke = FALSE;
1059     if ( gsmmap_pdu_type  == 1 )
1060         tap_rec.invoke = TRUE;
1061     tap_rec.opr_code_idx = op_idx;
1062     tap_rec.size = gsm_map_pdu_size;
1063
1064     tap_queue_packet(gsm_map_tap, pinfo, &tap_rec);
1065 }
1066
1067 static const value_string ssCode_vals[] = {
1068   { 0x00, "allSS - all SS" },
1069   { 0x10 ,"allLineIdentificationSS - all line identification SS" },
1070   { 0x11 ,"clip - calling line identification presentation" },
1071   { 0x12 ,"clir - calling line identification restriction" },
1072   { 0x13 ,"colp - connected line identification presentation" },
1073   { 0x14 ,"colr - connected line identification restriction" },
1074   { 0x15 ,"mci - malicious call identification" },
1075   { 0x18 ,"allNameIdentificationSS - all name indentification SS" },
1076   { 0x19 ,"cnap - calling name presentation" },
1077   { 0x20 ,"allForwardingSS - all forwarding SS" },
1078   { 0x21 ,"cfu - call forwarding unconditional" },
1079   { 0x28 ,"allCondForwardingSS - all conditional forwarding SS" },
1080   { 0x29 ,"cfb - call forwarding busy" },
1081   { 0x2a ,"cfnry - call forwarding on no reply" },
1082   { 0x2b ,"cfnrc - call forwarding on mobile subscriber not reachable" },
1083   { 0x24 ,"cd - call deflection" },
1084   { 0x30 ,"allCallOfferingSS - all call offering SS includes also all forwarding SS" },
1085   { 0x31 ,"ect - explicit call transfer" },
1086   { 0x32 ,"mah - mobile access hunting" },
1087   { 0x40 ,"allCallCompletionSS - all Call completion SS" },
1088   { 0x41 ,"cw - call waiting" },
1089   { 0x42 ,"hold - call hold" },
1090   { 0x43 ,"ccbs-A - completion of call to busy subscribers, originating side" },
1091   { 0x44 ,"ccbs-B - completion of call to busy subscribers, destination side" },
1092   { 0x45 ,"mc - multicall" },
1093   { 0x50 ,"allMultiPartySS - all multiparty SS" },
1094   { 0x51 ,"multiPTY - multiparty" },
1095   { 0x60 ,"allCommunityOfInterestSS - all community of interest SS" },
1096   { 0x61 ,"cug - closed user group" },
1097   { 0x70 ,"allChargingSS - all charging SS" },
1098   { 0x71 ,"aoci - advice of charge information" },
1099   { 0x72 ,"aocc - advice of charge charging" },
1100   { 0x80 ,"allAdditionalInfoTransferSS - all additional information transfer SS" },
1101   { 0x81 ,"uus1 - UUS1 user-to-user signalling" },
1102   { 0x82 ,"uus2 - UUS2 user-to-user signalling" },
1103   { 0x83 ,"uus3 - UUS3 user-to-user signalling" },
1104   { 0x90 ,"allCallRestrictionSS - all Callrestriction SS" },
1105   { 0x91 ,"barringOfOutgoingCalls" },
1106   { 0x92 ,"baoc - barring of all outgoing calls" },
1107   { 0x93 ,"boic - barring of outgoing international calls" },
1108   { 0x94 ,"boicExHC - barring of outgoing international calls except those directed to the home PLMN" },
1109   { 0x99 ,"barringOfIncomingCalls" },
1110   { 0x9a ,"baic - barring of all incoming calls" },
1111   { 0x9b ,"bicRoam - barring of incoming calls when roaming outside home PLMN Country" },
1112   { 0xf0 ,"allPLMN-specificSS" },
1113   { 0xa0 ,"allCallPrioritySS - all call priority SS" },
1114   { 0xa1 ,"emlpp - enhanced Multilevel Precedence Pre-emption (EMLPP) service" },
1115   { 0xb0 ,"allLCSPrivacyException - all LCS Privacy Exception Classes" },
1116   { 0xb1 ,"universal - allow location by any LCS client" },
1117   { 0xb2 ,"callrelated - allow location by any value added LCS client to which a call is established from the target MS" },
1118   { 0xb3 ,"callunrelated - allow location by designated external value added LCS clients" },
1119   { 0xb4 ,"plmnoperator - allow location by designated PLMN operator LCS clients" },
1120   { 0xc0 ,"allMOLR-SS - all Mobile Originating Location Request Classes" },
1121   { 0xc1 ,"basicSelfLocation - allow an MS to request its own location" },
1122   { 0xc2 ,"autonomousSelfLocation - allow an MS to perform self location without interaction with the PLMN for a predetermined period of time" },
1123   { 0xc3 ,"transferToThirdParty - allow an MS to request transfer of its location to another LCS client" },
1124
1125   { 0xf1 ,"plmn-specificSS-1" },
1126   { 0xf2 ,"plmn-specificSS-2" },
1127   { 0xf3 ,"plmn-specificSS-3" },
1128   { 0xf4 ,"plmn-specificSS-4" },
1129   { 0xf5 ,"plmn-specificSS-5" },
1130   { 0xf6 ,"plmn-specificSS-6" },
1131   { 0xf7 ,"plmn-specificSS-7" },
1132   { 0xf8 ,"plmn-specificSS-8" },
1133   { 0xf9 ,"plmn-specificSS-9" },
1134   { 0xfa ,"plmn-specificSS-a" },
1135   { 0xfb ,"plmn-specificSS-b" },
1136   { 0xfc ,"plmn-specificSS-c" },
1137   { 0xfd ,"plmn-specificSS-d" },
1138   { 0xfe ,"plmn-specificSS-e" },
1139   { 0xff ,"plmn-specificSS-f" },
1140   { 0, NULL }
1141 };
1142
1143 static const value_string Teleservice_vals[] = {
1144 {0x00, "allTeleservices" },
1145 {0x10, "allSpeechTransmissionServices" },
1146 {0x11, "telephony" },
1147 {0x12, "emergencyCalls" },
1148 {0x20, "allShortMessageServices" },
1149 {0x21, "shortMessageMT-PP" },
1150 {0x22, "shortMessageMO-PP" },
1151 {0x60, "allFacsimileTransmissionServices" },
1152 {0x61, "facsimileGroup3AndAlterSpeech" },
1153 {0x62, "automaticFacsimileGroup3" },
1154 {0x63, "facsimileGroup4" },
1155
1156 {0x70, "allDataTeleservices" },
1157 {0x80, "allTeleservices-ExeptSMS" },
1158
1159 {0x90, "allVoiceGroupCallServices" },
1160 {0x91, "voiceGroupCall" },
1161 {0x92, "voiceBroadcastCall" },
1162
1163 {0xd0, "allPLMN-specificTS" },
1164 {0xd1, "plmn-specificTS-1" },
1165 {0xd2, "plmn-specificTS-2" },
1166 {0xd3, "plmn-specificTS-3" },
1167 {0xd4, "plmn-specificTS-4" },
1168 {0xd5, "plmn-specificTS-5" },
1169 {0xd6, "plmn-specificTS-6" },
1170 {0xd7, "plmn-specificTS-7" },
1171 {0xd8, "plmn-specificTS-8" },
1172 {0xd9, "plmn-specificTS-9" },
1173 {0xda, "plmn-specificTS-A" },
1174 {0xdb, "plmn-specificTS-B" },
1175 {0xdc, "plmn-specificTS-C" },
1176 {0xdd, "plmn-specificTS-D" },
1177 {0xde, "plmn-specificTS-E" },
1178 {0xdf, "plmn-specificTS-F" },
1179   { 0, NULL }
1180 };
1181
1182 static const value_string Bearerservice_vals[] = {
1183 {0x00, "allBearerServices" },
1184 {0x10, "allDataCDA-Services" },
1185 {0x11, "dataCDA-300bps" },
1186 {0x12, "dataCDA-1200bps" },
1187 {0x13, "dataCDA-1200-75bps" },
1188 {0x14, "dataCDA-2400bps" },
1189 {0x15, "dataCDA-4800bps" },
1190 {0x16, "dataCDA-9600bps" },
1191 {0x17, "general-dataCDA" },
1192
1193 {0x18, "allDataCDS-Services" },
1194 {0x1A, "dataCDS-1200bps" },
1195 {0x1C, "dataCDS-2400bps" },
1196 {0x1D, "dataCDS-4800bps" },
1197 {0x1E, "dataCDS-9600bps" },
1198 {0x1F, "general-dataCDS" },
1199
1200 {0x20, "allPadAccessCA-Services" },
1201 {0x21, "padAccessCA-300bps" },
1202 {0x22, "padAccessCA-1200bps" },
1203 {0x23, "padAccessCA-1200-75bps" },
1204 {0x24, "padAccessCA-2400bps" },
1205 {0x25, "padAccessCA-4800bps" },
1206 {0x26, "padAccessCA-9600bps" },
1207 {0x27, "general-padAccessCA" },
1208
1209 {0x28, "allDataPDS-Services" },
1210 {0x2C, "dataPDS-2400bps" },
1211 {0x2D, "dataPDS-4800bps" },
1212 {0x2E, "dataPDS-9600bps" },
1213 {0x2F, "general-dataPDS" },
1214
1215 {0x30, "allAlternateSpeech-DataCDA" },
1216 {0x38, "allAlternateSpeech-DataCDS" },
1217 {0x40, "allSpeechFollowedByDataCDA" },
1218 {0x48, "allSpeechFollowedByDataCDS" },
1219
1220 {0x50, "allDataCircuitAsynchronous" },
1221 {0x60, "allAsynchronousServices" },
1222 {0x58, "allDataCircuitSynchronous" },
1223 {0x68, "allSynchronousServices" },
1224
1225 {0xD0, "allPLMN-specificBS" },
1226 {0xD1, "plmn-specificBS-1" },
1227 {0xD2, "plmn-specificBS-2" },
1228 {0xD3, "plmn-specificBS-3" },
1229 {0xD4, "plmn-specificBS-4" },
1230 {0xD5, "plmn-specificBS-5" },
1231 {0xD6, "plmn-specificBS-6" },
1232 {0xD7, "plmn-specificBS-7" },
1233 {0xD8, "plmn-specificBS-8" },
1234 {0xD9, "plmn-specificBS-9" },
1235 {0xDA, "plmn-specificBS-A" },
1236 {0xDB, "plmn-specificBS-B" },
1237 {0xDC, "plmn-specificBS-C" },
1238 {0xDD, "plmn-specificBS-D" },
1239 {0xDE, "plmn-specificBS-E" },
1240 {0xDF, "plmn-specificBS-F" },
1241
1242 { 0, NULL }
1243 };
1244
1245 /*--- proto_reg_handoff_gsm_map ---------------------------------------*/
1246 static void range_delete_callback(guint32 ssn)
1247 {
1248     if (ssn) {
1249         dissector_delete("tcap.itu_ssn", ssn, map_handle);
1250     }
1251 }
1252
1253 static void range_add_callback(guint32 ssn)
1254 {
1255     if (ssn) {
1256         dissector_add("tcap.itu_ssn", ssn, map_handle);
1257     }
1258 }
1259
1260 void proto_reg_handoff_gsm_map(void) {
1261
1262     static int map_prefs_initialized = FALSE;
1263     data_handle = find_dissector("data");
1264
1265     if (!map_prefs_initialized) {
1266         map_prefs_initialized = TRUE;
1267         map_handle = create_dissector_handle(dissect_gsm_map, proto_gsm_map);
1268   register_ber_oid_dissector_handle("0.4.0.0.1.0.1.3", map_handle, proto_gsm_map, "itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) networkLocUp(1) version3(3)");  
1269   register_ber_oid_dissector_handle("0.4.0.0.1.0.1.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) networkLocUp(1) version2(2)" );
1270   register_ber_oid_dissector_handle("0.4.0.0.1.0.2.3", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) locationCancel(2) version3(3)" );
1271   register_ber_oid_dissector_handle("0.4.0.0.1.0.2.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) locationCancel(2) version2(2)" );
1272   register_ber_oid_dissector_handle("0.4.0.0.1.0.2.1", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) locationCancel(2) version1(1)" );
1273   register_ber_oid_dissector_handle("0.4.0.0.1.0.3.3", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) roamingNbEnquiry(3) version3(3)" );
1274   register_ber_oid_dissector_handle("0.4.0.0.1.0.3.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) roamingNbEnquiry(3) version2(2)" );
1275   register_ber_oid_dissector_handle("0.4.0.0.1.0.3.1", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) roamingNbEnquiry(3) version1(1)" );
1276   register_ber_oid_dissector_handle("0.4.0.0.1.0.5.3", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) locInfoRetrieval(5) version3(3)" );
1277   register_ber_oid_dissector_handle("0.4.0.0.1.0.5.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) locInfoRetrieval(5) version2(2)" );
1278   register_ber_oid_dissector_handle("0.4.0.0.1.0.5.1", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) locInfoRetrieval(5) version1(1)" );
1279   register_ber_oid_dissector_handle("0.4.0.0.1.0.6.4", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) callControlTransfer(6) version4(4)" );
1280   register_ber_oid_dissector_handle("0.4.0.0.1.0.7.3", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) reporting(7) version3(3)" );
1281   register_ber_oid_dissector_handle("0.4.0.0.1.0.8.3", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) callCompletion(8) version3(3)" );
1282   register_ber_oid_dissector_handle("0.4.0.0.1.0.10.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) reset(10) version2(2)" );
1283   register_ber_oid_dissector_handle("0.4.0.0.1.0.10.1", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) reset(10) version1(1)" );
1284   register_ber_oid_dissector_handle("0.4.0.0.1.0.11.3", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) handoverControl(11) version3(3)" );
1285   register_ber_oid_dissector_handle("0.4.0.0.1.0.11.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) handoverControl(11) version2(2)" );
1286   register_ber_oid_dissector_handle("0.4.0.0.1.0.11.1", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) handoverControl(11) version1(1)" );
1287   register_ber_oid_dissector_handle("0.4.0.0.1.0.12.3", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) sIWFSAllocation(12) version3(3)" );
1288   register_ber_oid_dissector_handle("0.4.0.0.1.0.13.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) equipmentMngt(13) version2(2)" );
1289   register_ber_oid_dissector_handle("0.4.0.0.1.0.13.1", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) equipmentMngt(13) version1(1)" );
1290   register_ber_oid_dissector_handle("0.4.0.0.1.0.14.3", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) infoRetrieval(14) version3(3)" );
1291   register_ber_oid_dissector_handle("0.4.0.0.1.0.14.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) infoRetrieval(14) version2(2)" );
1292   register_ber_oid_dissector_handle("0.4.0.0.1.0.14.1", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) infoRetrieval(14) version1(1)" );
1293   register_ber_oid_dissector_handle("0.4.0.0.1.0.15.1", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) interVlrInfoRetrieval(15) version2(2)" );
1294   register_ber_oid_dissector_handle("0.4.0.0.1.0.16.3", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) subscriberDataMngt(16) version3(3)" );
1295   register_ber_oid_dissector_handle("0.4.0.0.1.0.16.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) subscriberDataMngt(16) version2(2)" );
1296   register_ber_oid_dissector_handle("0.4.0.0.1.0.16.1", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) subscriberDataMngt(16) version1(1)" );
1297   register_ber_oid_dissector_handle("0.4.0.0.1.0.17.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) tracing(17) version2(2)" );
1298   register_ber_oid_dissector_handle("0.4.0.0.1.0.17.1", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) tracing(17) version1(1)" );
1299   register_ber_oid_dissector_handle("0.4.0.0.1.0.18.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) networkFunctionalSs(18) version2(2)" );
1300   register_ber_oid_dissector_handle("0.4.0.0.1.0.18.1", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) networkFunctionalSs(18) version1(1)" );
1301   register_ber_oid_dissector_handle("0.4.0.0.1.0.19.1", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) networkUnstructuredSs(19) version2(2)" );
1302   register_ber_oid_dissector_handle("0.4.0.0.1.0.20.3", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) shortMsgGateway(20) version3(3)" );
1303   register_ber_oid_dissector_handle("0.4.0.0.1.0.20.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) shortMsgGateway(20) version2(2)" );
1304   register_ber_oid_dissector_handle("0.4.0.0.1.0.20.1", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) shortMsgGateway(20) version1(1)" );
1305   register_ber_oid_dissector_handle("0.4.0.0.1.0.21.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) shortMsgMO-Relay(21) version2(2)" );
1306   register_ber_oid_dissector_handle("0.4.0.0.1.0.21.1", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) --shortMsgRelay--21 version1(1)" );
1307   register_ber_oid_dissector_handle("0.4.0.0.1.0.22.3", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) subscriberDataModificationNotification(22) version3(3)" );
1308   register_ber_oid_dissector_handle("0.4.0.0.1.0.23.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) shortMsgAlert(23) version2(2)" );
1309   register_ber_oid_dissector_handle("0.4.0.0.1.0.23.1", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) shortMsgAlert(23) version1(1)" );
1310   register_ber_oid_dissector_handle("0.4.0.0.1.0.24.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) mwdMngt(24) version2(2)" );
1311   register_ber_oid_dissector_handle("0.4.0.0.1.0.24.1", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) mwdMngt(24) version1(1)" );
1312   register_ber_oid_dissector_handle("0.4.0.0.1.0.25.3", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) shortMsgMT-Relay(25) version3(3)" );
1313   register_ber_oid_dissector_handle("0.4.0.0.1.0.25.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) shortMsgMT-Relay(25) version2(2)" );
1314   register_ber_oid_dissector_handle("0.4.0.0.1.0.26.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) imsiRetrieval(26) version2(2)" );
1315   register_ber_oid_dissector_handle("0.4.0.0.1.0.25.1", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) msPurging(27) version2(2)" );
1316   register_ber_oid_dissector_handle("0.4.0.0.1.0.29.3", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) anyTimeInfoEnquiry(29) version3(3)" );
1317   register_ber_oid_dissector_handle("0.4.0.0.1.0.31.2", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) oupCallControl(31) version3(3)" );
1318   register_ber_oid_dissector_handle("0.4.0.0.1.0.32.3", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) gprsLocationUpdate(32) version3(3)" );
1319   register_ber_oid_dissector_handle("0.4.0.0.1.0.33.4", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) rsLocationInfoRetrieval(33) version4(4)" );
1320   register_ber_oid_dissector_handle("0.4.0.0.1.0.34.3", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) failureReport(34) version3(3)" );
1321   register_ber_oid_dissector_handle("0.4.0.0.1.0.36.3", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) ss-InvocationNotification(36) version3(3)" );
1322   register_ber_oid_dissector_handle("0.4.0.0.1.0.37.3", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) locationSvcGateway(37) version3(3)" );
1323   register_ber_oid_dissector_handle("0.4.0.0.1.0.38.3", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) locationSvcEnquiry(38) version3(3)" );
1324   register_ber_oid_dissector_handle("0.4.0.0.1.0.39.3", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) authenticationFailureReport(39) version3(3)" );
1325   register_ber_oid_dissector_handle("0.4.0.0.1.0.40.3", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) secureTransportHandling(40) version3(3)" );
1326   register_ber_oid_dissector_handle("0.4.0.0.1.0.42.3", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) mm-EventReporting(42) version3(3)" );
1327   register_ber_oid_dissector_handle("0.4.0.0.1.0.43.3", map_handle, proto_gsm_map,"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) anyTimeInfoHandling(43) version3(3)" );
1328     }
1329     else {
1330         range_foreach(ssn_range, range_delete_callback);
1331     }
1332
1333     g_free(ssn_range);
1334     ssn_range = range_copy(global_ssn_range);
1335
1336     range_foreach(ssn_range, range_add_callback);
1337
1338 }
1339
1340 /*--- proto_register_gsm_map -------------------------------------------*/
1341 void proto_register_gsm_map(void) {
1342         module_t *gsm_map_module;
1343
1344   /* List of fields */
1345   static hf_register_info hf[] = {
1346     { &hf_gsm_map_invokeCmd,
1347       { "invokeCmd", "gsm_map.invokeCmd",
1348         FT_UINT32, BASE_DEC, VALS(gsm_map_opr_code_strings), 0,
1349         "InvokePDU/invokeCmd", HFILL }},
1350     { &hf_gsm_map_invokeid,
1351       { "invokeid", "gsm_map.invokeid",
1352         FT_INT32, BASE_DEC, NULL, 0,
1353         "InvokeId/invokeid", HFILL }},
1354     { &hf_gsm_map_absent,
1355       { "absent", "gsm_map.absent",
1356         FT_NONE, BASE_NONE, NULL, 0,
1357         "InvokeId/absent", HFILL }},
1358     { &hf_gsm_map_invokeId,
1359       { "invokeId", "gsm_map.invokeId",
1360         FT_UINT32, BASE_DEC, VALS(InvokeId_vals), 0,
1361         "InvokePDU/invokeId", HFILL }},
1362         { &hf_gsm_map_SendAuthenticationInfoArg,
1363       { "SendAuthenticationInfoArg", "gsm_map.SendAuthenticationInfoArg",
1364         FT_BYTES, BASE_NONE, NULL, 0,
1365         "SendAuthenticationInfoArg", HFILL }},
1366         { &hf_gsm_map_SendAuthenticationInfoRes,
1367       { "SendAuthenticationInfoRes", "gsm_map.SendAuthenticationInfoRes",
1368         FT_BYTES, BASE_NONE, NULL, 0,
1369         "SendAuthenticationInfoRes", HFILL }},
1370     { &hf_gsm_map_currentPassword,
1371       { "currentPassword", "gsm_map.currentPassword",
1372         FT_STRING, BASE_NONE, NULL, 0,
1373         "", HFILL }},
1374         { &hf_gsm_mapSendEndSignal,
1375       { "mapSendEndSignalArg", "gsm_map.mapsendendsignalarg",
1376         FT_BYTES, BASE_NONE, NULL, 0,
1377         "mapSendEndSignalArg", HFILL }},
1378     { &hf_gsm_map_invoke,
1379       { "invoke", "gsm_map.invoke",
1380         FT_NONE, BASE_NONE, NULL, 0,
1381         "GSMMAPPDU/invoke", HFILL }},
1382     { &hf_gsm_map_returnResult,
1383       { "returnResult", "gsm_map.returnResult",
1384         FT_NONE, BASE_NONE, NULL, 0,
1385         "GSMMAPPDU/returnResult", HFILL }},
1386         {&hf_gsm_map_returnResult_result,
1387       { "returnResult_result", "gsm_map.returnresultresult",
1388         FT_BYTES, BASE_NONE, NULL, 0,
1389         "returnResult_result", HFILL }},
1390         {&hf_gsm_map_returnError_result,
1391       { "returnError_result", "gsm_map.returnerrorresult",
1392         FT_UINT32, BASE_DEC, NULL, 0,
1393         "returnError_result", HFILL }},
1394         {&hf_gsm_map_returnError,
1395       { "returnError", "gsm_map.returnError",
1396         FT_NONE, BASE_NONE, NULL, 0,
1397         "GSMMAPPDU/returnError", HFILL }},
1398         {&hf_gsm_map_local_errorCode,
1399       { "Local Error Code", "gsm_map.localerrorCode",
1400         FT_UINT32, BASE_DEC, VALS(gsm_map_err_code_string_vals), 0,
1401         "localerrorCode", HFILL }},
1402         {&hf_gsm_map_global_errorCode_oid,
1403       { "Global Error Code OID", "gsm_map.hlobalerrorCodeoid",
1404         FT_BYTES, BASE_NONE, NULL, 0,
1405         "globalerrorCodeoid", HFILL }},
1406         {&hf_gsm_map_global_errorCode,
1407       { "Global Error Code", "gsm_map.globalerrorCode",
1408         FT_UINT32, BASE_DEC, NULL, 0,
1409         "globalerrorCode", HFILL }},
1410     { &hf_gsm_map_getPassword,
1411       { "Password", "gsm_map.password",
1412         FT_UINT8, BASE_DEC, VALS(gsm_map_GetPasswordArg_vals), 0,
1413         "Password", HFILL }},
1414     { &hf_gsm_map_extension,
1415       { "Extension", "gsm_map.extension",
1416         FT_BOOLEAN, 8, TFS(&gsm_map_extension_value), 0x80,
1417         "Extension", HFILL }},
1418     { &hf_gsm_map_nature_of_number,
1419       { "Nature of number", "gsm_map.nature_of_number",
1420         FT_UINT8, BASE_HEX, VALS(gsm_map_nature_of_number_values), 0x70,
1421         "ature of number", HFILL }},
1422     { &hf_gsm_map_number_plan,
1423       { "Number plan", "gsm_map.number_plan",
1424         FT_UINT8, BASE_HEX, VALS(gsm_map_number_plan_values), 0x0f,
1425         "Number plan", HFILL }},
1426         { &hf_gsm_map_isdn_address_digits,
1427       { "ISDN Address digits", "gsm_map.isdn.adress.digits",
1428         FT_STRING, BASE_NONE, NULL, 0,
1429         "ISDN Address digits", HFILL }},
1430         { &hf_gsm_map_servicecentreaddress_digits,
1431       { "ServiceCentreAddress digits", "gsm_map.servicecentreaddress_digits",
1432         FT_STRING, BASE_NONE, NULL, 0,
1433         "ServiceCentreAddress digits", HFILL }},
1434         { &hf_gsm_map_imsi_digits,
1435       { "Imsi digits", "gsm_map.imsi_digits",
1436         FT_STRING, BASE_NONE, NULL, 0,
1437         "Imsi digits", HFILL }},
1438         { &hf_gsm_map_Ss_Status_unused,
1439       { "Unused", "gsm_map.unused",
1440         FT_UINT8, BASE_HEX, NULL, 0xf0,
1441         "Unused", HFILL }},
1442         { &hf_gsm_map_Ss_Status_q_bit,
1443       { "Q bit", "gsm_map.ss_status_q_bit",
1444         FT_BOOLEAN, 8, TFS(&gsm_map_Ss_Status_q_bit_values), 0x08,
1445         "Q bit", HFILL }},
1446         { &hf_gsm_map_Ss_Status_p_bit,
1447       { "P bit", "gsm_map.ss_status_p_bit",
1448         FT_BOOLEAN, 8, TFS(&gsm_map_Ss_Status_p_values), 0x04,
1449         "P bit", HFILL }},
1450         { &hf_gsm_map_Ss_Status_r_bit,
1451       { "R bit", "gsm_map.ss_status_r_bit",
1452         FT_BOOLEAN, 8, TFS(&gsm_map_Ss_Status_r_values), 0x02,
1453         "R bit", HFILL }},
1454         { &hf_gsm_map_Ss_Status_a_bit,
1455       { "A bit", "gsm_map.ss_status_a_bit",
1456         FT_BOOLEAN, 8, TFS(&gsm_map_Ss_Status_a_values), 0x01,
1457         "A bit", HFILL }},
1458
1459 #include "packet-gsm_map-hfarr.c"
1460   };
1461
1462   /* List of subtrees */
1463   static gint *ett[] = {
1464     &ett_gsm_map,
1465     &ett_gsm_map_InvokeId,
1466     &ett_gsm_map_InvokePDU,
1467     &ett_gsm_map_ReturnResultPDU,
1468         &ett_gsm_map_ReturnErrorPDU,
1469     &ett_gsm_map_ReturnResult_result,
1470         &ett_gsm_map_ReturnError_result,
1471     &ett_gsm_map_GSMMAPPDU,
1472 #include "packet-gsm_map-ettarr.c"
1473   };
1474
1475   /* Register protocol */
1476   proto_gsm_map = proto_register_protocol(PNAME, PSNAME, PFNAME);
1477 /*XXX  register_dissector("gsm_map", dissect_gsm_map, proto_gsm_map);*/
1478   /* Register fields and subtrees */
1479   proto_register_field_array(proto_gsm_map, hf, array_length(hf));
1480   proto_register_subtree_array(ett, array_length(ett));
1481
1482   sms_dissector_table = register_dissector_table("gsm_map.sms_tpdu", 
1483                                                  "GSM SMS TPDU", FT_UINT8,
1484                                                  BASE_DEC);
1485
1486   gsm_map_tap = register_tap("gsm_map");
1487   /*register_ber_oid_name("0.4.0.0.1.0.1.3","itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) map-ac(0) networkLocUp(1) version3(3)" );
1488    *
1489    * Register our configuration options, particularly our ssn:s
1490    * Set default SSNs
1491    */
1492   range_convert_str(&global_ssn_range, "6-9", MAX_SSN);
1493   ssn_range = range_empty();
1494
1495
1496   gsm_map_module = prefs_register_protocol(proto_gsm_map, proto_reg_handoff_gsm_map);
1497
1498   prefs_register_range_preference(gsm_map_module, "tcap.ssn", "TCAP SSNs",
1499                                   "TCAP Subsystem numbers used for GSM MAP",
1500                                   &global_ssn_range, MAX_SSN);
1501 }
1502
1503