Make all proto_* values static.
[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/oids.h>
36 #include <epan/expert.h>
37 #include <epan/asn1.h>
38
39 #include <stdio.h>
40 #include <string.h>
41
42 #include "packet-ber.h"
43 #include "packet-inap.h"
44 #include "packet-q931.h"
45 #include "packet-e164.h"
46 #include "packet-isup.h"
47 #include "packet-tcap.h"
48
49 #define PNAME  "Intelligent Network Application Protocol"
50 #define PSNAME "INAP"
51 #define PFNAME "inap"
52
53 /* Initialize the protocol and registered fields */
54 static int proto_inap = -1;
55
56 /* include constants */
57 #include "packet-inap-val.h"
58
59 #include "packet-inap-hf.c"
60
61 #define MAX_SSN 254
62 static range_t *global_ssn_range;
63
64 static dissector_handle_t       inap_handle;
65
66 /* Global variables */
67 static guint32 opcode=0;
68 static guint32 errorCode=0;
69
70 static int inap_opcode_type;
71 #define INAP_OPCODE_INVOKE        1
72 #define INAP_OPCODE_RETURN_RESULT 2
73 #define INAP_OPCODE_RETURN_ERROR  3
74 #define INAP_OPCODE_REJECT        4
75
76 /* Initialize the subtree pointers */
77 static gint ett_inap = -1;
78 static gint ett_inapisup_parameter = -1;
79 #include "packet-inap-ett.c"
80
81 #include "packet-inap-table.c"
82
83 const value_string inap_general_problem_strings[] = {
84 {0,"General Problem Unrecognized Component"},
85 {1,"General Problem Mistyped Component"},
86 {3,"General Problem Badly Structured Component"},
87 {0, NULL}
88 };
89
90 /* Forvard declarations */
91 static int dissect_invokeData(proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *actx _U_);
92 static int dissect_returnResultData(proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *actx _U_);
93 static int dissect_returnErrorData(proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *actx);
94
95 #include "packet-inap-fn.c"
96 /*
97 TC-Invokable OPERATION ::=
98   {activateServiceFiltering | activityTest | analysedInformation |
99    analyseInformation | applyCharging | applyChargingReport |
100    assistRequestInstructions | callGap | callInformationReport |
101    callInformationRequest | cancel | cancelStatusReportRequest |
102    collectedInformation | collectInformation | connect | connectToResource |
103    continue | disconnectForwardConnection | establishTemporaryConnection |
104    eventNotificationCharging | eventReportBCSM | furnishChargingInformation |
105    holdCallInNetwork | initialDP | initiateCallAttempt | oAnswer |
106    oCalledPartyBusy | oDisconnect | oMidCall | oNoAnswer |
107    originationAttemptAuthorized | releaseCall | requestCurrentStatusReport |
108    requestEveryStatusChangeReport | requestFirstStatusMatchReport |
109    requestNotificationChargingEvent | requestReportBCSMEvent | resetTimer |
110    routeSelectFailure | selectFacility | selectRoute | sendChargingInformation
111    | serviceFilteringResponse | statusReport | tAnswer | tBusy | tDisconnect |
112    termAttemptAuthorized | tMidCall | tNoAnswer | playAnnouncement |
113    promptAndCollectUserInformation}
114 */
115
116 #include "packet-inap-table2.c"
117
118
119 static guint8 inap_pdu_type = 0;
120 static guint8 inap_pdu_size = 0;
121
122
123 static void
124 dissect_inap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
125 {
126     proto_item          *item=NULL;
127     proto_tree          *tree=NULL;
128         int                             offset = 0;
129         asn1_ctx_t asn1_ctx;
130         asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
131
132     col_set_str(pinfo->cinfo, COL_PROTOCOL, "INAP");
133
134     /* create display subtree for the protocol */
135     if(parent_tree){
136        item = proto_tree_add_item(parent_tree, proto_inap, tvb, 0, -1, FALSE);
137        tree = proto_item_add_subtree(item, ett_inap);
138     }
139         inap_pdu_type = tvb_get_guint8(tvb, offset)&0x0f;
140         /* Get the length and add 2 */
141         inap_pdu_size = tvb_get_guint8(tvb, offset+1)+2;
142         opcode = 0;
143     offset = dissect_inap_ROS(TRUE, tvb, offset, &asn1_ctx, tree, -1);
144
145
146 }
147
148 /*--- proto_reg_handoff_inap ---------------------------------------*/
149 static void range_delete_callback(guint32 ssn)
150 {
151     if (ssn) {
152         delete_itu_tcap_subdissector(ssn, inap_handle);
153     }
154 }
155
156 static void range_add_callback(guint32 ssn)
157 {
158     if (ssn) {
159         add_itu_tcap_subdissector(ssn, inap_handle);
160     }
161 }
162
163 void proto_reg_handoff_inap(void) {
164
165     static gboolean inap_prefs_initialized = FALSE;
166     static range_t *ssn_range;
167
168     if (!inap_prefs_initialized) {
169             inap_prefs_initialized = TRUE;
170             inap_handle = find_dissector("inap");
171             oid_add_from_string("Core-INAP-CS1-Codes","0.4.0.1.1.0.3.0");
172     }
173     else {
174             range_foreach(ssn_range, range_delete_callback);
175             g_free(ssn_range);
176     }
177
178     ssn_range = range_copy(global_ssn_range);
179
180     range_foreach(ssn_range, range_add_callback);
181
182 }
183
184
185 void proto_register_inap(void) {
186         module_t *inap_module;
187   /* List of fields */
188   static hf_register_info hf[] = {
189
190
191
192 #include "packet-inap-hfarr.c"
193   };
194
195
196
197
198
199
200   /* List of subtrees */
201   static gint *ett[] = {
202     &ett_inap,
203         &ett_inapisup_parameter,
204 #include "packet-inap-ettarr.c"
205   };
206
207   /* Register protocol */
208   proto_inap = proto_register_protocol(PNAME, PSNAME, PFNAME);
209   register_dissector("inap", dissect_inap, proto_inap);
210   /* Register fields and subtrees */
211   proto_register_field_array(proto_inap, hf, array_length(hf));
212   proto_register_subtree_array(ett, array_length(ett));
213
214   /* Set default SSNs */
215   range_convert_str(&global_ssn_range, "106,241", MAX_SSN);
216
217   inap_module = prefs_register_protocol(proto_inap, proto_reg_handoff_inap);
218
219   prefs_register_obsolete_preference(inap_module, "tcap.itu_ssn");
220
221   prefs_register_obsolete_preference(inap_module, "tcap.itu_ssn1");
222
223   prefs_register_range_preference(inap_module, "ssn", "TCAP SSNs",
224                                   "TCAP Subsystem numbers used for INAP",
225                                   &global_ssn_range, MAX_SSN);
226 }
227
228
229