2 * Routines for Q.932 packet dissection
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
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.
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.
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.
30 #include <epan/packet.h>
31 #include <epan/strutil.h>
32 #include <epan/asn1.h>
34 #include "packet-ber.h"
35 #include "packet-q932.h"
41 /* Initialize the protocol and registered fields */
42 static int proto_q932 = -1;
43 static int hf_q932_ie_type = -1;
44 static int hf_q932_ie_len = -1;
45 static int hf_q932_ie_data = -1;
46 static int hf_q932_pp = -1;
47 static int hf_q932_nd = -1;
48 #include "packet-q932-hf.c"
50 /* Initialize the subtree pointers */
51 static gint ett_q932 = -1;
52 static gint ett_q932_ie = -1;
53 #include "packet-q932-ett.c"
58 static rose_ctx_t q932_rose_ctx;
61 static dissector_handle_t q932_ros_handle;
63 #define Q932_IE_EXTENDED_FACILITY 0x0D
64 #define Q932_IE_FACILITY 0x1C
65 #define Q932_IE_NOTIFICATION_INDICATOR 0x27
66 #define Q932_IE_INFORMATION_REQUEST 0x32
67 #define Q932_IE_FEATURE_ACTIVATION 0x38
68 #define Q932_IE_FEATURE_INDICATION 0x39
69 #define Q932_IE_SERVICE_PROFILE_ID 0x3A
70 #define Q932_IE_ENDPOINT_IDENTIFIER 0x3B
71 static const value_string q932_str_ie_type[] = {
72 { Q932_IE_EXTENDED_FACILITY , "Extended facility" },
73 { Q932_IE_FACILITY , "Facility" },
74 { Q932_IE_NOTIFICATION_INDICATOR, "Notification indicator" },
75 { Q932_IE_INFORMATION_REQUEST, "Information request" },
76 { Q932_IE_FEATURE_ACTIVATION , "Feature activation" },
77 { Q932_IE_FEATURE_INDICATION , "Feature indication" },
78 { Q932_IE_SERVICE_PROFILE_ID , "Service profile identification" },
79 { Q932_IE_ENDPOINT_IDENTIFIER, "Endpoint identifier" },
83 static const value_string str_pp[] = {
84 { 0x11 , "Remote Operations Protocol" },
85 { 0x12 , "CMIP Protocol" },
86 { 0x13 , "ACSE Protocol" },
87 { 0x1F , "Networking extensions" },
91 static const value_string str_nd[] = {
92 { 0x00 , "User suspended" },
93 { 0x01 , "User resume" },
94 { 0x02 , "Bearer service change" },
95 { 0x04 , "Call completion delay" },
96 { 0x03 , "Discriminator for extension to ASN.1 encoded component" },
97 { 0x40 , "Discriminator for extension to ASN.1 encoded component for ISO" },
98 { 0x42 , "Conference established" },
99 { 0x43 , "Conference disconnected" },
100 { 0x44 , "Other party added" },
101 { 0x45 , "Isolated" },
102 { 0x46 , "Reattached" },
103 { 0x47 , "Other party isolated" },
104 { 0x48 , "Other party reattached" },
105 { 0x49 , "Other party split" },
106 { 0x4A , "Other party disconnected" },
107 { 0x4B , "Conference floating" },
108 { 0x4C , "Conference disconnected, pre-emption" },
109 { 0x4F , "Conference floating, served user pre-empted" },
110 { 0x60 , "Call is a waiting call" },
111 { 0x68 , "Diversion activated" },
112 { 0x69 , "call transferred, alerting" },
113 { 0x6A , "call transferred, answered" },
114 { 0x6E , "reverse charging (whole call)" },
115 { 0x6F , "reverse charging (for the rest of the call)" },
116 { 0x74 , "service profile update" },
117 { 0x79 , "Remote hold" },
118 { 0x7A , "Remote retrieval" },
119 { 0x7B , "Call is diverting" },
123 #include "packet-q932-fn.c"
125 /*--- dissect_q932_facility_ie -------------------------------------------------------*/
127 dissect_q932_facility_ie(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, int length) {
132 int hoffset, eoffset;
136 ie_end = offset + length;
137 proto_tree_add_item(tree, hf_q932_pp, tvb, offset, 1, FALSE);
139 while (offset < ie_end) {
141 offset = get_ber_identifier(tvb, offset, &class, &pc, &tag);
142 offset = get_ber_length(tvb, offset, &len, NULL);
143 eoffset = offset + len;
144 next_tvb = tvb_new_subset(tvb, hoffset, eoffset - hoffset, eoffset - hoffset);
148 case 10 : /* Network Facility Extension */
149 dissect_NetworkFacilityExtension_PDU(next_tvb, pinfo, tree);
151 case 18 : /* Network Protocol Profile */
152 dissect_NetworkProtocolProfile_PDU(next_tvb, pinfo, tree);
154 case 11 : /* Interpretation Component */
155 dissect_InterpretationComponent_PDU(next_tvb, pinfo, tree);
158 case 1 : /* invoke */
159 case 2 : /* returnResult */
160 case 3 : /* returnError */
161 case 4 : /* reject */
162 q932_rose_ctx.apdu_depth = 1;
163 pinfo->private_data = &q932_rose_ctx;
164 call_dissector(q932_ros_handle, next_tvb, pinfo, tree);
167 case 12 : /* begin */
169 case 15 : /* continue */
170 case 17 : /* abort */
171 offset = dissect_ber_identifier(pinfo, tree, tvb, hoffset, NULL, NULL, NULL);
172 offset = dissect_ber_length(pinfo, tree, tvb, offset, NULL, NULL);
173 proto_tree_add_text(tree, tvb, offset, len, "DSE APDU (not supported)");
176 offset = dissect_ber_identifier(pinfo, tree, tvb, hoffset, NULL, NULL, NULL);
177 offset = dissect_ber_length(pinfo, tree, tvb, offset, NULL, NULL);
178 proto_tree_add_text(tree, tvb, offset, len, "Unknown Component");
189 offset = dissect_ber_identifier(pinfo, tree, tvb, hoffset, NULL, NULL, NULL);
190 offset = dissect_ber_length(pinfo, tree, tvb, offset, NULL, NULL);
191 proto_tree_add_text(tree, tvb, offset, len, "ACSE APDU (not supported)");
194 offset = dissect_ber_identifier(pinfo, tree, tvb, hoffset, NULL, NULL, NULL);
195 offset = dissect_ber_length(pinfo, tree, tvb, offset, NULL, NULL);
196 proto_tree_add_text(tree, tvb, offset, len, "Unknown Component");
200 offset = dissect_ber_identifier(pinfo, tree, tvb, hoffset, NULL, NULL, NULL);
201 offset = dissect_ber_length(pinfo, tree, tvb, offset, NULL, NULL);
202 proto_tree_add_text(tree, tvb, offset, len, "Unknown Component");
208 /*--- dissect_q932_ni_ie -------------------------------------------------------*/
210 dissect_q932_ni_ie(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int length) {
215 while ((remain > 0) && !(octet & 0x80)) {
216 octet = tvb_get_guint8(tvb, offset++);
219 value |= octet & 0x7F;
221 proto_tree_add_uint(tree, hf_q932_nd, tvb, offset - (length - remain), length - remain, value);
224 proto_tree_add_text(tree, tvb, offset - remain, remain, "ASN.1 Encoded Data Structure(NOT IMPLEMENTED): %s", tvb_bytes_to_str(tvb, offset - remain, remain));
228 /*--- dissect_q932_ie -------------------------------------------------------*/
230 dissect_q932_ie(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
232 proto_item *ti, *ti_ie;
234 guint8 ie_type, ie_len;
238 ti = proto_tree_add_item(tree, proto_q932, tvb, offset, -1, FALSE);
239 PROTO_ITEM_SET_HIDDEN(ti);
241 ie_type = tvb_get_guint8(tvb, offset);
242 ie_len = tvb_get_guint8(tvb, offset + 1);
244 ti_ie = proto_tree_add_text(tree, tvb, offset, -1, "%s",
245 val_to_str(ie_type, VALS(q932_str_ie_type), "unknown (0x%02X)"));
246 ie_tree = proto_item_add_subtree(ti_ie, ett_q932_ie);
247 proto_tree_add_item(ie_tree, hf_q932_ie_type, tvb, offset, 1, FALSE);
248 proto_tree_add_item(ie_tree, hf_q932_ie_len, tvb, offset + 1, 1, FALSE);
250 if (tvb_length_remaining(tvb, offset) <= 0)
253 case Q932_IE_FACILITY :
254 dissect_q932_facility_ie(tvb, offset, pinfo, ie_tree, ie_len);
256 case Q932_IE_NOTIFICATION_INDICATOR :
257 dissect_q932_ni_ie(tvb, offset, pinfo, ie_tree, ie_len);
261 if (tree) proto_tree_add_item(ie_tree, hf_q932_ie_data, tvb, offset, ie_len, FALSE);
266 /*--- dissect_q932_apdu -----------------------------------------------------*/
268 dissect_q932_apdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
269 call_dissector(q932_ros_handle, tvb, pinfo, tree);
272 /*--- proto_register_q932 ---------------------------------------------------*/
273 void proto_register_q932(void) {
276 static hf_register_info hf[] = {
277 { &hf_q932_ie_type, { "Type", "q932.ie.type",
278 FT_UINT8, BASE_HEX, VALS(q932_str_ie_type), 0x0,
279 "Information Element Type", HFILL }},
280 { &hf_q932_ie_len, { "Length", "q932.ie.len",
281 FT_UINT8, BASE_DEC, NULL, 0x0,
282 "Information Element Length", HFILL }},
283 { &hf_q932_ie_data, { "Data", "q932.ie.data",
284 FT_BYTES, BASE_NONE, NULL, 0x0,
286 { &hf_q932_pp, { "Protocol profile", "q932.pp",
287 FT_UINT8, BASE_HEX, VALS(str_pp), 0x1F,
289 { &hf_q932_nd, { "Notification description", "q932.nd",
290 FT_UINT8, BASE_HEX, VALS(str_nd), 0x0,
292 #include "packet-q932-hfarr.c"
295 /* List of subtrees */
296 static gint *ett[] = {
299 #include "packet-q932-ettarr.c"
302 /* Register protocol and dissector */
303 proto_q932 = proto_register_protocol(PNAME, PSNAME, PFNAME);
304 register_dissector("q932.apdu", dissect_q932_apdu, proto_q932);
306 /* Register fields and subtrees */
307 proto_register_field_array(proto_q932, hf, array_length(hf));
308 proto_register_subtree_array(ett, array_length(ett));
310 rose_ctx_init(&q932_rose_ctx);
312 /* Register dissector tables */
313 q932_rose_ctx.arg_global_dissector_table = register_dissector_table("q932.ros.global.arg", "Q.932 Operation Argument (global opcode)", FT_STRING, BASE_NONE);
314 q932_rose_ctx.res_global_dissector_table = register_dissector_table("q932.ros.global.res", "Q.932 Operation Result (global opcode)", FT_STRING, BASE_NONE);
315 q932_rose_ctx.arg_local_dissector_table = register_dissector_table("q932.ros.local.arg", "Q.932 Operation Argument (local opcode)", FT_UINT32, BASE_HEX);
316 q932_rose_ctx.res_local_dissector_table = register_dissector_table("q932.ros.local.res", "Q.932 Operation Result (local opcode)", FT_UINT32, BASE_HEX);
317 q932_rose_ctx.err_global_dissector_table = register_dissector_table("q932.ros.global.err", "Q.932 Error (global opcode)", FT_STRING, BASE_NONE);
318 q932_rose_ctx.err_local_dissector_table = register_dissector_table("q932.ros.local.err", "Q.932 Error (local opcode)", FT_UINT32, BASE_HEX);
321 /*--- proto_reg_handoff_q932 ------------------------------------------------*/
322 void proto_reg_handoff_q932(void) {
323 dissector_handle_t q932_ie_handle;
325 q932_ie_handle = create_dissector_handle(dissect_q932_ie, proto_q932);
327 dissector_add_uint("q931.ie", (0x00 << 8) | Q932_IE_FACILITY, q932_ie_handle);
328 /* Notification indicator */
329 dissector_add_uint("q931.ie", (0x00 << 8) | Q932_IE_NOTIFICATION_INDICATOR, q932_ie_handle);
331 q932_ros_handle = find_dissector("q932.ros");
334 /*---------------------------------------------------------------------------*/