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 * SPDX-License-Identifier: GPL-2.0-or-later
11 * References: ETSI 300 374
12 * ITU Q.1218
13 */
14
15 #include "config.h"
16
17 #include <epan/packet.h>
18 #include <epan/prefs.h>
19 #include <epan/oids.h>
20 #include <epan/expert.h>
21 #include <epan/asn1.h>
22
23 #include "packet-ber.h"
24 #include "packet-inap.h"
25 #include "packet-q931.h"
26 #include "packet-e164.h"
27 #include "packet-isup.h"
28 #include "packet-tcap.h"
29 #include "packet-dap.h"
30 #include "packet-dsp.h"
31
32 #define PNAME "Intelligent Network Application Protocol"
33 #define PSNAME "INAP"
34 #define PFNAME "inap"
35
36 void proto_register_inap(void);
37 void proto_reg_handoff_inap(void);
38
39
40 /* Initialize the protocol and registered fields */
41 static int proto_inap = -1;
42
43 /* include constants */
44 #include "packet-inap-val.h"
45
46 #include "packet-inap-hf.c"
47
48 #define MAX_SSN 254
49 static range_t *global_ssn_range;
50
51 static dissector_handle_t inap_handle;
52
53 /* Global variables */
54 static guint32 opcode=0;
55 static guint32 errorCode=0;
56 static const char *obj_id = NULL;
57
58 static int inap_opcode_type;
59 #define INAP_OPCODE_INVOKE 1
60 #define INAP_OPCODE_RETURN_RESULT 2
61 #define INAP_OPCODE_RETURN_ERROR 3
62 #define INAP_OPCODE_REJECT 4
63
64 static int hf_inap_cause_indicator = -1;
65
66 /* Initialize the subtree pointers */
67 static gint ett_inap = -1;
68 static gint ett_inapisup_parameter = -1;
69 static gint ett_inap_RedirectionInformation = -1;
70 static gint ett_inap_HighLayerCompatibility = -1;
71 static gint ett_inap_extension_data = -1;
72 static gint ett_inap_cause = -1;
73 static gint ett_inap_calledAddressValue = -1;
74 static gint ett_inap_callingAddressValue = -1;
75 static gint ett_inap_additionalCallingPartyNumber = -1;
76 static gint ett_inap_assistingSSPIPRoutingAddress = -1;
77 static gint ett_inap_correlationID = -1;
78 static gint ett_inap_number = -1;
79 static gint ett_inap_dialledNumber = -1;
80 static gint ett_inap_callingLineID = -1;
81 static gint ett_inap_iNServiceControlCode = -1;
82 static gint ett_inap_iNServiceControlCodeLow = -1;
83 static gint ett_inap_iNServiceControlCodeHigh = -1;
84 static gint ett_inap_lineID = -1;
85 static gint ett_inap_prefix = -1;
86 static gint ett_inap_iPAddressValue = -1;
87 static gint ett_inap_digitsResponse = -1;
88
89 #include "packet-inap-ett.c"
90
91 static expert_field ei_inap_unknown_invokeData = EI_INIT;
92 static expert_field ei_inap_unknown_returnResultData = EI_INIT;
93 static expert_field ei_inap_unknown_returnErrorData = EI_INIT;
94
95 #include "packet-inap-table.c"
96
97 const value_string inap_general_problem_strings[] = {
98 {0,"General Problem Unrecognized Component"},
99 {1,"General Problem Mistyped Component"},
100 {3,"General Problem Badly Structured Component"},
101 {0, NULL}
102 };
103
104 /* Forvard declarations */
105 static int dissect_invokeData(proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *actx _U_);
106 static int dissect_returnResultData(proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *actx _U_);
107 static int dissect_returnErrorData(proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *actx);
108
109 #include "packet-inap-fn.c"
110 /*
111 TC-Invokable OPERATION ::=
112 {activateServiceFiltering | activityTest | analysedInformation |
113 analyseInformation | applyCharging | applyChargingReport |
114 assistRequestInstructions | callGap | callInformationReport |
115 callInformationRequest | cancel | cancelStatusReportRequest |
116 collectedInformation | collectInformation | connect | connectToResource |
117 continue | disconnectForwardConnection | establishTemporaryConnection |
118 eventNotificationCharging | eventReportBCSM | furnishChargingInformation |
119 holdCallInNetwork | initialDP | initiateCallAttempt | oAnswer |
120 oCalledPartyBusy | oDisconnect | oMidCall | oNoAnswer |
121 originationAttemptAuthorized | releaseCall | requestCurrentStatusReport |
122 requestEveryStatusChangeReport | requestFirstStatusMatchReport |
123 requestNotificationChargingEvent | requestReportBCSMEvent | resetTimer |
124 routeSelectFailure | selectFacility | selectRoute | sendChargingInformation
125 | serviceFilteringResponse | statusReport | tAnswer | tBusy | tDisconnect |
126 termAttemptAuthorized | tMidCall | tNoAnswer | playAnnouncement |
127 promptAndCollectUserInformation}
128 */
129
130 #include "packet-inap-table2.c"
131
132
133 static guint8 inap_pdu_type = 0;
134 static guint8 inap_pdu_size = 0;
135
136
137 static int
dissect_inap(tvbuff_t * tvb,packet_info * pinfo,proto_tree * parent_tree,void * data _U_)138 dissect_inap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *data _U_)
139 {
140 proto_item *item=NULL;
141 proto_tree *tree=NULL;
142 int offset = 0;
143 asn1_ctx_t asn1_ctx;
144 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
145
146 col_set_str(pinfo->cinfo, COL_PROTOCOL, "INAP");
147
148 /* create display subtree for the protocol */
149 if(parent_tree){
150 item = proto_tree_add_item(parent_tree, proto_inap, tvb, 0, -1, ENC_NA);
151 tree = proto_item_add_subtree(item, ett_inap);
152 }
153 inap_pdu_type = tvb_get_guint8(tvb, offset)&0x0f;
154 /* Get the length and add 2 */
155 inap_pdu_size = tvb_get_guint8(tvb, offset+1)+2;
156 opcode = 0;
157 dissect_inap_ROS(TRUE, tvb, offset, &asn1_ctx, tree, -1);
158
159 return inap_pdu_size;
160 }
161
162 /*--- proto_reg_handoff_inap ---------------------------------------*/
range_delete_callback(guint32 ssn,gpointer ptr _U_)163 static void range_delete_callback(guint32 ssn, gpointer ptr _U_)
164 {
165 if (ssn) {
166 delete_itu_tcap_subdissector(ssn, inap_handle);
167 }
168 }
169
range_add_callback(guint32 ssn,gpointer ptr _U_)170 static void range_add_callback(guint32 ssn, gpointer ptr _U_)
171 {
172 if (ssn) {
173 add_itu_tcap_subdissector(ssn, inap_handle);
174 }
175 }
176
proto_reg_handoff_inap(void)177 void proto_reg_handoff_inap(void) {
178
179 static gboolean inap_prefs_initialized = FALSE;
180 static range_t *ssn_range;
181
182 if (!inap_prefs_initialized) {
183 inap_prefs_initialized = TRUE;
184 oid_add_from_string("Core-INAP-CS1-Codes","0.4.0.1.1.0.3.0");
185 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");
186 oid_add_from_string("alcatel(1006)","1.3.12.2.1006.64");
187 oid_add_from_string("Siemens (1107)","1.3.12.2.1107");
188 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");
189 }
190 else {
191 range_foreach(ssn_range, range_delete_callback, NULL);
192 wmem_free(wmem_epan_scope(), ssn_range);
193 }
194
195 ssn_range = range_copy(wmem_epan_scope(), global_ssn_range);
196
197 range_foreach(ssn_range, range_add_callback, NULL);
198
199 }
200
201
proto_register_inap(void)202 void proto_register_inap(void) {
203 module_t *inap_module;
204 /* List of fields */
205 static hf_register_info hf[] = {
206
207
208 { &hf_inap_cause_indicator, /* Currently not enabled */
209 { "Cause indicator", "inap.cause_indicator",
210 FT_UINT8, BASE_DEC | BASE_EXT_STRING, &q850_cause_code_vals_ext, 0x7f,
211 NULL, HFILL } },
212
213 #include "packet-inap-hfarr.c"
214 };
215
216
217
218
219
220
221 /* List of subtrees */
222 static gint *ett[] = {
223 &ett_inap,
224 &ett_inapisup_parameter,
225 &ett_inap_RedirectionInformation,
226 &ett_inap_HighLayerCompatibility,
227 &ett_inap_extension_data,
228 &ett_inap_cause,
229 &ett_inap_calledAddressValue,
230 &ett_inap_callingAddressValue,
231 &ett_inap_additionalCallingPartyNumber,
232 &ett_inap_assistingSSPIPRoutingAddress,
233 &ett_inap_correlationID,
234 &ett_inap_number,
235 &ett_inap_dialledNumber,
236 &ett_inap_callingLineID,
237 &ett_inap_iNServiceControlCode,
238 &ett_inap_iNServiceControlCodeLow,
239 &ett_inap_iNServiceControlCodeHigh,
240 &ett_inap_lineID,
241 &ett_inap_prefix,
242 &ett_inap_iPAddressValue,
243 &ett_inap_digitsResponse,
244 #include "packet-inap-ettarr.c"
245 };
246
247 static ei_register_info ei[] = {
248 { &ei_inap_unknown_invokeData, { "inap.unknown.invokeData", PI_MALFORMED, PI_WARN, "Unknown invokeData", EXPFILL }},
249 { &ei_inap_unknown_returnResultData, { "inap.unknown.returnResultData", PI_MALFORMED, PI_WARN, "Unknown returnResultData", EXPFILL }},
250 { &ei_inap_unknown_returnErrorData, { "inap.unknown.returnErrorData", PI_MALFORMED, PI_WARN, "Unknown returnResultData", EXPFILL }},
251 };
252
253 expert_module_t* expert_inap;
254
255 /* Register protocol */
256 proto_inap = proto_register_protocol(PNAME, PSNAME, PFNAME);
257 inap_handle = register_dissector("inap", dissect_inap, proto_inap);
258 /* Register fields and subtrees */
259 proto_register_field_array(proto_inap, hf, array_length(hf));
260 proto_register_subtree_array(ett, array_length(ett));
261 expert_inap = expert_register_protocol(proto_inap);
262 expert_register_field_array(expert_inap, ei, array_length(ei));
263
264 register_ber_oid_dissector("0.4.0.1.1.1.0.0", dissect_inap, proto_inap, "cs1-ssp-to-scp");
265
266 /* Set default SSNs */
267 range_convert_str(wmem_epan_scope(), &global_ssn_range, "106,241", MAX_SSN);
268
269 inap_module = prefs_register_protocol(proto_inap, proto_reg_handoff_inap);
270
271 prefs_register_obsolete_preference(inap_module, "tcap.itu_ssn");
272
273 prefs_register_obsolete_preference(inap_module, "tcap.itu_ssn1");
274
275 prefs_register_range_preference(inap_module, "ssn", "TCAP SSNs",
276 "TCAP Subsystem numbers used for INAP",
277 &global_ssn_range, MAX_SSN);
278 }
279
280 /*
281 * Editor modelines
282 *
283 * Local Variables:
284 * c-basic-offset: 2
285 * tab-width: 8
286 * indent-tabs-mode: nil
287 * End:
288 *
289 * ex: set shiftwidth=2 tabstop=8 expandtab:
290 * :indentSize=2:tabSize=8:noTabs=true:
291 */
292