2 * Routines for Signalling Connection Control Part (SCCP) Management dissection
4 * It is hopefully compliant to:
7 * YDN 038-1997 (Chinese ITU variant)
8 * JT-Q714 and NTT-Q714 (Japan)
10 * Note that NTT Annex E (SCCP Management Procedure (Global Title Status
11 * Management)) is not implemented (yet)
13 * Copyright 2002, Jeff Morriss <jeff.morriss.ws [AT] gmail.com>
15 * Wireshark - Network traffic analyzer
16 * By Gerald Combs <gerald@wireshark.org>
17 * Copyright 1998 Gerald Combs
19 * This program is free software; you can redistribute it and/or
20 * modify it under the terms of the GNU General Public License
21 * as published by the Free Software Foundation; either version 2
22 * of the License, or (at your option) any later version.
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
38 #include <epan/packet.h>
39 #include "packet-mtp3.h"
43 #define SCCPMG_MESSAGE_TYPE_SSA 0x01
44 #define SCCPMG_MESSAGE_TYPE_SSP 0x02
45 #define SCCPMG_MESSAGE_TYPE_SST 0x03
46 #define SCCPMG_MESSAGE_TYPE_SOR 0x04
47 #define SCCPMG_MESSAGE_TYPE_SOG 0x05
49 #define SCCPMG_MESSAGE_TYPE_SSC 0x06
50 /* Below are ANSI only */
51 #define SCCPMG_MESSAGE_TYPE_SBR 0xfd
52 #define SCCPMG_MESSAGE_TYPE_SNR 0xfe
53 #define SCCPMG_MESSAGE_TYPE_SRT 0xff
55 void proto_register_sccpmg(void);
56 void proto_reg_handoff_sccpmg(void);
58 /* Same as below but with names typed out */
59 static const value_string sccpmg_message_type_values[] = {
60 { SCCPMG_MESSAGE_TYPE_SSA, "SubSystem Allowed" },
61 { SCCPMG_MESSAGE_TYPE_SSP, "SubSystem Prohibited" },
62 { SCCPMG_MESSAGE_TYPE_SST, "Subsystem Status Test" },
63 { SCCPMG_MESSAGE_TYPE_SOR, "Subsystem Out of service Request" },
64 { SCCPMG_MESSAGE_TYPE_SOG, "Subsystem Out of service Grant" },
65 { SCCPMG_MESSAGE_TYPE_SSC, "SubSystem Congested (ITU)" },
66 { SCCPMG_MESSAGE_TYPE_SBR, "Subsystem Backup Routing (ANSI)" },
67 { SCCPMG_MESSAGE_TYPE_SNR, "Subsystem Normal Routing (ANSI)" },
68 { SCCPMG_MESSAGE_TYPE_SRT, "Subsystem Routing status Test (ANSI)" },
71 /* Same as above but in acronym for (for the Info column) */
72 static const value_string sccpmg_message_type_acro_values[] = {
73 { SCCPMG_MESSAGE_TYPE_SSA, "SSA" },
74 { SCCPMG_MESSAGE_TYPE_SSP, "SSP" },
75 { SCCPMG_MESSAGE_TYPE_SST, "SST" },
76 { SCCPMG_MESSAGE_TYPE_SOR, "SOR" },
77 { SCCPMG_MESSAGE_TYPE_SOG, "SOG" },
78 { SCCPMG_MESSAGE_TYPE_SSC, "SSC" },
79 { SCCPMG_MESSAGE_TYPE_SBR, "SBR" },
80 { SCCPMG_MESSAGE_TYPE_SNR, "SNR" },
81 { SCCPMG_MESSAGE_TYPE_SRT, "SRT" },
85 #define SCCPMG_MESSAGE_TYPE_OFFSET 0
86 #define SCCPMG_MESSAGE_TYPE_LENGTH 1
88 #define SCCPMG_AFFECTED_SSN_OFFSET SCCPMG_MESSAGE_TYPE_LENGTH
89 #define SCCPMG_AFFECTED_SSN_LENGTH 1
91 #define SCCPMG_AFFECTED_PC_OFFSET (SCCPMG_AFFECTED_SSN_OFFSET + SCCPMG_AFFECTED_SSN_LENGTH)
92 #define ITU_SCCPMG_AFFECTED_PC_LENGTH 2
93 #define ANSI_SCCPMG_AFFECTED_PC_LENGTH 3
95 #define ITU_SCCPMG_SMI_OFFSET (SCCPMG_AFFECTED_PC_OFFSET + ITU_SCCPMG_AFFECTED_PC_LENGTH)
96 #define ANSI_SCCPMG_SMI_OFFSET (SCCPMG_AFFECTED_PC_OFFSET + ANSI_SCCPMG_AFFECTED_PC_LENGTH)
97 #define SCCPMG_SMI_LENGTH 1
98 #define SCCPMG_SMI_MASK 0x3
100 #define ITU_SCCPMG_CONGESTION_OFFSET (ITU_SCCPMG_SMI_OFFSET + SCCPMG_SMI_LENGTH)
101 #define ITU_SCCPMG_CONGESTION_LENGTH 1
102 #define ITU_SCCPMG_CONGESTION_MASK 0x0f
103 #define CHINESE_ITU_SCCPMG_CONGESTION_OFFSET (ANSI_SCCPMG_SMI_OFFSET + SCCPMG_SMI_LENGTH)
105 #define SCCPMG_SSN_LENGTH 1
107 /* Initialize the protocol and registered fields */
108 static int proto_sccpmg = -1;
109 static int hf_sccpmg_message_type = -1;
110 static int hf_sccpmg_affected_ssn = -1;
111 static int hf_sccpmg_affected_itu_pc = -1;
112 static int hf_sccpmg_affected_japan_pc = -1;
113 static int hf_sccpmg_affected_ansi_pc = -1;
114 static int hf_sccpmg_affected_chinese_pc = -1;
115 static int hf_sccpmg_affected_pc_member = -1;
116 static int hf_sccpmg_affected_pc_cluster = -1;
117 static int hf_sccpmg_affected_pc_network = -1;
118 static int hf_sccpmg_smi = -1;
119 static int hf_sccpmg_congestion_level = -1;
121 /* Initialize the subtree pointers */
122 static gint ett_sccpmg = -1;
123 static gint ett_sccpmg_affected_pc = -1;
126 dissect_sccpmg_unknown_message(tvbuff_t *message_tvb, proto_tree *sccpmg_tree)
128 guint32 message_length;
130 message_length = tvb_length(message_tvb);
132 proto_tree_add_text(sccpmg_tree, message_tvb, 0, message_length,
133 "Unknown message (%u byte%s)", message_length,
134 plurality(message_length, "", "s"));
138 dissect_sccpmg_affected_ssn(tvbuff_t *tvb, proto_tree *sccpmg_tree)
140 proto_tree_add_item(sccpmg_tree, hf_sccpmg_affected_ssn, tvb,
141 SCCPMG_AFFECTED_SSN_OFFSET, SCCPMG_SSN_LENGTH,
146 dissect_sccpmg_affected_pc(tvbuff_t *tvb, proto_tree *sccpmg_tree)
148 guint8 offset = SCCPMG_AFFECTED_PC_OFFSET;
150 if (mtp3_standard == ITU_STANDARD) {
151 proto_tree_add_item(sccpmg_tree, hf_sccpmg_affected_itu_pc, tvb,
152 offset, ITU_PC_LENGTH, ENC_LITTLE_ENDIAN);
153 } else if (mtp3_standard == JAPAN_STANDARD) {
154 proto_tree_add_item(sccpmg_tree, hf_sccpmg_affected_japan_pc,
155 tvb, offset, JAPAN_PC_LENGTH, ENC_LITTLE_ENDIAN);
156 } else /* ANSI_STANDARD and CHINESE_ITU_STANDARD */ {
159 if (mtp3_standard == ANSI_STANDARD)
161 hf_affected_pc = &hf_sccpmg_affected_ansi_pc;
162 } else /* CHINESE_ITU_STANDARD */ {
163 hf_affected_pc = &hf_sccpmg_affected_chinese_pc;
166 /* create and fill the PC tree */
167 dissect_mtp3_3byte_pc(tvb, offset, sccpmg_tree,
168 ett_sccpmg_affected_pc, *hf_affected_pc,
169 hf_sccpmg_affected_pc_network,
170 hf_sccpmg_affected_pc_cluster,
171 hf_sccpmg_affected_pc_member, 0, 0);
177 dissect_sccpmg_smi(tvbuff_t *tvb, proto_tree *sccpmg_tree)
181 if (mtp3_standard == ITU_STANDARD || mtp3_standard == JAPAN_STANDARD)
182 offset = ITU_SCCPMG_SMI_OFFSET;
183 else /* ANSI_STANDARD and CHINESE_ITU_STANDARD */
184 offset = ANSI_SCCPMG_SMI_OFFSET;
186 proto_tree_add_item(sccpmg_tree, hf_sccpmg_smi, tvb, offset,
187 SCCPMG_SMI_LENGTH, ENC_BIG_ENDIAN);
191 dissect_sccpmg_congestion_level(tvbuff_t *tvb, proto_tree *sccpmg_tree)
195 if (mtp3_standard == CHINESE_ITU_STANDARD)
196 offset = CHINESE_ITU_SCCPMG_CONGESTION_OFFSET;
197 else /* ITU_STANDARD or JAPAN_STANDARD */
198 offset = ITU_SCCPMG_CONGESTION_OFFSET;
200 proto_tree_add_item(sccpmg_tree, hf_sccpmg_congestion_level, tvb,
201 offset, ITU_SCCPMG_CONGESTION_LENGTH, ENC_BIG_ENDIAN);
205 dissect_sccpmg_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *sccpmg_tree)
209 /* Extract the message type; all other processing is based on this */
210 message_type = tvb_get_guint8(tvb, SCCPMG_MESSAGE_TYPE_OFFSET);
212 col_add_fstr(pinfo->cinfo, COL_INFO, "%s ", val_to_str_const(message_type, sccpmg_message_type_acro_values, "Unknown"));
215 /* add the message type to the protocol tree */
216 proto_tree_add_uint(sccpmg_tree, hf_sccpmg_message_type, tvb,
217 SCCPMG_MESSAGE_TYPE_OFFSET,
218 SCCPMG_MESSAGE_TYPE_LENGTH, message_type);
221 switch(message_type) {
222 case SCCPMG_MESSAGE_TYPE_SBR:
223 case SCCPMG_MESSAGE_TYPE_SNR:
224 case SCCPMG_MESSAGE_TYPE_SRT:
225 if (mtp3_standard != ANSI_STANDARD)
227 dissect_sccpmg_unknown_message(tvb, sccpmg_tree);
230 /* else fallthrough */
231 case SCCPMG_MESSAGE_TYPE_SSA:
232 case SCCPMG_MESSAGE_TYPE_SSP:
233 case SCCPMG_MESSAGE_TYPE_SST:
234 case SCCPMG_MESSAGE_TYPE_SOR:
235 case SCCPMG_MESSAGE_TYPE_SOG:
236 dissect_sccpmg_affected_ssn(tvb, sccpmg_tree);
237 dissect_sccpmg_affected_pc(tvb, sccpmg_tree);
238 dissect_sccpmg_smi(tvb, sccpmg_tree);
241 case SCCPMG_MESSAGE_TYPE_SSC:
242 if (mtp3_standard != ANSI_STANDARD)
244 dissect_sccpmg_affected_ssn(tvb, sccpmg_tree);
245 dissect_sccpmg_affected_pc(tvb, sccpmg_tree);
246 dissect_sccpmg_smi(tvb, sccpmg_tree);
247 dissect_sccpmg_congestion_level(tvb, sccpmg_tree);
249 /* else fallthrough */
252 dissect_sccpmg_unknown_message(tvb, sccpmg_tree);
257 dissect_sccpmg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
259 proto_item *sccpmg_item;
260 proto_tree *sccpmg_tree = NULL;
262 /* Make entry in the Protocol column on summary display */
263 switch(mtp3_standard) {
265 col_set_str(pinfo->cinfo, COL_PROTOCOL, "SCCPMG (Int. ITU)");
268 col_set_str(pinfo->cinfo, COL_PROTOCOL, "SCCPMG (ANSI)");
270 case CHINESE_ITU_STANDARD:
271 col_set_str(pinfo->cinfo, COL_PROTOCOL, "SCCPMG (Chin. ITU)");
275 /* In the interest of speed, if "tree" is NULL, don't do any work not
276 necessary to generate protocol tree items. */
278 /* create the sccpmg protocol tree */
279 sccpmg_item = proto_tree_add_item(tree, proto_sccpmg, tvb, 0,
281 sccpmg_tree = proto_item_add_subtree(sccpmg_item, ett_sccpmg);
284 /* dissect the message */
285 dissect_sccpmg_message(tvb, pinfo, sccpmg_tree);
288 /* Register the protocol with Wireshark */
290 proto_register_sccpmg(void)
292 /* Setup list of header fields */
293 static hf_register_info hf[] = {
294 { &hf_sccpmg_message_type,
295 { "Message Type", "sccpmg.message_type",
296 FT_UINT8, BASE_HEX, VALS(sccpmg_message_type_values), 0x0,
298 { &hf_sccpmg_affected_ssn,
299 { "Affected SubSystem Number", "sccpmg.ssn",
300 FT_UINT8, BASE_DEC, NULL, 0x0,
302 { &hf_sccpmg_affected_itu_pc,
303 { "Affected Point Code", "sccpmg.pc",
304 FT_UINT16, BASE_DEC, NULL, ITU_PC_MASK,
306 { &hf_sccpmg_affected_japan_pc,
307 { "Affected Point Code", "sccpmg.pc",
308 FT_UINT16, BASE_DEC, NULL, 0x0,
310 { &hf_sccpmg_affected_ansi_pc,
311 { "Affected Point Code", "sccpmg.ansi_pc",
312 FT_STRING, BASE_NONE, NULL, 0x0,
314 { &hf_sccpmg_affected_chinese_pc,
315 { "Affected Point Code", "sccpmg.chinese_pc",
316 FT_STRING, BASE_NONE, NULL, 0x0,
318 { &hf_sccpmg_affected_pc_network,
319 { "Affected PC Network", "sccpmg.network",
320 FT_UINT24, BASE_DEC, NULL, ANSI_NETWORK_MASK,
322 { &hf_sccpmg_affected_pc_cluster,
323 { "Affected PC Cluster", "sccpmg.cluster",
324 FT_UINT24, BASE_DEC, NULL, ANSI_CLUSTER_MASK,
326 { &hf_sccpmg_affected_pc_member,
327 { "Affected PC Member", "sccpmg.member",
328 FT_UINT24, BASE_DEC, NULL, ANSI_MEMBER_MASK,
331 { "Subsystem Multiplicity Indicator", "sccpmg.smi",
332 FT_UINT8, BASE_DEC, NULL, SCCPMG_SMI_MASK,
334 { &hf_sccpmg_congestion_level,
335 { "SCCP Congestion Level (ITU)", "sccpmg.congestion",
336 FT_UINT8, BASE_DEC, NULL, ITU_SCCPMG_CONGESTION_MASK,
340 /* Setup protocol subtree array */
341 static gint *ett[] = {
343 &ett_sccpmg_affected_pc
346 /* Register the protocol name and description */
347 proto_sccpmg = proto_register_protocol("Signalling Connection Control Part Management",
350 /* Required function calls to register the header fields and subtrees
352 proto_register_field_array(proto_sccpmg, hf, array_length(hf));
353 proto_register_subtree_array(ett, array_length(ett));
357 proto_reg_handoff_sccpmg(void)
359 dissector_handle_t sccpmg_handle;
361 sccpmg_handle = create_dissector_handle(dissect_sccpmg, proto_sccpmg);
363 /* Register for SCCP SSN=1 messages */
364 dissector_add_uint("sccp.ssn", SCCPMG_SSN, sccpmg_handle);