[Automatic update for 2016-03-13]
[metze/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  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  * References: ETSI 300 374
24  * ITU Q.1218
25  */
26
27 #include "config.h"
28
29 #include <epan/packet.h>
30 #include <epan/prefs.h>
31 #include <epan/oids.h>
32 #include <epan/expert.h>
33 #include <epan/asn1.h>
34
35 #include "packet-ber.h"
36 #include "packet-inap.h"
37 #include "packet-q931.h"
38 #include "packet-e164.h"
39 #include "packet-isup.h"
40 #include "packet-tcap.h"
41 #include "packet-dap.h"
42 #include "packet-dsp.h"
43
44 #define PNAME  "Intelligent Network Application Protocol"
45 #define PSNAME "INAP"
46 #define PFNAME "inap"
47
48 void proto_register_inap(void);
49 void proto_reg_handoff_inap(void);
50
51
52 /* Initialize the protocol and registered fields */
53 static int proto_inap = -1;
54
55 /* include constants */
56 #include "packet-inap-val.h"
57
58 #include "packet-inap-hf.c"
59
60 #define MAX_SSN 254
61 static range_t *global_ssn_range;
62
63 static dissector_handle_t       inap_handle;
64 static dissector_handle_t       data_handle;
65
66 /* Global variables */
67 static guint32 opcode=0;
68 static guint32 errorCode=0;
69 static const char *obj_id = NULL;
70
71 static int inap_opcode_type;
72 #define INAP_OPCODE_INVOKE        1
73 #define INAP_OPCODE_RETURN_RESULT 2
74 #define INAP_OPCODE_RETURN_ERROR  3
75 #define INAP_OPCODE_REJECT        4
76
77 static int hf_inap_cause_indicator = -1;
78
79 /* Initialize the subtree pointers */
80 static gint ett_inap = -1;
81 static gint ett_inapisup_parameter = -1;
82 static gint ett_inap_HighLayerCompatibility = -1;
83 static gint ett_inap_extension_data = -1;
84 static gint ett_inap_cause = -1;
85
86 #include "packet-inap-ett.c"
87
88 static expert_field ei_inap_unknown_invokeData = EI_INIT;
89 static expert_field ei_inap_unknown_returnResultData = EI_INIT;
90 static expert_field ei_inap_unknown_returnErrorData = EI_INIT;
91
92 #include "packet-inap-table.c"
93
94 const value_string inap_general_problem_strings[] = {
95 {0,"General Problem Unrecognized Component"},
96 {1,"General Problem Mistyped Component"},
97 {3,"General Problem Badly Structured Component"},
98 {0, NULL}
99 };
100
101 /* Forvard declarations */
102 static int dissect_invokeData(proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *actx _U_);
103 static int dissect_returnResultData(proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *actx _U_);
104 static int dissect_returnErrorData(proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *actx);
105
106 #include "packet-inap-fn.c"
107 /*
108 TC-Invokable OPERATION ::=
109   {activateServiceFiltering | activityTest | analysedInformation |
110    analyseInformation | applyCharging | applyChargingReport |
111    assistRequestInstructions | callGap | callInformationReport |
112    callInformationRequest | cancel | cancelStatusReportRequest |
113    collectedInformation | collectInformation | connect | connectToResource |
114    continue | disconnectForwardConnection | establishTemporaryConnection |
115    eventNotificationCharging | eventReportBCSM | furnishChargingInformation |
116    holdCallInNetwork | initialDP | initiateCallAttempt | oAnswer |
117    oCalledPartyBusy | oDisconnect | oMidCall | oNoAnswer |
118    originationAttemptAuthorized | releaseCall | requestCurrentStatusReport |
119    requestEveryStatusChangeReport | requestFirstStatusMatchReport |
120    requestNotificationChargingEvent | requestReportBCSMEvent | resetTimer |
121    routeSelectFailure | selectFacility | selectRoute | sendChargingInformation
122    | serviceFilteringResponse | statusReport | tAnswer | tBusy | tDisconnect |
123    termAttemptAuthorized | tMidCall | tNoAnswer | playAnnouncement |
124    promptAndCollectUserInformation}
125 */
126
127 #include "packet-inap-table2.c"
128
129
130 static guint8 inap_pdu_type = 0;
131 static guint8 inap_pdu_size = 0;
132
133
134 static int
135 dissect_inap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *data _U_)
136 {
137   proto_item            *item=NULL;
138   proto_tree            *tree=NULL;
139   int                           offset = 0;
140   asn1_ctx_t asn1_ctx;
141   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
142
143   col_set_str(pinfo->cinfo, COL_PROTOCOL, "INAP");
144
145   /* create display subtree for the protocol */
146   if(parent_tree){
147     item = proto_tree_add_item(parent_tree, proto_inap, tvb, 0, -1, ENC_NA);
148     tree = proto_item_add_subtree(item, ett_inap);
149   }
150   inap_pdu_type = tvb_get_guint8(tvb, offset)&0x0f;
151   /* Get the length and add 2 */
152   inap_pdu_size = tvb_get_guint8(tvb, offset+1)+2;
153   opcode = 0;
154   dissect_inap_ROS(TRUE, tvb, offset, &asn1_ctx, tree, -1);
155
156   return inap_pdu_size;
157 }
158
159 /*--- proto_reg_handoff_inap ---------------------------------------*/
160 static void range_delete_callback(guint32 ssn)
161 {
162   if (ssn) {
163     delete_itu_tcap_subdissector(ssn, inap_handle);
164   }
165 }
166
167 static void range_add_callback(guint32 ssn)
168 {
169   if (ssn) {
170   add_itu_tcap_subdissector(ssn, inap_handle);
171   }
172 }
173
174 void proto_reg_handoff_inap(void) {
175
176   static gboolean inap_prefs_initialized = FALSE;
177   static range_t *ssn_range;
178
179   if (!inap_prefs_initialized) {
180     inap_prefs_initialized = TRUE;
181     inap_handle = find_dissector("inap");
182     data_handle = find_dissector("data");
183     oid_add_from_string("Core-INAP-CS1-Codes","0.4.0.1.1.0.3.0");
184     oid_add_from_string("iso(1) identified-organization(3) icd-ecma(12) member-company(2) 1107 oen(3) inap(3) extensions(2)","1.3.12.2.1107.3.3.2");
185     oid_add_from_string("alcatel(1006)","1.3.12.2.1006.64");
186     oid_add_from_string("Siemens (1107)","1.3.12.2.1107");
187     oid_add_from_string("iso(1) member-body(2) gb(826) national(0) ericsson(1249) inDomain(51) inNetwork(1) inNetworkcapabilitySet1plus(1) ","1.2.826.0.1249.51.1.1");
188   }
189   else {
190     range_foreach(ssn_range, range_delete_callback);
191     g_free(ssn_range);
192   }
193
194   ssn_range = range_copy(global_ssn_range);
195
196   range_foreach(ssn_range, range_add_callback);
197
198 }
199
200
201 void proto_register_inap(void) {
202   module_t *inap_module;
203   /* List of fields */
204   static hf_register_info hf[] = {
205
206
207     { &hf_inap_cause_indicator, /* Currently not enabled */
208     { "Cause indicator", "inap.cause_indicator",
209     FT_UINT8, BASE_DEC | BASE_EXT_STRING, &q850_cause_code_vals_ext, 0x7f,
210     NULL, HFILL } },
211
212 #include "packet-inap-hfarr.c"
213   };
214
215
216
217
218
219
220   /* List of subtrees */
221   static gint *ett[] = {
222     &ett_inap,
223     &ett_inapisup_parameter,
224     &ett_inap_HighLayerCompatibility,
225     &ett_inap_extension_data,
226     &ett_inap_cause,
227 #include "packet-inap-ettarr.c"
228   };
229
230   static ei_register_info ei[] = {
231    { &ei_inap_unknown_invokeData, { "inap.unknown.invokeData", PI_MALFORMED, PI_WARN, "Unknown invokeData", EXPFILL }},
232    { &ei_inap_unknown_returnResultData, { "inap.unknown.returnResultData", PI_MALFORMED, PI_WARN, "Unknown returnResultData", EXPFILL }},
233    { &ei_inap_unknown_returnErrorData, { "inap.unknown.returnErrorData", PI_MALFORMED, PI_WARN, "Unknown returnResultData", EXPFILL }},
234   };
235
236   expert_module_t* expert_inap;
237
238   /* Register protocol */
239   proto_inap = proto_register_protocol(PNAME, PSNAME, PFNAME);
240   register_dissector("inap", dissect_inap, proto_inap);
241   /* Register fields and subtrees */
242   proto_register_field_array(proto_inap, hf, array_length(hf));
243   proto_register_subtree_array(ett, array_length(ett));
244   expert_inap = expert_register_protocol(proto_inap);
245   expert_register_field_array(expert_inap, ei, array_length(ei));
246
247   register_ber_oid_dissector("0.4.0.1.1.1.0.0", dissect_inap, proto_inap, "cs1-ssp-to-scp");
248
249   /* Set default SSNs */
250   range_convert_str(&global_ssn_range, "106,241", MAX_SSN);
251
252   inap_module = prefs_register_protocol(proto_inap, proto_reg_handoff_inap);
253
254   prefs_register_obsolete_preference(inap_module, "tcap.itu_ssn");
255
256   prefs_register_obsolete_preference(inap_module, "tcap.itu_ssn1");
257
258   prefs_register_range_preference(inap_module, "ssn", "TCAP SSNs",
259                  "TCAP Subsystem numbers used for INAP",
260                  &global_ssn_range, MAX_SSN);
261 }
262
263 /*
264  * Editor modelines
265  *
266  * Local Variables:
267  * c-basic-offset: 2
268  * tab-width: 8
269  * indent-tabs-mode: nil
270  * End:
271  *
272  * ex: set shiftwidth=2 tabstop=8 expandtab:
273  * :indentSize=2:tabSize=8:noTabs=true:
274  */