2c5d9a86a8b2721ddb230eeb409d4e4b570adaed
[obnox/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           if (application_context_version < 2 ){
746                   offset=dissect_gsm_map_SendAuthenticationInfoRes(FALSE, tvb, offset, pinfo, tree, hf_gsm_map_SendAuthenticationInfoRes);
747           }else{
748                   offset=dissect_gsm_map_SendAuthenticationInfoResV3(TRUE, tvb, offset, pinfo, tree, hf_gsm_map_SendAuthenticationInfoRes);
749           }
750           break;
751   case 57: /*restoreData*/
752     offset=dissect_gsm_map_RestoreDataRes(FALSE, tvb, offset, pinfo, tree, -1);
753     break;
754   case 58: /*sendIMSI*/
755     offset=dissect_gsm_map_IMSI(FALSE, tvb, offset, pinfo, tree,hf_gsm_map_imsi);
756     break;
757   case 59: /*unstructuredSS-Request*/
758     offset=dissect_gsm_map_Ussd_Res(FALSE, tvb, offset, pinfo, tree, -1);
759     break;
760   case 60: /*unstructuredSS-Request*/
761     offset=dissect_gsm_map_Ussd_Res(FALSE, tvb, offset, pinfo, tree, -1);
762     break;
763   case 61: /*unstructuredSS-Notify*/
764     /* TRUE ? */
765     proto_tree_add_text(tree, tvb, offset, -1, "Unknown returnResultData blob");
766     break;
767   case 62: /*AnyTimeSubscriptionInterrogation*/
768           offset=dissect_gsm_map_AnyTimeSubscriptionInterrogationRes(FALSE, tvb, offset, pinfo, tree, -1);
769           break;
770   case 65: /*AnyTimeModification*/
771           offset=dissect_gsm_map_AnyTimeModificationRes(FALSE, tvb, offset, pinfo, tree, -1);
772           break;
773   case 66: /*readyForSM*/
774     offset=dissect_gsm_map_ReadyForSM_Res(FALSE, tvb, offset, pinfo, tree, -1);
775     break;
776   case 67: /*purgeMS*/
777     offset=dissect_gsm_map_PurgeMSRes(FALSE, tvb, offset, pinfo, tree, -1);
778     break;
779   case 68: /*prepareHandover*/
780         octet = tvb_get_guint8(tvb,0) & 0xf;
781         if ( octet == 3){ /* This is a V3 message ??? */
782                 offset = offset +2;
783                 offset=dissect_gsm_map_PrepareHO_ResV3(TRUE, tvb, offset, pinfo, tree, hf_gsm_mapSendEndSignal);
784         }else{
785                 offset=dissect_gsm_map_PrepareHO_Res(FALSE, tvb, offset, pinfo, tree, -1);
786         }
787     break;
788   case 69: /*prepareSubsequentHandover*/
789      offset=dissect_gsm_map_Bss_APDU(FALSE, tvb, offset, pinfo, tree, -1);
790     break;
791   case 70: /*provideSubscriberInfo*/
792     offset=dissect_gsm_map_ProvideSubscriberInfoRes(FALSE, tvb, offset, pinfo, tree, -1);
793     break;
794   case 71: /*anyTimeInterrogation*/
795     offset=dissect_gsm_map_AnyTimeInterrogationRes(FALSE, tvb, offset, pinfo, tree, -1);
796     break;
797   case 72: /*ss-InvocationNotificatio*/
798     offset=dissect_gsm_map_Ss_InvocationNotificationRes(FALSE, tvb, offset, pinfo, tree, -1);
799     break;
800   case 73: /*setReportingState*/
801     offset=dissect_gsm_map_SetReportingStateRes(FALSE, tvb, offset, pinfo, tree, -1);
802     break;
803   case 74: /*statusReport*/
804     offset=dissect_gsm_map_StatusReportRes(FALSE, tvb, offset, pinfo, tree, -1);
805     break;
806   case 75: /*remoteUserFree*/
807     offset=dissect_gsm_map_RemoteUserFreeRes(FALSE, tvb, offset, pinfo, tree, -1);
808     break;
809   case 76: /*registerCC-Entry*/
810     offset=dissect_gsm_map_RegisterCC_EntryRes(FALSE, tvb, offset, pinfo, tree, -1);
811     break;
812   case 77: /*eraseCC-Entry*/
813     offset=dissect_gsm_map_EraseCC_EntryRes(FALSE, tvb, offset, pinfo, tree, -1);
814     break;
815   case 78: /*secureTransportClass1*/
816   case 79: /*secureTransportClass1*/
817   case 80: /*secureTransportClass1*/
818   case 81: /*secureTransportClass1*/
819     offset=dissect_gsm_map_SecureTransportRes(FALSE, tvb, offset, pinfo, tree, -1);
820     break;
821   case 83: /*provideSubscriberLocation*/
822     offset=dissect_gsm_map_ProvideSubscriberLocation_Res(FALSE, tvb, offset, pinfo, tree, -1);
823     break;
824   case 85: /*sendRoutingInfoForLCS*/
825     offset=dissect_gsm_map_RoutingInfoForLCS_Arg(FALSE, tvb, offset, pinfo, tree, -1);
826     break;
827   case 86: /*subscriberLocationReport*/
828     offset=dissect_gsm_map_SubscriberLocationReport_Res(FALSE, tvb, offset, pinfo, tree, -1);
829     break;
830   case 87: /*ist-Alert*/
831     offset=dissect_gsm_map_IST_AlertRes(FALSE, tvb, offset, pinfo, tree, -1);
832     break;
833   case 88: /*ist-Command*/
834     offset=dissect_gsm_map_IST_CommandRes(FALSE, tvb, offset, pinfo, tree, -1);
835     break;
836   case 89: /*noteMM-Event*/
837     offset=dissect_gsm_map_NoteMM_EventRes(FALSE, tvb, offset, pinfo, tree, -1);
838     break;
839  default:
840     proto_tree_add_text(tree, tvb, offset, -1, "Unknown returnResultData blob");
841   }
842   return offset;
843 }
844
845 static int 
846 dissect_invokeCmd(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
847   return dissect_gsm_map_Opcode(FALSE, tvb, offset, pinfo, tree, hf_gsm_map_invokeCmd);
848 }
849
850 static int dissect_invokeid(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
851   return dissect_ber_integer(FALSE, pinfo, tree, tvb, offset, hf_gsm_map_invokeid, NULL);
852 }
853
854
855 static const value_string InvokeId_vals[] = {
856   {   0, "invokeid" },
857   {   1, "absent" },
858   { 0, NULL }
859 };
860
861 static int dissect_absent(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
862   return dissect_gsm_map_NULL(FALSE, tvb, offset, pinfo, tree, hf_gsm_map_absent);
863 }
864
865
866 static const ber_choice_t InvokeId_choice[] = {
867   {   0, BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_invokeid },
868   {   1, BER_CLASS_UNI, BER_UNI_TAG_NULL, BER_FLAGS_NOOWNTAG, dissect_absent },
869   { 0, 0, 0, 0, NULL }
870 };
871
872 static int
873 dissect_gsm_map_InvokeId(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
874   offset = dissect_ber_CHOICE(pinfo, tree, tvb, offset,
875                               InvokeId_choice, hf_index, ett_gsm_map_InvokeId, NULL);
876
877   return offset;
878 }
879 static int dissect_invokeId(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
880   return dissect_gsm_map_InvokeId(FALSE, tvb, offset, pinfo, tree, hf_gsm_map_invokeId);
881 }
882
883 static const ber_sequence_t InvokePDU_sequence[] = {
884   { BER_CLASS_UNI, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_invokeId },
885   { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_invokeCmd },
886   { BER_CLASS_UNI, -1/*depends on Cmd*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_invokeData },
887   { 0, 0, 0, NULL }
888 };
889
890 static int
891 dissect_gsm_map_InvokePDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
892   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
893                                 InvokePDU_sequence, hf_index, ett_gsm_map_InvokePDU);
894
895   return offset;
896 }
897 static int dissect_invoke_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
898   return dissect_gsm_map_InvokePDU(TRUE, tvb, offset, pinfo, tree, hf_gsm_map_invoke);
899 }
900
901 static const ber_sequence_t ReturnResult_result_sequence[] = {
902   { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_invokeCmd },
903   { BER_CLASS_UNI, -1/*depends on Cmd*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_returnResultData },
904   { 0, 0, 0, NULL }
905 };
906 static int
907 dissect_returnResult_result(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
908   offset = dissect_ber_sequence(FALSE, pinfo, tree, tvb, offset,
909                                 ReturnResult_result_sequence, hf_gsm_map_returnResult_result, ett_gsm_map_ReturnResult_result);
910
911   return offset;
912 }
913
914 static const ber_sequence_t ReturnResultPDU_sequence[] = {
915   { BER_CLASS_UNI, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_invokeId },
916   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_returnResult_result },
917   { 0, 0, 0, NULL }
918 };
919
920 static int
921 dissect_gsm_map_returnResultPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
922   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
923                                 ReturnResultPDU_sequence, hf_index, ett_gsm_map_ReturnResultPDU);
924
925   return offset;
926 }
927 static int dissect_returnResult_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
928   return dissect_gsm_map_returnResultPDU(TRUE, tvb, offset, pinfo, tree, hf_gsm_map_returnResult);
929 }
930
931 static int
932 dissect_local_errorCode(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
933   return dissect_ber_integer(FALSE, pinfo, tree, tvb, offset, hf_gsm_map_local_errorCode, NULL);
934 }
935
936 static int
937 dissect_global_errorCode(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
938   offset =  dissect_ber_object_identifier(FALSE, pinfo, tree, tvb, offset,
939                                          hf_gsm_map_global_errorCode_oid, NULL);
940   return dissect_ber_integer(FALSE, pinfo, tree, tvb, offset, hf_gsm_map_global_errorCode, NULL);
941 }
942 static const ber_choice_t ReturnError_result_choice[] = {
943   {   0, BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_local_errorCode },
944   {   1, BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_global_errorCode },
945   {   0, 0, 0, 0, NULL }
946 };
947
948
949 static int
950 dissect_ReturnError_result(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
951
952   offset = dissect_ber_CHOICE(pinfo, tree, tvb, offset,
953                               ReturnError_result_choice, hf_gsm_map_returnError_result, ett_gsm_map_ReturnError_result, NULL);
954
955   return offset;
956 }
957
958 static const ber_sequence_t ReturnErrorPDU_sequence[] = {
959   { BER_CLASS_UNI, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_invokeId },
960   { BER_CLASS_UNI, -1/*choice*/,BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_ReturnError_result },
961   { 0, 0, 0, NULL }
962 };
963
964 static int
965 dissect_gsm_map_ReturnErrorPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
966   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
967                                 ReturnErrorPDU_sequence, hf_index, ett_gsm_map_ReturnErrorPDU);
968
969   return offset;
970 }
971 static int dissect_returnError_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
972   return dissect_gsm_map_ReturnErrorPDU(TRUE, tvb, offset, pinfo, tree, hf_gsm_map_returnError);
973 }
974
975
976 static const value_string GSMMAPPDU_vals[] = {
977   {   1, "Invoke " },
978   {   2, "ReturnResult " },
979   {   3, "ReturnError " },
980   {   4, "Reject " },
981   { 0, NULL }
982 };
983
984 static const ber_choice_t GSMMAPPDU_choice[] = {
985   {   1, BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_invoke_impl },
986   {   2, BER_CLASS_CON, 2, BER_FLAGS_IMPLTAG, dissect_returnResult_impl },
987   {   3, BER_CLASS_CON, 3, BER_FLAGS_IMPLTAG, dissect_returnError_impl },
988 #ifdef REMOVED
989   {   4, BER_CLASS_CON, 4, BER_FLAGS_IMPLTAG, dissect_reject_impl },
990 #endif
991   { 0, 0, 0, 0, NULL }
992 };
993
994 static guint8 gsmmap_pdu_type = 0;
995 static guint8 gsm_map_pdu_size = 0;
996
997 static int
998 dissect_gsm_map_GSMMAPPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo , proto_tree *tree, int hf_index) {
999
1000   char *version_ptr, *version_str;
1001
1002   opcode = 0;
1003   application_context_version = 0;
1004   if (pinfo->private_data != NULL){
1005     version_ptr = strrchr(pinfo->private_data,'.');
1006         if (version_ptr) {
1007                 version_str = g_strdup(version_ptr+1);
1008                 application_context_version = atoi(version_str);
1009         }
1010   }
1011
1012   gsmmap_pdu_type = tvb_get_guint8(tvb, offset)&0x0f;
1013   /* Get the length and add 2 */
1014   gsm_map_pdu_size = tvb_get_guint8(tvb, offset+1)+2;
1015
1016   if (check_col(pinfo->cinfo, COL_INFO)){
1017     col_set_str(pinfo->cinfo, COL_INFO, val_to_str(gsmmap_pdu_type, GSMMAPPDU_vals, "Unknown GSM-MAP PDU (%u)"));
1018   }
1019
1020   offset = dissect_ber_CHOICE(pinfo, tree, tvb, offset,
1021                               GSMMAPPDU_choice, hf_index, ett_gsm_map_GSMMAPPDU, NULL);
1022
1023
1024   return offset;
1025 }
1026
1027
1028
1029
1030 static void
1031 dissect_gsm_map(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
1032 {
1033     proto_item          *item=NULL;
1034     proto_tree          *tree=NULL;
1035     /* Used for gsm_map TAP */
1036     static              gsm_map_tap_rec_t tap_rec;
1037     gint                op_idx;
1038
1039
1040     if (check_col(pinfo->cinfo, COL_PROTOCOL))
1041     {
1042         col_set_str(pinfo->cinfo, COL_PROTOCOL, "GSM MAP");
1043     }
1044
1045     top_tree = parent_tree;
1046     dissector_add("tcap.itu_ssn",pinfo->match_port, map_handle);
1047     /* create display subtree for the protocol */
1048     if(parent_tree){
1049         item = proto_tree_add_item(parent_tree, proto_gsm_map, tvb, 0, -1, FALSE);
1050         tree = proto_item_add_subtree(item, ett_gsm_map);
1051     }
1052
1053     dissect_gsm_map_GSMMAPPDU(FALSE, tvb, 0, pinfo, tree, -1);
1054     match_strval_idx(opcode, gsm_map_opr_code_strings, &op_idx);
1055
1056     tap_rec.invoke = FALSE;
1057     if ( gsmmap_pdu_type  == 1 )
1058         tap_rec.invoke = TRUE;
1059     tap_rec.opr_code_idx = op_idx;
1060     tap_rec.size = gsm_map_pdu_size;
1061
1062     tap_queue_packet(gsm_map_tap, pinfo, &tap_rec);
1063 }
1064
1065 static const value_string ssCode_vals[] = {
1066   { 0x00, "allSS - all SS" },
1067   { 0x10 ,"allLineIdentificationSS - all line identification SS" },
1068   { 0x11 ,"clip - calling line identification presentation" },
1069   { 0x12 ,"clir - calling line identification restriction" },
1070   { 0x13 ,"colp - connected line identification presentation" },
1071   { 0x14 ,"colr - connected line identification restriction" },
1072   { 0x15 ,"mci - malicious call identification" },
1073   { 0x18 ,"allNameIdentificationSS - all name indentification SS" },
1074   { 0x19 ,"cnap - calling name presentation" },
1075   { 0x20 ,"allForwardingSS - all forwarding SS" },
1076   { 0x21 ,"cfu - call forwarding unconditional" },
1077   { 0x28 ,"allCondForwardingSS - all conditional forwarding SS" },
1078   { 0x29 ,"cfb - call forwarding busy" },
1079   { 0x2a ,"cfnry - call forwarding on no reply" },
1080   { 0x2b ,"cfnrc - call forwarding on mobile subscriber not reachable" },
1081   { 0x24 ,"cd - call deflection" },
1082   { 0x30 ,"allCallOfferingSS - all call offering SS includes also all forwarding SS" },
1083   { 0x31 ,"ect - explicit call transfer" },
1084   { 0x32 ,"mah - mobile access hunting" },
1085   { 0x40 ,"allCallCompletionSS - all Call completion SS" },
1086   { 0x41 ,"cw - call waiting" },
1087   { 0x42 ,"hold - call hold" },
1088   { 0x43 ,"ccbs-A - completion of call to busy subscribers, originating side" },
1089   { 0x44 ,"ccbs-B - completion of call to busy subscribers, destination side" },
1090   { 0x45 ,"mc - multicall" },
1091   { 0x50 ,"allMultiPartySS - all multiparty SS" },
1092   { 0x51 ,"multiPTY - multiparty" },
1093   { 0x60 ,"allCommunityOfInterestSS - all community of interest SS" },
1094   { 0x61 ,"cug - closed user group" },
1095   { 0x70 ,"allChargingSS - all charging SS" },
1096   { 0x71 ,"aoci - advice of charge information" },
1097   { 0x72 ,"aocc - advice of charge charging" },
1098   { 0x80 ,"allAdditionalInfoTransferSS - all additional information transfer SS" },
1099   { 0x81 ,"uus1 - UUS1 user-to-user signalling" },
1100   { 0x82 ,"uus2 - UUS2 user-to-user signalling" },
1101   { 0x83 ,"uus3 - UUS3 user-to-user signalling" },
1102   { 0x90 ,"allCallRestrictionSS - all Callrestriction SS" },
1103   { 0x91 ,"barringOfOutgoingCalls" },
1104   { 0x92 ,"baoc - barring of all outgoing calls" },
1105   { 0x93 ,"boic - barring of outgoing international calls" },
1106   { 0x94 ,"boicExHC - barring of outgoing international calls except those directed to the home PLMN" },
1107   { 0x99 ,"barringOfIncomingCalls" },
1108   { 0x9a ,"baic - barring of all incoming calls" },
1109   { 0x9b ,"bicRoam - barring of incoming calls when roaming outside home PLMN Country" },
1110   { 0xf0 ,"allPLMN-specificSS" },
1111   { 0xa0 ,"allCallPrioritySS - all call priority SS" },
1112   { 0xa1 ,"emlpp - enhanced Multilevel Precedence Pre-emption (EMLPP) service" },
1113   { 0xb0 ,"allLCSPrivacyException - all LCS Privacy Exception Classes" },
1114   { 0xb1 ,"universal - allow location by any LCS client" },
1115   { 0xb2 ,"callrelated - allow location by any value added LCS client to which a call is established from the target MS" },
1116   { 0xb3 ,"callunrelated - allow location by designated external value added LCS clients" },
1117   { 0xb4 ,"plmnoperator - allow location by designated PLMN operator LCS clients" },
1118   { 0xc0 ,"allMOLR-SS - all Mobile Originating Location Request Classes" },
1119   { 0xc1 ,"basicSelfLocation - allow an MS to request its own location" },
1120   { 0xc2 ,"autonomousSelfLocation - allow an MS to perform self location without interaction with the PLMN for a predetermined period of time" },
1121   { 0xc3 ,"transferToThirdParty - allow an MS to request transfer of its location to another LCS client" },
1122
1123   { 0xf1 ,"plmn-specificSS-1" },
1124   { 0xf2 ,"plmn-specificSS-2" },
1125   { 0xf3 ,"plmn-specificSS-3" },
1126   { 0xf4 ,"plmn-specificSS-4" },
1127   { 0xf5 ,"plmn-specificSS-5" },
1128   { 0xf6 ,"plmn-specificSS-6" },
1129   { 0xf7 ,"plmn-specificSS-7" },
1130   { 0xf8 ,"plmn-specificSS-8" },
1131   { 0xf9 ,"plmn-specificSS-9" },
1132   { 0xfa ,"plmn-specificSS-a" },
1133   { 0xfb ,"plmn-specificSS-b" },
1134   { 0xfc ,"plmn-specificSS-c" },
1135   { 0xfd ,"plmn-specificSS-d" },
1136   { 0xfe ,"plmn-specificSS-e" },
1137   { 0xff ,"plmn-specificSS-f" },
1138   { 0, NULL }
1139 };
1140
1141 static const value_string Teleservice_vals[] = {
1142 {0x00, "allTeleservices" },
1143 {0x10, "allSpeechTransmissionServices" },
1144 {0x11, "telephony" },
1145 {0x12, "emergencyCalls" },
1146 {0x20, "allShortMessageServices" },
1147 {0x21, "shortMessageMT-PP" },
1148 {0x22, "shortMessageMO-PP" },
1149 {0x60, "allFacsimileTransmissionServices" },
1150 {0x61, "facsimileGroup3AndAlterSpeech" },
1151 {0x62, "automaticFacsimileGroup3" },
1152 {0x63, "facsimileGroup4" },
1153
1154 {0x70, "allDataTeleservices" },
1155 {0x80, "allTeleservices-ExeptSMS" },
1156
1157 {0x90, "allVoiceGroupCallServices" },
1158 {0x91, "voiceGroupCall" },
1159 {0x92, "voiceBroadcastCall" },
1160
1161 {0xd0, "allPLMN-specificTS" },
1162 {0xd1, "plmn-specificTS-1" },
1163 {0xd2, "plmn-specificTS-2" },
1164 {0xd3, "plmn-specificTS-3" },
1165 {0xd4, "plmn-specificTS-4" },
1166 {0xd5, "plmn-specificTS-5" },
1167 {0xd6, "plmn-specificTS-6" },
1168 {0xd7, "plmn-specificTS-7" },
1169 {0xd8, "plmn-specificTS-8" },
1170 {0xd9, "plmn-specificTS-9" },
1171 {0xda, "plmn-specificTS-A" },
1172 {0xdb, "plmn-specificTS-B" },
1173 {0xdc, "plmn-specificTS-C" },
1174 {0xdd, "plmn-specificTS-D" },
1175 {0xde, "plmn-specificTS-E" },
1176 {0xdf, "plmn-specificTS-F" },
1177   { 0, NULL }
1178 };
1179
1180 static const value_string Bearerservice_vals[] = {
1181 {0x00, "allBearerServices" },
1182 {0x10, "allDataCDA-Services" },
1183 {0x11, "dataCDA-300bps" },
1184 {0x12, "dataCDA-1200bps" },
1185 {0x13, "dataCDA-1200-75bps" },
1186 {0x14, "dataCDA-2400bps" },
1187 {0x15, "dataCDA-4800bps" },
1188 {0x16, "dataCDA-9600bps" },
1189 {0x17, "general-dataCDA" },
1190
1191 {0x18, "allDataCDS-Services" },
1192 {0x1A, "dataCDS-1200bps" },
1193 {0x1C, "dataCDS-2400bps" },
1194 {0x1D, "dataCDS-4800bps" },
1195 {0x1E, "dataCDS-9600bps" },
1196 {0x1F, "general-dataCDS" },
1197
1198 {0x20, "allPadAccessCA-Services" },
1199 {0x21, "padAccessCA-300bps" },
1200 {0x22, "padAccessCA-1200bps" },
1201 {0x23, "padAccessCA-1200-75bps" },
1202 {0x24, "padAccessCA-2400bps" },
1203 {0x25, "padAccessCA-4800bps" },
1204 {0x26, "padAccessCA-9600bps" },
1205 {0x27, "general-padAccessCA" },
1206
1207 {0x28, "allDataPDS-Services" },
1208 {0x2C, "dataPDS-2400bps" },
1209 {0x2D, "dataPDS-4800bps" },
1210 {0x2E, "dataPDS-9600bps" },
1211 {0x2F, "general-dataPDS" },
1212
1213 {0x30, "allAlternateSpeech-DataCDA" },
1214 {0x38, "allAlternateSpeech-DataCDS" },
1215 {0x40, "allSpeechFollowedByDataCDA" },
1216 {0x48, "allSpeechFollowedByDataCDS" },
1217
1218 {0x50, "allDataCircuitAsynchronous" },
1219 {0x60, "allAsynchronousServices" },
1220 {0x58, "allDataCircuitSynchronous" },
1221 {0x68, "allSynchronousServices" },
1222
1223 {0xD0, "allPLMN-specificBS" },
1224 {0xD1, "plmn-specificBS-1" },
1225 {0xD2, "plmn-specificBS-2" },
1226 {0xD3, "plmn-specificBS-3" },
1227 {0xD4, "plmn-specificBS-4" },
1228 {0xD5, "plmn-specificBS-5" },
1229 {0xD6, "plmn-specificBS-6" },
1230 {0xD7, "plmn-specificBS-7" },
1231 {0xD8, "plmn-specificBS-8" },
1232 {0xD9, "plmn-specificBS-9" },
1233 {0xDA, "plmn-specificBS-A" },
1234 {0xDB, "plmn-specificBS-B" },
1235 {0xDC, "plmn-specificBS-C" },
1236 {0xDD, "plmn-specificBS-D" },
1237 {0xDE, "plmn-specificBS-E" },
1238 {0xDF, "plmn-specificBS-F" },
1239
1240 { 0, NULL }
1241 };
1242
1243 /*--- proto_reg_handoff_gsm_map ---------------------------------------*/
1244 static void range_delete_callback(guint32 ssn)
1245 {
1246     if (ssn) {
1247         dissector_delete("tcap.itu_ssn", ssn, map_handle);
1248     }
1249 }
1250
1251 static void range_add_callback(guint32 ssn)
1252 {
1253     if (ssn) {
1254         dissector_add("tcap.itu_ssn", ssn, map_handle);
1255     }
1256 }
1257
1258 void proto_reg_handoff_gsm_map(void) {
1259
1260     static int map_prefs_initialized = FALSE;
1261     data_handle = find_dissector("data");
1262
1263     if (!map_prefs_initialized) {
1264         map_prefs_initialized = TRUE;
1265         map_handle = create_dissector_handle(dissect_gsm_map, proto_gsm_map);
1266   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)");  
1267   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)" );
1268   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)" );
1269   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)" );
1270   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)" );
1271   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)" );
1272   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)" );
1273   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)" );
1274   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)" );
1275   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)" );
1276   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)" );
1277   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)" );
1278   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)" );
1279   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)" );
1280   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)" );
1281   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)" );
1282   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)" );
1283   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)" );
1284   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)" );
1285   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)" );
1286   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)" );
1287   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)" );
1288   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)" );
1289   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)" );
1290   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)" );
1291   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)" );
1292   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)" );
1293   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)" );
1294   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)" );
1295   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)" );
1296   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)" );
1297   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)" );
1298   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)" );
1299   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)" );
1300   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)" );
1301   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)" );
1302   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)" );
1303   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)" );
1304   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)" );
1305   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)" );
1306   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)" );
1307   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)" );
1308   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)" );
1309   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)" );
1310   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)" );
1311   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)" );
1312   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)" );
1313   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)" );
1314   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)" );
1315   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)" );
1316   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)" );
1317   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)" );
1318   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)" );
1319   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)" );
1320   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)" );
1321   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)" );
1322   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)" );
1323   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)" );
1324   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)" );
1325   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)" );
1326     }
1327     else {
1328         range_foreach(ssn_range, range_delete_callback);
1329     }
1330
1331     g_free(ssn_range);
1332     ssn_range = range_copy(global_ssn_range);
1333
1334     range_foreach(ssn_range, range_add_callback);
1335
1336 }
1337
1338 /*--- proto_register_gsm_map -------------------------------------------*/
1339 void proto_register_gsm_map(void) {
1340         module_t *gsm_map_module;
1341
1342   /* List of fields */
1343   static hf_register_info hf[] = {
1344     { &hf_gsm_map_invokeCmd,
1345       { "invokeCmd", "gsm_map.invokeCmd",
1346         FT_UINT32, BASE_DEC, VALS(gsm_map_opr_code_strings), 0,
1347         "InvokePDU/invokeCmd", HFILL }},
1348     { &hf_gsm_map_invokeid,
1349       { "invokeid", "gsm_map.invokeid",
1350         FT_INT32, BASE_DEC, NULL, 0,
1351         "InvokeId/invokeid", HFILL }},
1352     { &hf_gsm_map_absent,
1353       { "absent", "gsm_map.absent",
1354         FT_NONE, BASE_NONE, NULL, 0,
1355         "InvokeId/absent", HFILL }},
1356     { &hf_gsm_map_invokeId,
1357       { "invokeId", "gsm_map.invokeId",
1358         FT_UINT32, BASE_DEC, VALS(InvokeId_vals), 0,
1359         "InvokePDU/invokeId", HFILL }},
1360         { &hf_gsm_map_SendAuthenticationInfoArg,
1361       { "SendAuthenticationInfoArg", "gsm_map.SendAuthenticationInfoArg",
1362         FT_BYTES, BASE_NONE, NULL, 0,
1363         "SendAuthenticationInfoArg", HFILL }},
1364         { &hf_gsm_map_SendAuthenticationInfoRes,
1365       { "SendAuthenticationInfoRes", "gsm_map.SendAuthenticationInfoRes",
1366         FT_BYTES, BASE_NONE, NULL, 0,
1367         "SendAuthenticationInfoRes", HFILL }},
1368     { &hf_gsm_map_currentPassword,
1369       { "currentPassword", "gsm_map.currentPassword",
1370         FT_STRING, BASE_NONE, NULL, 0,
1371         "", HFILL }},
1372         { &hf_gsm_mapSendEndSignal,
1373       { "mapSendEndSignalArg", "gsm_map.mapsendendsignalarg",
1374         FT_BYTES, BASE_NONE, NULL, 0,
1375         "mapSendEndSignalArg", HFILL }},
1376     { &hf_gsm_map_invoke,
1377       { "invoke", "gsm_map.invoke",
1378         FT_NONE, BASE_NONE, NULL, 0,
1379         "GSMMAPPDU/invoke", HFILL }},
1380     { &hf_gsm_map_returnResult,
1381       { "returnResult", "gsm_map.returnResult",
1382         FT_NONE, BASE_NONE, NULL, 0,
1383         "GSMMAPPDU/returnResult", HFILL }},
1384         {&hf_gsm_map_returnResult_result,
1385       { "returnResult_result", "gsm_map.returnresultresult",
1386         FT_BYTES, BASE_NONE, NULL, 0,
1387         "returnResult_result", HFILL }},
1388         {&hf_gsm_map_returnError_result,
1389       { "returnError_result", "gsm_map.returnerrorresult",
1390         FT_UINT32, BASE_DEC, NULL, 0,
1391         "returnError_result", HFILL }},
1392         {&hf_gsm_map_returnError,
1393       { "returnError", "gsm_map.returnError",
1394         FT_NONE, BASE_NONE, NULL, 0,
1395         "GSMMAPPDU/returnError", HFILL }},
1396         {&hf_gsm_map_local_errorCode,
1397       { "Local Error Code", "gsm_map.localerrorCode",
1398         FT_UINT32, BASE_DEC, VALS(gsm_map_err_code_string_vals), 0,
1399         "localerrorCode", HFILL }},
1400         {&hf_gsm_map_global_errorCode_oid,
1401       { "Global Error Code OID", "gsm_map.hlobalerrorCodeoid",
1402         FT_BYTES, BASE_NONE, NULL, 0,
1403         "globalerrorCodeoid", HFILL }},
1404         {&hf_gsm_map_global_errorCode,
1405       { "Global Error Code", "gsm_map.globalerrorCode",
1406         FT_UINT32, BASE_DEC, NULL, 0,
1407         "globalerrorCode", HFILL }},
1408     { &hf_gsm_map_getPassword,
1409       { "Password", "gsm_map.password",
1410         FT_UINT8, BASE_DEC, VALS(gsm_map_GetPasswordArg_vals), 0,
1411         "Password", HFILL }},
1412     { &hf_gsm_map_extension,
1413       { "Extension", "gsm_map.extension",
1414         FT_BOOLEAN, 8, TFS(&gsm_map_extension_value), 0x80,
1415         "Extension", HFILL }},
1416     { &hf_gsm_map_nature_of_number,
1417       { "Nature of number", "gsm_map.nature_of_number",
1418         FT_UINT8, BASE_HEX, VALS(gsm_map_nature_of_number_values), 0x70,
1419         "ature of number", HFILL }},
1420     { &hf_gsm_map_number_plan,
1421       { "Number plan", "gsm_map.number_plan",
1422         FT_UINT8, BASE_HEX, VALS(gsm_map_number_plan_values), 0x0f,
1423         "Number plan", HFILL }},
1424         { &hf_gsm_map_isdn_address_digits,
1425       { "ISDN Address digits", "gsm_map.isdn.adress.digits",
1426         FT_STRING, BASE_NONE, NULL, 0,
1427         "ISDN Address digits", HFILL }},
1428         { &hf_gsm_map_servicecentreaddress_digits,
1429       { "ServiceCentreAddress digits", "gsm_map.servicecentreaddress_digits",
1430         FT_STRING, BASE_NONE, NULL, 0,
1431         "ServiceCentreAddress digits", HFILL }},
1432         { &hf_gsm_map_imsi_digits,
1433       { "Imsi digits", "gsm_map.imsi_digits",
1434         FT_STRING, BASE_NONE, NULL, 0,
1435         "Imsi digits", HFILL }},
1436         { &hf_gsm_map_Ss_Status_unused,
1437       { "Unused", "gsm_map.unused",
1438         FT_UINT8, BASE_HEX, NULL, 0xf0,
1439         "Unused", HFILL }},
1440         { &hf_gsm_map_Ss_Status_q_bit,
1441       { "Q bit", "gsm_map.ss_status_q_bit",
1442         FT_BOOLEAN, 8, TFS(&gsm_map_Ss_Status_q_bit_values), 0x08,
1443         "Q bit", HFILL }},
1444         { &hf_gsm_map_Ss_Status_p_bit,
1445       { "P bit", "gsm_map.ss_status_p_bit",
1446         FT_BOOLEAN, 8, TFS(&gsm_map_Ss_Status_p_values), 0x04,
1447         "P bit", HFILL }},
1448         { &hf_gsm_map_Ss_Status_r_bit,
1449       { "R bit", "gsm_map.ss_status_r_bit",
1450         FT_BOOLEAN, 8, TFS(&gsm_map_Ss_Status_r_values), 0x02,
1451         "R bit", HFILL }},
1452         { &hf_gsm_map_Ss_Status_a_bit,
1453       { "A bit", "gsm_map.ss_status_a_bit",
1454         FT_BOOLEAN, 8, TFS(&gsm_map_Ss_Status_a_values), 0x01,
1455         "A bit", HFILL }},
1456
1457 #include "packet-gsm_map-hfarr.c"
1458   };
1459
1460   /* List of subtrees */
1461   static gint *ett[] = {
1462     &ett_gsm_map,
1463     &ett_gsm_map_InvokeId,
1464     &ett_gsm_map_InvokePDU,
1465     &ett_gsm_map_ReturnResultPDU,
1466         &ett_gsm_map_ReturnErrorPDU,
1467     &ett_gsm_map_ReturnResult_result,
1468         &ett_gsm_map_ReturnError_result,
1469     &ett_gsm_map_GSMMAPPDU,
1470 #include "packet-gsm_map-ettarr.c"
1471   };
1472
1473   /* Register protocol */
1474   proto_gsm_map = proto_register_protocol(PNAME, PSNAME, PFNAME);
1475 /*XXX  register_dissector("gsm_map", dissect_gsm_map, proto_gsm_map);*/
1476   /* Register fields and subtrees */
1477   proto_register_field_array(proto_gsm_map, hf, array_length(hf));
1478   proto_register_subtree_array(ett, array_length(ett));
1479
1480   sms_dissector_table = register_dissector_table("gsm_map.sms_tpdu", 
1481                                                  "GSM SMS TPDU", FT_UINT8,
1482                                                  BASE_DEC);
1483
1484   gsm_map_tap = register_tap("gsm_map");
1485   /*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)" );
1486    *
1487    * Register our configuration options, particularly our ssn:s
1488    * Set default SSNs
1489    */
1490   range_convert_str(&global_ssn_range, "6-9", MAX_SSN);
1491   ssn_range = range_empty();
1492
1493
1494   gsm_map_module = prefs_register_protocol(proto_gsm_map, proto_reg_handoff_gsm_map);
1495
1496   prefs_register_range_preference(gsm_map_module, "tcap.ssn", "TCAP SSNs",
1497                                   "TCAP Subsystem numbers used for GSM MAP",
1498                                   &global_ssn_range, MAX_SSN);
1499 }
1500
1501