2 * Routines for Signalling Connection Control Part (SCCP) Management dissection
4 * It is hopefully compliant to:
7 * YDN 038-1997 (Chinese ITU variant)
9 * Copyright 2002, Jeff Morriss <jeff.morriss[AT]ulticom.com>
11 * $Id: packet-sccpmg.c,v 1.8 2003/09/06 00:04:21 guy Exp $
13 * Ethereal - Network traffic analyzer
14 * By Gerald Combs <gerald@ethereal.com>
15 * Copyright 1998 Gerald Combs
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License
19 * as published by the Free Software Foundation; either version 2
20 * of the License, or (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
42 #ifdef NEED_SNPRINTF_H
46 #include <epan/packet.h>
47 #include "packet-mtp3.h"
51 #define SCCPMG_MESSAGE_TYPE_SSA 0x01
52 #define SCCPMG_MESSAGE_TYPE_SSP 0x02
53 #define SCCPMG_MESSAGE_TYPE_SST 0x03
54 #define SCCPMG_MESSAGE_TYPE_SOR 0x04
55 #define SCCPMG_MESSAGE_TYPE_SOG 0x05
57 #define SCCPMG_MESSAGE_TYPE_SSC 0x06
58 /* Below are ANSI only */
59 #define SCCPMG_MESSAGE_TYPE_SBR 0xfd
60 #define SCCPMG_MESSAGE_TYPE_SNR 0xfe
61 #define SCCPMG_MESSAGE_TYPE_SRT 0xff
63 /* Same as below but with names typed out */
64 static const value_string sccpmg_message_type_values[] = {
65 { SCCPMG_MESSAGE_TYPE_SSA, "SubSystem Allowed" },
66 { SCCPMG_MESSAGE_TYPE_SSP, "SubSystem Prohibited" },
67 { SCCPMG_MESSAGE_TYPE_SST, "Subsystem Status Test" },
68 { SCCPMG_MESSAGE_TYPE_SOR, "Subsystem Out of service Request" },
69 { SCCPMG_MESSAGE_TYPE_SOG, "Subsystem Out of service Grant" },
70 { SCCPMG_MESSAGE_TYPE_SSC, "SubSystem Congested (ITU)" },
71 { SCCPMG_MESSAGE_TYPE_SBR, "Subsystem Backup Routing (ANSI)" },
72 { SCCPMG_MESSAGE_TYPE_SNR, "Subsystem Normal Routing (ANSI)" },
73 { SCCPMG_MESSAGE_TYPE_SRT, "Subsystem Routing status Test (ANSI)" },
76 /* Same as above but in acronym for (for the Info column) */
77 static const value_string sccpmg_message_type_acro_values[] = {
78 { SCCPMG_MESSAGE_TYPE_SSA, "SSA" },
79 { SCCPMG_MESSAGE_TYPE_SSP, "SSP" },
80 { SCCPMG_MESSAGE_TYPE_SST, "SST" },
81 { SCCPMG_MESSAGE_TYPE_SOR, "SOR" },
82 { SCCPMG_MESSAGE_TYPE_SOG, "SOG" },
83 { SCCPMG_MESSAGE_TYPE_SSC, "SSC" },
84 { SCCPMG_MESSAGE_TYPE_SBR, "SBR" },
85 { SCCPMG_MESSAGE_TYPE_SNR, "SNR" },
86 { SCCPMG_MESSAGE_TYPE_SRT, "SRT" },
90 #define SCCPMG_MESSAGE_TYPE_OFFSET 0
91 #define SCCPMG_MESSAGE_TYPE_LENGTH 1
93 #define SCCPMG_AFFECTED_SSN_OFFSET SCCPMG_MESSAGE_TYPE_LENGTH
94 #define SCCPMG_AFFECTED_SSN_LENGTH 1
96 #define SCCPMG_AFFECTED_PC_OFFSET (SCCPMG_AFFECTED_SSN_OFFSET + SCCPMG_AFFECTED_SSN_LENGTH)
97 #define ITU_SCCPMG_AFFECTED_PC_LENGTH 2
98 #define ANSI_SCCPMG_AFFECTED_PC_LENGTH 3
100 #define ITU_SCCPMG_SMI_OFFSET (SCCPMG_AFFECTED_PC_OFFSET + ITU_SCCPMG_AFFECTED_PC_LENGTH)
101 #define ANSI_SCCPMG_SMI_OFFSET (SCCPMG_AFFECTED_PC_OFFSET + ANSI_SCCPMG_AFFECTED_PC_LENGTH)
102 #define SCCPMG_SMI_LENGTH 1
103 #define SCCPMG_SMI_MASK 0x3
105 #define ITU_SCCPMG_CONGESTION_OFFSET (ITU_SCCPMG_SMI_OFFSET + SCCPMG_SMI_LENGTH)
106 #define ITU_SCCPMG_CONGESTION_LENGTH 1
107 #define ITU_SCCPMG_CONGESTION_MASK 0x0f
108 #define CHINESE_ITU_SCCPMG_CONGESTION_OFFSET (ANSI_SCCPMG_SMI_OFFSET + SCCPMG_SMI_LENGTH)
110 #define SCCPMG_SSN_LENGTH 1
112 /* Initialize the protocol and registered fields */
113 static int proto_sccpmg = -1;
114 static int hf_sccpmg_message_type = -1;
115 static int hf_sccpmg_affected_ssn = -1;
116 static int hf_sccpmg_affected_pc = -1;
117 static int hf_sccpmg_affected_ansi_pc = -1;
118 static int hf_sccpmg_affected_chinese_pc = -1;
119 static int hf_sccpmg_affected_pc_member = -1;
120 static int hf_sccpmg_affected_pc_cluster = -1;
121 static int hf_sccpmg_affected_pc_network = -1;
122 static int hf_sccpmg_smi = -1;
123 static int hf_sccpmg_congestion_level = -1;
125 /* Initialize the subtree pointers */
126 static gint ett_sccpmg = -1;
127 static gint ett_sccpmg_affected_pc = -1;
130 dissect_sccpmg_unknown_message(tvbuff_t *message_tvb, proto_tree *sccpmg_tree)
132 guint32 message_length;
134 message_length = tvb_length(message_tvb);
136 proto_tree_add_text(sccpmg_tree, message_tvb, 0, message_length,
137 "Unknown message (%u byte%s)", message_length,
138 plurality(message_length, "", "s"));
142 dissect_sccpmg_affected_ssn(tvbuff_t *tvb, proto_tree *sccpmg_tree)
144 proto_tree_add_item(sccpmg_tree, hf_sccpmg_affected_ssn, tvb,
145 SCCPMG_AFFECTED_SSN_OFFSET, SCCPMG_SSN_LENGTH,
150 dissect_sccpmg_affected_pc(tvbuff_t *tvb, proto_tree *sccpmg_tree)
152 proto_item *pc_item = 0;
153 proto_tree *pc_tree = 0;
155 guint8 offset = SCCPMG_AFFECTED_PC_OFFSET;
156 char pc[ANSI_PC_STRING_LENGTH];
158 if (mtp3_standard == ITU_STANDARD) {
159 proto_tree_add_item(sccpmg_tree, hf_sccpmg_affected_pc, tvb,
160 offset, ITU_PC_LENGTH, TRUE);
161 } else /* ANSI_STANDARD and CHINESE_ITU_STANDARD */ {
164 if (mtp3_standard == ANSI_STANDARD)
166 hf_affected_pc = &hf_sccpmg_affected_ansi_pc;
167 } else /* CHINESE_ITU_STANDARD */ {
168 hf_affected_pc = &hf_sccpmg_affected_chinese_pc;
171 /* create the DPC tree; modified from that in packet-sccp.c */
172 dpc = tvb_get_ntoh24(tvb, offset);
173 snprintf(pc, sizeof(pc), "%d-%d-%d",
174 (dpc & ANSI_NETWORK_MASK),
175 ((dpc & ANSI_CLUSTER_MASK) >> 8),
176 ((dpc & ANSI_MEMBER_MASK) >> 16));
178 pc_item = proto_tree_add_string_format(sccpmg_tree,
184 pc_tree = proto_item_add_subtree(pc_item,
185 ett_sccpmg_affected_pc);
187 proto_tree_add_uint(pc_tree, hf_sccpmg_affected_pc_member, tvb,
188 offset, ANSI_NCM_LENGTH, dpc);
189 offset += ANSI_NCM_LENGTH;
190 proto_tree_add_uint(pc_tree, hf_sccpmg_affected_pc_cluster, tvb,
191 offset, ANSI_NCM_LENGTH, dpc);
192 offset += ANSI_NCM_LENGTH;
193 proto_tree_add_uint(pc_tree, hf_sccpmg_affected_pc_network,
194 tvb, offset, ANSI_NCM_LENGTH, dpc);
199 dissect_sccpmg_smi(tvbuff_t *tvb, proto_tree *sccpmg_tree)
203 if (mtp3_standard == ITU_STANDARD)
204 offset = ITU_SCCPMG_SMI_OFFSET;
205 else /* ANSI_STANDARD and CHINESE_ITU_STANDARD */
206 offset = ANSI_SCCPMG_SMI_OFFSET;
208 proto_tree_add_item(sccpmg_tree, hf_sccpmg_smi, tvb, offset,
209 SCCPMG_SMI_LENGTH, FALSE);
213 dissect_sccpmg_congestion_level(tvbuff_t *tvb, proto_tree *sccpmg_tree)
217 if (mtp3_standard == CHINESE_ITU_STANDARD)
218 offset = CHINESE_ITU_SCCPMG_CONGESTION_OFFSET;
219 else /* ITU_STANDARD */
220 offset = ITU_SCCPMG_CONGESTION_OFFSET;
222 proto_tree_add_item(sccpmg_tree, hf_sccpmg_congestion_level, tvb,
223 offset, ITU_SCCPMG_CONGESTION_LENGTH, FALSE);
227 dissect_sccpmg_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *sccpmg_tree)
232 /* Extract the message type; all other processing is based on this */
233 message_type = tvb_get_guint8(tvb, SCCPMG_MESSAGE_TYPE_OFFSET);
234 offset = SCCPMG_MESSAGE_TYPE_LENGTH;
236 if (check_col(pinfo->cinfo, COL_INFO))
237 col_add_fstr(pinfo->cinfo, COL_INFO, "%s ", val_to_str(message_type, sccpmg_message_type_acro_values, "Unknown"));
240 /* add the message type to the protocol tree */
241 proto_tree_add_uint(sccpmg_tree, hf_sccpmg_message_type, tvb,
242 SCCPMG_MESSAGE_TYPE_OFFSET,
243 SCCPMG_MESSAGE_TYPE_LENGTH, message_type);
246 switch(message_type) {
247 case SCCPMG_MESSAGE_TYPE_SBR:
248 case SCCPMG_MESSAGE_TYPE_SNR:
249 case SCCPMG_MESSAGE_TYPE_SRT:
250 if (mtp3_standard != ANSI_STANDARD)
252 dissect_sccpmg_unknown_message(tvb, sccpmg_tree);
255 /* else fallthrough */
256 case SCCPMG_MESSAGE_TYPE_SSA:
257 case SCCPMG_MESSAGE_TYPE_SSP:
258 case SCCPMG_MESSAGE_TYPE_SST:
259 case SCCPMG_MESSAGE_TYPE_SOR:
260 case SCCPMG_MESSAGE_TYPE_SOG:
261 dissect_sccpmg_affected_ssn(tvb, sccpmg_tree);
262 dissect_sccpmg_affected_pc(tvb, sccpmg_tree);
263 dissect_sccpmg_smi(tvb, sccpmg_tree);
266 case SCCPMG_MESSAGE_TYPE_SSC:
267 if (mtp3_standard != ANSI_STANDARD)
269 dissect_sccpmg_affected_ssn(tvb, sccpmg_tree);
270 dissect_sccpmg_affected_pc(tvb, sccpmg_tree);
271 dissect_sccpmg_smi(tvb, sccpmg_tree);
272 dissect_sccpmg_congestion_level(tvb, sccpmg_tree);
274 /* else fallthrough */
277 dissect_sccpmg_unknown_message(tvb, sccpmg_tree);
282 dissect_sccpmg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
284 proto_item *sccpmg_item;
285 proto_tree *sccpmg_tree = NULL;
287 /* Make entry in the Protocol column on summary display */
288 if (check_col(pinfo->cinfo, COL_PROTOCOL))
289 switch(mtp3_standard) {
291 col_set_str(pinfo->cinfo, COL_PROTOCOL, "SCCPMG (Int. ITU)");
294 col_set_str(pinfo->cinfo, COL_PROTOCOL, "SCCPMG (ANSI)");
296 case CHINESE_ITU_STANDARD:
297 col_set_str(pinfo->cinfo, COL_PROTOCOL, "SCCPMG (Chin. ITU)");
301 /* In the interest of speed, if "tree" is NULL, don't do any work not
302 necessary to generate protocol tree items. */
304 /* create the sccpmg protocol tree */
305 sccpmg_item = proto_tree_add_item(tree, proto_sccpmg, tvb, 0,
307 sccpmg_tree = proto_item_add_subtree(sccpmg_item, ett_sccpmg);
310 /* dissect the message */
311 dissect_sccpmg_message(tvb, pinfo, sccpmg_tree);
314 /* Register the protocol with Ethereal */
316 proto_register_sccpmg(void)
318 /* Setup list of header fields */
319 static hf_register_info hf[] = {
320 { &hf_sccpmg_message_type,
321 { "Message Type", "sccpmg.message_type",
322 FT_UINT8, BASE_HEX, VALS(sccpmg_message_type_values), 0x0,
324 { &hf_sccpmg_affected_ssn,
325 { "Affected SubSystem Number", "sccpmg.ssn",
326 FT_UINT8, BASE_DEC, NULL, 0x0,
328 { &hf_sccpmg_affected_pc,
329 { "Affected Point Code", "sccpmg.pc",
330 FT_UINT16, BASE_DEC, NULL, ITU_PC_MASK,
332 { &hf_sccpmg_affected_ansi_pc,
333 { "Affected Point Code", "sccpmg.ansi_pc",
334 FT_STRING, BASE_NONE, NULL, 0x0,
336 { &hf_sccpmg_affected_chinese_pc,
337 { "Affected Point Code", "sccpmg.chinese_pc",
338 FT_STRING, BASE_NONE, NULL, 0x0,
340 { &hf_sccpmg_affected_pc_network,
341 { "Affected PC Network", "sccpmg.network",
342 FT_UINT24, BASE_DEC, NULL, ANSI_NETWORK_MASK,
344 { &hf_sccpmg_affected_pc_cluster,
345 { "Affected PC Cluster", "sccpmg.cluster",
346 FT_UINT24, BASE_DEC, NULL, ANSI_CLUSTER_MASK,
348 { &hf_sccpmg_affected_pc_member,
349 { "Affected PC Member", "sccpmg.member",
350 FT_UINT24, BASE_DEC, NULL, ANSI_MEMBER_MASK,
353 { "Subsystem Multiplicity Indicator", "sccpmg.smi",
354 FT_UINT8, BASE_DEC, NULL, SCCPMG_SMI_MASK,
356 { &hf_sccpmg_congestion_level,
357 { "SCCP Congestionl Level (ITU)", "sccpmg.congestion",
358 FT_UINT8, BASE_DEC, NULL, ITU_SCCPMG_CONGESTION_MASK,
362 /* Setup protocol subtree array */
363 static gint *ett[] = {
365 &ett_sccpmg_affected_pc
368 /* Register the protocol name and description */
369 proto_sccpmg = proto_register_protocol("Signalling Connection Control Part Management",
372 /* Required function calls to register the header fields and subtrees
374 proto_register_field_array(proto_sccpmg, hf, array_length(hf));
375 proto_register_subtree_array(ett, array_length(ett));
379 proto_reg_handoff_sccpmg(void)
381 dissector_handle_t sccpmg_handle;
383 sccpmg_handle = create_dissector_handle(dissect_sccpmg, proto_sccpmg);
385 /* Register for SCCP SSN=1 messages */
386 dissector_add("sccp.ssn", SCCPMG_SSN, sccpmg_handle);