Replace a handful of tabs with spaces.
[obnox/wireshark/wip.git] / asn1 / inap / packet-inap-template.c
1 /* packet-inap-template.c
2  * Routines for INAP
3  * Copyright 2004, Tim Endean <endeant@hotmail.com>
4  * Built from the gsm-map dissector Copyright 2004, Anders Broman <anders.broman@ericsson.com>
5  *
6  * $Id$
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1998 Gerald Combs
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24  * References: ETSI 300 374
25  * ITU Q.1218
26  */
27
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
31
32 #include <glib.h>
33 #include <epan/packet.h>
34 #include <epan/prefs.h>
35 #include <epan/conversation.h>
36 #include <epan/oids.h>
37 #include "epan/expert.h"
38 #include <epan/asn1.h>
39
40 #include <stdio.h>
41 #include <string.h>
42
43 #include "packet-ber.h"
44 #include "packet-inap.h"
45 #include "packet-q931.h"
46 #include "packet-e164.h"
47 #include "packet-isup.h"
48 #include "packet-tcap.h"
49
50 #define PNAME  "Intelligent Network Application Protocol"
51 #define PSNAME "INAP"
52 #define PFNAME "inap"
53
54 /* Initialize the protocol and registered fields */
55 int proto_inap = -1;
56
57 #include "packet-inap-hf.c"
58
59 #define MAX_SSN 254
60 static range_t *global_ssn_range;
61 static range_t *ssn_range;
62
63 static dissector_handle_t       inap_handle;
64
65 /* Global variables */
66 static guint32 opcode=0;
67 static guint32 errorCode;
68
69 /* Initialize the subtree pointers */
70 static gint ett_inap = -1;
71 static gint ett_inapisup_parameter = -1;
72 #include "packet-inap-ett.c"
73
74 const value_string inap_opr_code_strings[] = {
75
76         {0,"InitialDP"},
77         {1, "OriginationAttemptAuthorized"},
78         {2, "CollectedInformation"},
79         {3, "AnalysedInformation"},
80         {4, "RouteSelectFailure"},
81         {5, "oCalledPartyBusy"},
82         {6, "oNoAnswer"},
83         {7, "oAnswer"},
84         {8, "oDisconnect"},
85         {9, "TermAttemptAuthorized"},
86         {10, "tBusy"},
87         {11, "tNoAnswer"},
88         {12, "tAnswer"},
89         {13, "tDisconnect"},
90         {14, "oMidCall"},
91         {15, "tMidCall"},
92         {16, "AssistRequestInstructions"},
93         {17,"EstablishTemporaryConnection"},
94         {18, "DisconnectForwardConnection"},
95         {19,"ConnectToResource"},
96         {20, "Connect"},
97         {21,"HoldCallInNetwork"},
98         {22, "ReleaseCall"},
99         {23, "RequestReportBCSMEven"},
100         {23, "RequestReportBCSMEvent"},
101         {24, "EventReportBCSM"},
102         {25, "RequestNotificationChargingEvent"},
103         {26, "EventNotificationCharging"},
104         {27, "CollectInformation"},
105         {28, "AnalyseInformation"},
106         {29, "SelectRoute"},
107         {30, "SelectFacility"},
108         {31, "Continue"},
109         {32, "InitiateCallAttempt"},
110         {33, "ResetTimer"},
111         {34, "FurnishChargingInformation"},
112         {35, "ApplyCharging"},
113         {36, "ApplyChargingReport"},
114         {37, "RequestCurrentStatusReport"},
115         {38, "RequestEveryStatusChangeReport"},
116         {39, "RequestFirstStatusMatchReport"},
117         {40, "StatusReport"},
118         {41, "CallGap"},
119         {42, "ActivateServiceFiltering"},
120         {43, "ServiceFilteringResponse"},
121         {44, "CallInformationReport"},
122         {45, "CallInformationRequest"},
123         {46, "SendChargingInformation"},
124         {47, "PlayAnnouncement"},
125         {48, "PromptAndCollectUserInformation"},
126         {49, "SpecializedResourceReport"},
127         {53, "Cancel"},
128         {54, "CancelStatusReportRequest"},
129         {55, "ActivityTest"},
130         {80, "FacilitySelectedAndAvailable"},
131         {81, "OriginationAttempt"},
132         {82, "TerminationAttempt"},
133         {83, "OAbandon"},
134         {84, "OSuspended"},
135         {85, "TSuspended"},
136         {87, "AuthorizeTermination"},
137         {88, "ContinueWithArgument"},
138         {89, "CreateCallSegmentAssociation "},
139         {90, "DisconnectLeg"},
140         {91, "MergeCallSegments"},
141         {92, "MoveCallSegments"},
142         {93, "MoveLeg"},
143         {94, "Reconnect"},
144         {95, "SplitLeg"},
145         {96, "EntityReleased"},
146         {97, "ManageTriggerData"},
147         {98, "requestReportUTSI"},
148         {99,"ReceivedInformation"}, /*???????*/
149         {100, "sendSTUI"},
150         {101, "reportUTSI"},
151         {102, "sendFacilityInformation"},
152         {103, "requestReportFacilityEvent"},
153         {104, "eventReportFacility"},
154         {107, "promptAndReceiveMessage"},
155         {108, "scriptInformation"},
156         {109, "scriptEvent"},
157         {110, "scriptRun"},
158         {111, "scriptClose"},
159         {135, "createOrRemoveTriggerData"},
160         {136, "setServiceProfile"},
161         {139, "srfCallGap"},
162         {145, "CallFiltering"},
163         {146, "monitorRouteRequest"},
164         {147, "monitorRouteReport"},
165         {0, NULL}
166 };
167
168 const value_string inap_error_code_strings[] = {
169
170 {0,"cancelled"},
171 {1,"cancelFailed"},
172 {3,"etcFailed"},
173 {4,"improperCallerResponse"},
174 {6,"missingCustomerRecord"},
175 {7,"missingParameter"},
176 {8,"parameterOutOfRange"},
177 {10,"RequestedInfoError"},
178 {11,"SystemFailure"},
179 {12,"TaskRefused"},
180 {13,"UnavailableResource"},
181 {14,"UnexpectedComponentSequence"},
182 {15,"UnexpectedDataValue"},
183 {16,"UnexpectedParameter"},
184 {17,"UnknownLegID"},
185 {18,"UnknownResource"},
186 {0, NULL}
187 };
188
189 const value_string inap_general_problem_strings[] = {
190 {0,"General Problem Unrecognized Component"},
191 {1,"General Problem Mistyped Component"},
192 {3,"General Problem Badly Structured Component"},
193 {0, NULL}
194 };
195
196 /* Forvard declarations */
197 static int dissect_invokeData(proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *actx _U_);
198 static int dissect_returnResultData(proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *actx _U_);
199 static int dissect_returnErrorData(proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *actx);
200
201 #include "packet-inap-fn.c"
202 /*
203 TC-Invokable OPERATION ::=
204   {activateServiceFiltering | activityTest | analysedInformation |
205    analyseInformation | applyCharging | applyChargingReport |
206    assistRequestInstructions | callGap | callInformationReport |
207    callInformationRequest | cancel | cancelStatusReportRequest |
208    collectedInformation | collectInformation | connect | connectToResource |
209    continue | disconnectForwardConnection | establishTemporaryConnection |
210    eventNotificationCharging | eventReportBCSM | furnishChargingInformation |
211    holdCallInNetwork | initialDP | initiateCallAttempt | oAnswer |
212    oCalledPartyBusy | oDisconnect | oMidCall | oNoAnswer |
213    originationAttemptAuthorized | releaseCall | requestCurrentStatusReport |
214    requestEveryStatusChangeReport | requestFirstStatusMatchReport |
215    requestNotificationChargingEvent | requestReportBCSMEvent | resetTimer |
216    routeSelectFailure | selectFacility | selectRoute | sendChargingInformation
217    | serviceFilteringResponse | statusReport | tAnswer | tBusy | tDisconnect |
218    termAttemptAuthorized | tMidCall | tNoAnswer | playAnnouncement |
219    promptAndCollectUserInformation}
220 */
221
222 static int dissect_invokeData(proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *actx _U_) {
223   switch(opcode){
224   case 0: /*InitialDP*/
225     offset=dissect_inap_InitialDPArg(FALSE, tvb, offset, actx, tree, hf_inap_InitialDPArg_PDU);
226     break;
227   case 1: /*1 OriginationAttemptAuthorized */
228     offset=dissect_inap_OriginationAttemptAuthorizedArg(FALSE, tvb, offset, actx, tree, hf_inap_OriginationAttemptAuthorizedArg_PDU);
229     break;
230   case 2: /*2 CollectedInformation */
231     offset=dissect_inap_CollectedInformationArg(FALSE, tvb, offset, actx, tree, hf_inap_CollectedInformationArg_PDU);
232     break;
233   case 3: /*3 AnalysedInformation */
234     offset=dissect_inap_AnalysedInformationArg(FALSE, tvb, offset, actx, tree, hf_inap_AnalysedInformationArg_PDU);
235     break;
236   case 4: /*4 RouteSelectFailure */
237     offset=dissect_inap_RouteSelectFailureArg(FALSE, tvb, offset, actx, tree, hf_inap_RouteSelectFailureArg_PDU);
238     break;
239   case 5: /*5 oCalledPartyBusy */
240     offset=dissect_inap_OCalledPartyBusyArg(FALSE, tvb, offset, actx, tree, hf_inap_OCalledPartyBusyArg_PDU);
241     break;       
242   case 6: /*6 oNoAnswer */
243     offset=dissect_inap_ONoAnswerArg(FALSE, tvb, offset, actx, tree, hf_inap_ONoAnswerArg_PDU);
244     break;
245   case 7: /*7 oAnswer */
246     offset=dissect_inap_OAnswerArg(FALSE, tvb, offset, actx, tree, hf_inap_OAnswerArg_PDU);
247     break;
248   case 8: /*8 oDisconnect */
249     offset=dissect_inap_ODisconnectArg(FALSE, tvb, offset, actx, tree, hf_inap_ODisconnectArg_PDU);
250     break;
251   case 9: /*9 TermAttemptAuthorized */
252     offset=dissect_inap_TermAttemptAuthorizedArg(FALSE, tvb, offset, actx, tree, hf_inap_TermAttemptAuthorizedArg_PDU);
253     break;
254   case 10: /*10 tBusy */
255     offset=dissect_inap_TBusyArg(FALSE, tvb, offset, actx, tree, hf_inap_TBusyArg_PDU);
256     break;
257   case 11: /*11 tNoAnswer */
258     offset=dissect_inap_TNoAnswerArg(FALSE, tvb, offset, actx, tree, hf_inap_TNoAnswerArg_PDU);
259     break;
260   case 12: /*12 tAnswer */
261     offset=dissect_inap_TAnswerArg(FALSE, tvb, offset, actx, tree, hf_inap_TAnswerArg_PDU);
262     break;
263   case 13: /*13 tDisconnect */
264     offset=dissect_inap_TDisconnectArg(FALSE, tvb, offset, actx, tree, hf_inap_TDisconnectArg_PDU);
265     break;
266   case 14: /*14 oMidCall */
267     offset=dissect_inap_MidCallArg(FALSE, tvb, offset, actx, tree, hf_inap_MidCallArg_PDU);
268     break;
269   case 15: /*15 tMidCall */
270     offset=dissect_inap_MidCallArg(FALSE, tvb, offset, actx, tree, hf_inap_MidCallArg_PDU);
271     break;
272   case  16: /*AssistRequestInstructions*/
273     offset=dissect_inap_AssistRequestInstructionsArg(FALSE, tvb, offset, actx, tree, hf_inap_AssistRequestInstructionsArg_PDU);
274     break;
275   case  17: /*EstablishTemporaryConnection*/
276     offset=dissect_inap_EstablishTemporaryConnectionArg(FALSE, tvb, offset, actx, tree, hf_inap_EstablishTemporaryConnectionArg_PDU);
277     break;
278   case  18: /*DisconnectForwardConnections*/
279     proto_tree_add_text(tree, tvb, offset, -1, "Disconnect Forward Connection");
280     break;
281   case  19: /*ConnectToResource*/
282     offset=dissect_inap_ConnectToResourceArg(FALSE, tvb, offset, actx, tree, hf_inap_ConnectToResourceArg_PDU);
283     break;
284   case  20: /*Connect*/
285     offset=dissect_inap_ConnectArg(FALSE, tvb, offset, actx, tree,hf_inap_ConnectArg_PDU);
286     break;      
287   case  21: /* 21 HoldCallInNetwork */
288     offset=dissect_inap_HoldCallInNetworkArg(FALSE, tvb, offset, actx, tree,hf_inap_HoldCallInNetworkArg_PDU);
289     break;
290
291    case 22: /*ReleaseCall*/
292     offset=dissect_inap_ReleaseCallArg(FALSE, tvb, offset, actx, tree,hf_inap_ReleaseCallArg_PDU);
293     break;
294     case 23: /*InitialDP*/
295     offset=dissect_inap_RequestReportBCSMEventArg(FALSE, tvb, offset, actx, tree, hf_inap_RequestReportBCSMEventArg_PDU);
296     break;
297   case  24: /*EventReportBCSM*/
298     offset=dissect_inap_EventReportBCSMArg(FALSE, tvb, offset, actx, tree, hf_inap_EventReportBCSMArg_PDU);
299     break;
300   case  25: /*25, "RequestNotificationChargingEvent */
301     offset=dissect_inap_RequestNotificationChargingEventArg(FALSE, tvb, offset, actx, tree, hf_inap_RequestNotificationChargingEventArg_PDU);
302     break;
303   case  26: /*26, "EventNotificationCharging */
304     offset=dissect_inap_EventNotificationChargingArg(FALSE, tvb, offset, actx, tree, hf_inap_EventNotificationChargingArg_PDU);
305     break;
306   case  27: /*27, "CollectInformation */
307     offset=dissect_inap_CollectInformationArg(FALSE, tvb, offset, actx, tree, hf_inap_CollectInformationArg_PDU);
308     break;
309   case  28: /*28, "AnalyseInformation */
310     offset=dissect_inap_AnalyseInformationArg(FALSE, tvb, offset, actx, tree, hf_inap_AnalyseInformationArg_PDU);
311     break;
312   case  29: /*29, "SelectRoute */
313     offset=dissect_inap_SelectRouteArg(FALSE, tvb, offset, actx, tree, hf_inap_SelectRouteArg_PDU);
314     break;
315   case  30: /*30, "SelectFacility */
316     offset=dissect_inap_SelectFacilityArg(FALSE, tvb, offset, actx, tree, hf_inap_SelectFacilityArg_PDU);
317     break;
318         /*31, "Continue */
319   case  32: /*32, InitiateCallAttempt*/
320     offset=dissect_inap_InitiateCallAttemptArg(FALSE, tvb, offset, actx, tree, hf_inap_InitiateCallAttemptArg_PDU);
321     break;
322   case 33: /*ResetTimer*/
323     offset=dissect_inap_ResetTimerArg(FALSE, tvb, offset, actx, tree, hf_inap_ResetTimerArg_PDU);
324     break;
325   case 34: /*FurnishChargingInformation*/
326     offset=dissect_inap_FurnishChargingInformationArg(FALSE, tvb, offset, actx, tree, hf_inap_FurnishChargingInformationArg_PDU);
327     break;
328   case 35: /*35, ApplyCharging */
329     offset=dissect_inap_ApplyChargingArg(FALSE, tvb, offset, actx, tree, hf_inap_ApplyChargingArg_PDU);
330     break;      
331   case 36: /*36, "ApplyChargingReport */
332     offset=dissect_inap_ApplyChargingReportArg(FALSE, tvb, offset, actx, tree, hf_inap_ApplyChargingReportArg_PDU);
333     break;
334   case 37: /*37, "RequestCurrentStatusReport */
335     offset=dissect_inap_RequestCurrentStatusReportArg(FALSE, tvb, offset, actx, tree, hf_inap_RequestCurrentStatusReportArg_PDU);
336     break;
337   case 38:/*38, "RequestEveryStatusChangeReport */
338     offset=dissect_inap_RequestEveryStatusChangeReportArg(FALSE, tvb, offset, actx, tree, hf_inap_RequestEveryStatusChangeReportArg_PDU);
339     break;
340   case 39:/*39, "RequestFirstStatusMatchReport */
341     offset=dissect_inap_RequestFirstStatusMatchReportArg(FALSE, tvb, offset, actx, tree, hf_inap_RequestFirstStatusMatchReportArg_PDU);
342     break;
343   case 40:/*40, "StatusReport */
344     offset=dissect_inap_StatusReportArg(FALSE, tvb, offset, actx, tree, hf_inap_StatusReportArg_PDU);
345     break;
346   case 41:/*41, "CallGap */
347     offset=dissect_inap_CallGapArg(FALSE, tvb, offset, actx, tree, hf_inap_CallGapArg_PDU);
348     break;
349   case 42:/*42, "ActivateServiceFiltering */
350     offset=dissect_inap_ActivateServiceFilteringArg(FALSE, tvb, offset, actx, tree, hf_inap_ActivateServiceFilteringArg_PDU);
351     break;
352   case 43:/*43, "ServiceFilteringResponse */
353     offset=dissect_inap_ServiceFilteringResponseArg(FALSE, tvb, offset, actx, tree, hf_inap_ServiceFilteringResponseArg_PDU);
354     break;    
355   case  44: /*CallInformationReport*/
356     offset=dissect_inap_CallInformationReportArg(FALSE, tvb, offset, actx, tree, hf_inap_CallInformationReportArg_PDU);
357     break;
358   case  45: /*CallInformationRequest*/
359     offset=dissect_inap_CallInformationRequestArg(FALSE, tvb, offset, actx, tree, hf_inap_CallInformationRequestArg_PDU);
360     break;
361   case 47: /*PlayAnnouncement*/
362     offset=dissect_inap_PlayAnnouncementArg(FALSE, tvb, offset, actx, tree, hf_inap_PlayAnnouncementArg_PDU);
363     break;
364   case 48: /*PromptAndCollectUserInformation*/
365     offset=dissect_inap_PromptAndCollectUserInformationArg(FALSE, tvb, offset, actx, tree, hf_inap_PromptAndCollectUserInformationArg_PDU);
366     break;
367   case 49: /* 49 SpecializedResourceReport */
368     offset=dissect_inap_SpecializedResourceReportArg(FALSE, tvb, offset, actx, tree, hf_inap_SpecializedResourceReportArg_PDU);
369     break;
370   case  53: /*Cancel*/
371     offset=dissect_inap_CancelArg(FALSE, tvb, offset, actx, tree, hf_inap_CancelArg_PDU);
372     break;
373   case  80: /*FacilitySelectedAndAvailable*/
374         offset = dissect_inap_FacilitySelectedAndAvailableArg(FALSE, tvb, offset, actx, tree, -1);
375     break;
376   case  81: /*OriginationAttempt*/
377         offset = dissect_inap_OriginationAttemptArg(FALSE, tvb, offset, actx, tree, -1);
378     break;
379   case  82: /*TerminationAttempt*/
380         offset = dissect_inap_TerminationAttemptArg(FALSE, tvb, offset, actx, tree, -1);
381     break;
382   case  83: /*OAbandon*/
383         offset =dissect_inap_OAbandonArg(FALSE, tvb, offset, actx, tree, -1);
384     break;
385   case  84: /*OSuspended*/
386         offset = dissect_inap_OSuspendedArg(FALSE, tvb, offset, actx, tree, -1);
387     break;
388   case  85: /*TSuspended*/
389         offset = dissect_inap_TSuspendedArg(FALSE, tvb, offset, actx, tree, -1);
390     break;
391   case  87: /*AuthorizeTermination*/
392         offset = dissect_inap_AuthorizeTerminationArg(FALSE, tvb, offset, actx, tree, -1);
393     break;
394   case  88: /*continueWithArgument*/
395     offset=dissect_inap_ContinueWithArgumentArg(FALSE, tvb, offset, actx, tree, -1);
396     break;
397   case  89: /*CreateCallSegmentAssociation */
398         offset = dissect_inap_CreateCallSegmentAssociationArg(FALSE, tvb, offset, actx, tree, -1);
399     break;
400   case  90: /*DisconnectLeg*/
401         offset = dissect_inap_DisconnectLegArg(FALSE, tvb, offset, actx, tree, -1);
402     break;
403   case  91: /*MergeCallSegments*/
404         offset = dissect_inap_MergeCallSegmentsArg(FALSE, tvb, offset, actx, tree, -1);
405     break;
406   case  92: /*MoveCallSegments*/
407         offset = dissect_inap_MoveCallSegmentsArg(FALSE, tvb, offset, actx, tree, -1);
408     break;
409   case  93: /*MoveLeg*/
410         offset = dissect_inap_MoveLegArg(FALSE, tvb, offset, actx, tree, -1);
411     break;
412   case  94: /*Reconnect*/
413         offset = dissect_inap_ReconnectArg(FALSE, tvb, offset, actx, tree, -1);
414     break;
415   case  95: /*SplitLeg*/
416         offset = dissect_inap_SplitLegArg(FALSE, tvb, offset, actx, tree, -1);
417     break;
418   case  96: /*EntityReleased*/
419         offset = dissect_inap_EntityReleasedArg(FALSE, tvb, offset, actx, tree, -1);
420     break;
421   case  97: /*ManageTriggerData*/
422         offset = dissect_inap_ManageTriggerDataArg(FALSE, tvb, offset, actx, tree, -1);
423     break;
424   case  98: /*requestReportUTSI*/
425         offset = dissect_inap_RequestReportUTSIArg(FALSE, tvb, offset, actx, tree, -1);
426     break;
427   case  99: /* ReceivedInformation - ???????*/
428         offset = dissect_inap_ReceivedInformationArg(FALSE, tvb, offset, actx, tree, -1);
429     break;
430   case  100: /*sendSTUI*/
431         offset = dissect_inap_SendSTUIArg(FALSE, tvb, offset, actx, tree, -1);
432     break;
433   case  101: /*reportUTSI*/
434         offset = dissect_inap_ReportUTSIArg(FALSE, tvb, offset, actx, tree, -1);
435     break;
436   case  102: /*sendFacilityInformation*/
437         offset = dissect_inap_SendFacilityInformationArg(FALSE, tvb, offset, actx, tree, -1);
438     break;
439   case  103: /*requestReportFacilityEvent*/
440         offset = dissect_inap_RequestReportFacilityEventArg(FALSE, tvb, offset, actx, tree, -1);
441     break;
442   case  104: /*eventReportFacility*/
443         offset = dissect_inap_EventReportFacilityArg(FALSE, tvb, offset, actx, tree, -1);
444     break;
445   case  107: /*promptAndReceiveMessage*/
446         offset = dissect_inap_PromptAndReceiveMessageArg(FALSE, tvb, offset, actx, tree, -1);
447     break;
448   case  108: /*scriptInformation*/
449         offset = dissect_inap_ScriptInformationArg(FALSE, tvb, offset, actx, tree, -1);
450     break;
451   case  109: /*scriptEvent*/
452         offset = dissect_inap_ScriptEventArg(FALSE, tvb, offset, actx, tree, -1);
453     break;
454   case  110: /*scriptRun*/
455         offset = dissect_inap_ScriptRunArg(FALSE, tvb, offset, actx, tree, -1);
456     break;
457   case  111: /*scriptClose*/
458         offset = dissect_inap_ScriptCloseArg(FALSE, tvb, offset, actx, tree, -1);
459     break;
460   case  135: /*createOrRemoveTriggerData*/
461         offset = dissect_inap_CreateOrRemoveTriggerDataArg(FALSE, tvb, offset, actx, tree, -1);
462     break;
463   case  139: /*srfCallGap*/
464         offset = dissect_inap_SRFCallGapArg(FALSE, tvb, offset, actx, tree, -1);
465     break;
466   case  136: /*setServiceProfile*/
467         offset = dissect_inap_SetServiceProfileArg(FALSE, tvb, offset, actx, tree, -1);
468     break;
469   case  145: /*CallFiltering*/
470         offset = dissect_inap_CallFilteringArg(FALSE, tvb, offset, actx, tree, -1);
471     break;
472   case  146: /*monitorRouteRequest*/
473         offset = dissect_inap_MonitorRouteRequestArg(FALSE, tvb, offset, actx, tree, -1);
474     break;
475   case  147: /*monitorRouteReport*/
476         offset = dissect_inap_MonitorRouteReportArg(FALSE, tvb, offset, actx, tree, -1);
477     break;
478         /*55 ActivityTest*/
479    default: 
480     proto_tree_add_text(tree, tvb, offset, -1, "Unknown invokeData blob");
481     /* todo call the asn.1 dissector */
482   }
483   return offset;
484 }
485
486 /*
487 TC-Returnable OPERATION ::=
488   {activateServiceFiltering | activityTest | requestCurrentStatusReport |
489    requestEveryStatusChangeReport | requestFirstStatusMatchReport |
490    promptAndCollectUserInformation}
491
492    activateServiceFiltering                     - No arg
493    activityTest                                         - No Arg
494    requestCurrentStatusReport           - RESULT         RequestCurrentStatusReportResultArg
495    requestEveryStatusChangeReport       - No arg
496    requestFirstStatusMatchReport        - No Arg 
497    promptAndCollectUserInformation      - RESULT         ReceivedInformationArg
498         
499 */
500 static int dissect_returnResultData(proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *actx _U_) {
501   switch(opcode){
502    case 37: /*requestCurrentStatusReport*/
503     offset=dissect_inap_RequestCurrentStatusReportResultArg(FALSE, tvb, offset, actx, tree, -1);
504     break;
505    case 48: /*PromptAndCollectUserInformation*/
506     offset=dissect_inap_ReceivedInformationArg(FALSE, tvb, offset, actx, tree, -1);
507     break;
508   default:
509     proto_tree_add_text(tree, tvb, offset, -1, "Unknown returnResultData blob");
510   }
511   return offset;
512 }
513 /* From GSMMAP TODO find out if there is ERROR parameters */
514 static int dissect_returnErrorData(proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *actx) {
515   proto_item *cause;
516         
517   switch(errorCode){
518   default:
519     cause=proto_tree_add_text(tree, tvb, offset, -1, "Unknown returnErrorData blob");
520     proto_item_set_expert_flags(cause, PI_MALFORMED, PI_WARN);
521     expert_add_info_format(actx->pinfo, cause, PI_MALFORMED, PI_WARN, "Unknown invokeData %d",errorCode);
522     break;
523   }
524   return offset;
525 }
526
527 static guint8 inap_pdu_type = 0;
528 static guint8 inap_pdu_size = 0;
529
530
531 static void
532 dissect_inap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
533 {
534     proto_item          *item=NULL;
535     proto_tree          *tree=NULL;
536         int                             offset = 0;
537
538     if (check_col(pinfo->cinfo, COL_PROTOCOL))
539     {
540         col_set_str(pinfo->cinfo, COL_PROTOCOL, "INAP");
541     }
542
543     /* create display subtree for the protocol */
544     if(parent_tree){
545        item = proto_tree_add_item(parent_tree, proto_inap, tvb, 0, -1, FALSE);
546        tree = proto_item_add_subtree(item, ett_inap);
547     }
548         inap_pdu_type = tvb_get_guint8(tvb, offset)&0x0f;
549         /* Get the length and add 2 */
550         inap_pdu_size = tvb_get_guint8(tvb, offset+1)+2;
551         opcode = 0;
552     dissect_INAP_Component_PDU(tvb, pinfo, tree);
553
554
555 }
556
557 /*--- proto_reg_handoff_inap ---------------------------------------*/
558 static void range_delete_callback(guint32 ssn)
559 {
560     if (ssn) {
561         delete_itu_tcap_subdissector(ssn, inap_handle);
562     }
563 }
564
565 static void range_add_callback(guint32 ssn)
566 {
567     if (ssn) {
568         add_itu_tcap_subdissector(ssn, inap_handle);
569     }
570 }
571
572 void proto_reg_handoff_inap(void) {
573
574     static int inap_prefs_initialized = FALSE;
575     
576     inap_handle = create_dissector_handle(dissect_inap, proto_inap);
577         
578     if (!inap_prefs_initialized) {
579             inap_prefs_initialized = TRUE;
580     }
581     else {
582             range_foreach(ssn_range, range_delete_callback);
583     }
584
585     g_free(ssn_range);
586     ssn_range = range_copy(global_ssn_range);
587
588     range_foreach(ssn_range, range_add_callback);
589
590         oid_add_from_string("Core-INAP-CS1-Codes","0.4.0.1.1.0.3.0");
591 }
592
593
594 void proto_register_inap(void) {
595         module_t *inap_module;
596   /* List of fields */
597   static hf_register_info hf[] = {
598
599           
600
601 #include "packet-inap-hfarr.c"
602   };
603
604
605
606
607
608
609   /* List of subtrees */
610   static gint *ett[] = {
611     &ett_inap,
612         &ett_inapisup_parameter,
613 #include "packet-inap-ettarr.c"
614   };
615
616   /* Register protocol */
617   proto_inap = proto_register_protocol(PNAME, PSNAME, PFNAME);
618   register_dissector("inap", dissect_inap, proto_inap);
619   /* Register fields and subtrees */
620   proto_register_field_array(proto_inap, hf, array_length(hf));
621   proto_register_subtree_array(ett, array_length(ett));
622   
623   /* Set default SSNs */
624   range_convert_str(&global_ssn_range, "106,241", MAX_SSN);
625   ssn_range = range_empty();
626   
627   inap_module = prefs_register_protocol(proto_inap, proto_reg_handoff_inap);
628
629   prefs_register_obsolete_preference(inap_module, "tcap.itu_ssn");
630  
631   prefs_register_obsolete_preference(inap_module, "tcap.itu_ssn1");
632
633   prefs_register_range_preference(inap_module, "ssn", "TCAP SSNs",
634                                   "TCAP Subsystem numbers used for INAP",
635                                   &global_ssn_range, MAX_SSN);
636 }
637
638
639