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 * SPDX-License-Identifier: GPL-2.0-or-later
24 #include <epan/packet.h>
25 #include <epan/expert.h>
26 #include "packet-mtp3.h"
30 #define SCCPMG_MESSAGE_TYPE_SSA 0x01
31 #define SCCPMG_MESSAGE_TYPE_SSP 0x02
32 #define SCCPMG_MESSAGE_TYPE_SST 0x03
33 #define SCCPMG_MESSAGE_TYPE_SOR 0x04
34 #define SCCPMG_MESSAGE_TYPE_SOG 0x05
36 #define SCCPMG_MESSAGE_TYPE_SSC 0x06
37 /* Below are ANSI only */
38 #define SCCPMG_MESSAGE_TYPE_SBR 0xfd
39 #define SCCPMG_MESSAGE_TYPE_SNR 0xfe
40 #define SCCPMG_MESSAGE_TYPE_SRT 0xff
42 void proto_register_sccpmg(void);
43 void proto_reg_handoff_sccpmg(void);
45 static dissector_handle_t sccpmg_handle
;
47 /* Same as below but with names typed out */
48 static const value_string sccpmg_message_type_values
[] = {
49 { SCCPMG_MESSAGE_TYPE_SSA
, "SubSystem Allowed" },
50 { SCCPMG_MESSAGE_TYPE_SSP
, "SubSystem Prohibited" },
51 { SCCPMG_MESSAGE_TYPE_SST
, "Subsystem Status Test" },
52 { SCCPMG_MESSAGE_TYPE_SOR
, "Subsystem Out of service Request" },
53 { SCCPMG_MESSAGE_TYPE_SOG
, "Subsystem Out of service Grant" },
54 { SCCPMG_MESSAGE_TYPE_SSC
, "SubSystem Congested (ITU)" },
55 { SCCPMG_MESSAGE_TYPE_SBR
, "Subsystem Backup Routing (ANSI)" },
56 { SCCPMG_MESSAGE_TYPE_SNR
, "Subsystem Normal Routing (ANSI)" },
57 { SCCPMG_MESSAGE_TYPE_SRT
, "Subsystem Routing status Test (ANSI)" },
60 /* Same as above but in acronym for (for the Info column) */
61 static const value_string sccpmg_message_type_acro_values
[] = {
62 { SCCPMG_MESSAGE_TYPE_SSA
, "SSA" },
63 { SCCPMG_MESSAGE_TYPE_SSP
, "SSP" },
64 { SCCPMG_MESSAGE_TYPE_SST
, "SST" },
65 { SCCPMG_MESSAGE_TYPE_SOR
, "SOR" },
66 { SCCPMG_MESSAGE_TYPE_SOG
, "SOG" },
67 { SCCPMG_MESSAGE_TYPE_SSC
, "SSC" },
68 { SCCPMG_MESSAGE_TYPE_SBR
, "SBR" },
69 { SCCPMG_MESSAGE_TYPE_SNR
, "SNR" },
70 { SCCPMG_MESSAGE_TYPE_SRT
, "SRT" },
74 #define SCCPMG_MESSAGE_TYPE_OFFSET 0
75 #define SCCPMG_MESSAGE_TYPE_LENGTH 1
77 #define SCCPMG_AFFECTED_SSN_OFFSET SCCPMG_MESSAGE_TYPE_LENGTH
78 #define SCCPMG_AFFECTED_SSN_LENGTH 1
80 #define SCCPMG_AFFECTED_PC_OFFSET (SCCPMG_AFFECTED_SSN_OFFSET + SCCPMG_AFFECTED_SSN_LENGTH)
81 #define ITU_SCCPMG_AFFECTED_PC_LENGTH 2
82 #define ANSI_SCCPMG_AFFECTED_PC_LENGTH 3
84 #define ITU_SCCPMG_SMI_OFFSET (SCCPMG_AFFECTED_PC_OFFSET + ITU_SCCPMG_AFFECTED_PC_LENGTH)
85 #define ANSI_SCCPMG_SMI_OFFSET (SCCPMG_AFFECTED_PC_OFFSET + ANSI_SCCPMG_AFFECTED_PC_LENGTH)
86 #define SCCPMG_SMI_LENGTH 1
87 #define SCCPMG_SMI_MASK 0x3
89 #define ITU_SCCPMG_CONGESTION_OFFSET (ITU_SCCPMG_SMI_OFFSET + SCCPMG_SMI_LENGTH)
90 #define ITU_SCCPMG_CONGESTION_LENGTH 1
91 #define ITU_SCCPMG_CONGESTION_MASK 0x0f
92 #define CHINESE_ITU_SCCPMG_CONGESTION_OFFSET (ANSI_SCCPMG_SMI_OFFSET + SCCPMG_SMI_LENGTH)
94 #define SCCPMG_SSN_LENGTH 1
96 /* Initialize the protocol and registered fields */
97 static int proto_sccpmg
;
98 static int hf_sccpmg_message_type
;
99 static int hf_sccpmg_affected_ssn
;
100 static int hf_sccpmg_affected_itu_pc
;
101 static int hf_sccpmg_affected_japan_pc
;
102 static int hf_sccpmg_affected_ansi_pc
;
103 static int hf_sccpmg_affected_chinese_pc
;
104 static int hf_sccpmg_affected_pc_member
;
105 static int hf_sccpmg_affected_pc_cluster
;
106 static int hf_sccpmg_affected_pc_network
;
107 static int hf_sccpmg_smi
;
108 static int hf_sccpmg_congestion_level
;
110 /* Initialize the subtree pointers */
111 static int ett_sccpmg
;
112 static int ett_sccpmg_affected_pc
;
114 static expert_field ei_sccpmg_unknown_msg
;
117 dissect_sccpmg_affected_ssn(tvbuff_t
*tvb
, proto_tree
*sccpmg_tree
)
119 proto_tree_add_item(sccpmg_tree
, hf_sccpmg_affected_ssn
, tvb
,
120 SCCPMG_AFFECTED_SSN_OFFSET
, SCCPMG_SSN_LENGTH
,
125 dissect_sccpmg_affected_pc(tvbuff_t
*tvb
, proto_tree
*sccpmg_tree
)
127 int offset
= SCCPMG_AFFECTED_PC_OFFSET
;
129 if (mtp3_standard
== ITU_STANDARD
) {
130 proto_tree_add_item(sccpmg_tree
, hf_sccpmg_affected_itu_pc
, tvb
,
131 offset
, ITU_PC_LENGTH
, ENC_LITTLE_ENDIAN
);
132 } else if (mtp3_standard
== JAPAN_STANDARD
) {
133 proto_tree_add_item(sccpmg_tree
, hf_sccpmg_affected_japan_pc
,
134 tvb
, offset
, JAPAN_PC_LENGTH
, ENC_LITTLE_ENDIAN
);
135 } else /* ANSI_STANDARD and CHINESE_ITU_STANDARD */ {
138 if (mtp3_standard
== ANSI_STANDARD
)
140 hf_affected_pc
= &hf_sccpmg_affected_ansi_pc
;
141 } else /* CHINESE_ITU_STANDARD */ {
142 hf_affected_pc
= &hf_sccpmg_affected_chinese_pc
;
145 /* create and fill the PC tree */
146 dissect_mtp3_3byte_pc(tvb
, offset
, sccpmg_tree
,
147 ett_sccpmg_affected_pc
, *hf_affected_pc
,
148 hf_sccpmg_affected_pc_network
,
149 hf_sccpmg_affected_pc_cluster
,
150 hf_sccpmg_affected_pc_member
, 0, 0);
156 dissect_sccpmg_smi(tvbuff_t
*tvb
, proto_tree
*sccpmg_tree
)
160 if (mtp3_standard
== ITU_STANDARD
|| mtp3_standard
== JAPAN_STANDARD
)
161 offset
= ITU_SCCPMG_SMI_OFFSET
;
162 else /* ANSI_STANDARD and CHINESE_ITU_STANDARD */
163 offset
= ANSI_SCCPMG_SMI_OFFSET
;
165 proto_tree_add_item(sccpmg_tree
, hf_sccpmg_smi
, tvb
, offset
,
166 SCCPMG_SMI_LENGTH
, ENC_BIG_ENDIAN
);
170 dissect_sccpmg_congestion_level(tvbuff_t
*tvb
, proto_tree
*sccpmg_tree
)
174 if (mtp3_standard
== CHINESE_ITU_STANDARD
)
175 offset
= CHINESE_ITU_SCCPMG_CONGESTION_OFFSET
;
176 else /* ITU_STANDARD or JAPAN_STANDARD */
177 offset
= ITU_SCCPMG_CONGESTION_OFFSET
;
179 proto_tree_add_item(sccpmg_tree
, hf_sccpmg_congestion_level
, tvb
,
180 offset
, ITU_SCCPMG_CONGESTION_LENGTH
, ENC_BIG_ENDIAN
);
184 dissect_sccpmg_message(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*sccpmg_tree
)
186 uint8_t message_type
;
188 /* Extract the message type; all other processing is based on this */
189 message_type
= tvb_get_uint8(tvb
, SCCPMG_MESSAGE_TYPE_OFFSET
);
191 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "%s ", val_to_str_const(message_type
, sccpmg_message_type_acro_values
, "Unknown"));
194 /* add the message type to the protocol tree */
195 proto_tree_add_uint(sccpmg_tree
, hf_sccpmg_message_type
, tvb
,
196 SCCPMG_MESSAGE_TYPE_OFFSET
,
197 SCCPMG_MESSAGE_TYPE_LENGTH
, message_type
);
200 switch(message_type
) {
201 case SCCPMG_MESSAGE_TYPE_SBR
:
202 case SCCPMG_MESSAGE_TYPE_SNR
:
203 case SCCPMG_MESSAGE_TYPE_SRT
:
204 if (mtp3_standard
!= ANSI_STANDARD
)
206 proto_tree_add_expert(sccpmg_tree
, pinfo
, &ei_sccpmg_unknown_msg
, tvb
, 0, -1);
209 /* else fallthrough */
210 case SCCPMG_MESSAGE_TYPE_SSA
:
211 case SCCPMG_MESSAGE_TYPE_SSP
:
212 case SCCPMG_MESSAGE_TYPE_SST
:
213 case SCCPMG_MESSAGE_TYPE_SOR
:
214 case SCCPMG_MESSAGE_TYPE_SOG
:
215 dissect_sccpmg_affected_ssn(tvb
, sccpmg_tree
);
216 dissect_sccpmg_affected_pc(tvb
, sccpmg_tree
);
217 dissect_sccpmg_smi(tvb
, sccpmg_tree
);
220 case SCCPMG_MESSAGE_TYPE_SSC
:
221 if (mtp3_standard
!= ANSI_STANDARD
)
223 dissect_sccpmg_affected_ssn(tvb
, sccpmg_tree
);
224 dissect_sccpmg_affected_pc(tvb
, sccpmg_tree
);
225 dissect_sccpmg_smi(tvb
, sccpmg_tree
);
226 dissect_sccpmg_congestion_level(tvb
, sccpmg_tree
);
228 /* else fallthrough */
231 proto_tree_add_expert(sccpmg_tree
, pinfo
, &ei_sccpmg_unknown_msg
, tvb
, 0, -1);
236 dissect_sccpmg(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
238 proto_item
*sccpmg_item
;
239 proto_tree
*sccpmg_tree
= NULL
;
241 /* Make entry in the Protocol column on summary display */
242 switch(mtp3_standard
) {
244 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "SCCPMG (Int. ITU)");
247 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "SCCPMG (ANSI)");
249 case CHINESE_ITU_STANDARD
:
250 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "SCCPMG (Chin. ITU)");
254 /* In the interest of speed, if "tree" is NULL, don't do any work not
255 necessary to generate protocol tree items. */
257 /* create the sccpmg protocol tree */
258 sccpmg_item
= proto_tree_add_item(tree
, proto_sccpmg
, tvb
, 0,
260 sccpmg_tree
= proto_item_add_subtree(sccpmg_item
, ett_sccpmg
);
263 /* dissect the message */
264 dissect_sccpmg_message(tvb
, pinfo
, sccpmg_tree
);
265 return tvb_captured_length(tvb
);
268 /* Register the protocol with Wireshark */
270 proto_register_sccpmg(void)
272 /* Setup list of header fields */
273 static hf_register_info hf
[] = {
274 { &hf_sccpmg_message_type
,
275 { "Message Type", "sccpmg.message_type",
276 FT_UINT8
, BASE_HEX
, VALS(sccpmg_message_type_values
), 0x0,
278 { &hf_sccpmg_affected_ssn
,
279 { "Affected SubSystem Number", "sccpmg.ssn",
280 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
282 { &hf_sccpmg_affected_itu_pc
,
283 { "Affected Point Code", "sccpmg.pc",
284 FT_UINT16
, BASE_DEC
, NULL
, ITU_PC_MASK
,
286 { &hf_sccpmg_affected_japan_pc
,
287 { "Affected Point Code", "sccpmg.pc",
288 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
290 { &hf_sccpmg_affected_ansi_pc
,
291 { "Affected Point Code", "sccpmg.ansi_pc",
292 FT_STRING
, BASE_NONE
, NULL
, 0x0,
294 { &hf_sccpmg_affected_chinese_pc
,
295 { "Affected Point Code", "sccpmg.chinese_pc",
296 FT_STRING
, BASE_NONE
, NULL
, 0x0,
298 { &hf_sccpmg_affected_pc_network
,
299 { "Affected PC Network", "sccpmg.network",
300 FT_UINT24
, BASE_DEC
, NULL
, ANSI_NETWORK_MASK
,
302 { &hf_sccpmg_affected_pc_cluster
,
303 { "Affected PC Cluster", "sccpmg.cluster",
304 FT_UINT24
, BASE_DEC
, NULL
, ANSI_CLUSTER_MASK
,
306 { &hf_sccpmg_affected_pc_member
,
307 { "Affected PC Member", "sccpmg.member",
308 FT_UINT24
, BASE_DEC
, NULL
, ANSI_MEMBER_MASK
,
311 { "Subsystem Multiplicity Indicator", "sccpmg.smi",
312 FT_UINT8
, BASE_DEC
, NULL
, SCCPMG_SMI_MASK
,
314 { &hf_sccpmg_congestion_level
,
315 { "SCCP Congestion Level (ITU)", "sccpmg.congestion",
316 FT_UINT8
, BASE_DEC
, NULL
, ITU_SCCPMG_CONGESTION_MASK
,
320 /* Setup protocol subtree array */
321 static int *ett
[] = {
323 &ett_sccpmg_affected_pc
326 static ei_register_info ei
[] = {
327 { &ei_sccpmg_unknown_msg
, { "sccpmg.unknown_msg", PI_UNDECODED
, PI_WARN
, "Unknown message", EXPFILL
}},
330 expert_module_t
* expert_sccpmg
;
332 /* Register the protocol name and description */
333 proto_sccpmg
= proto_register_protocol("Signalling Connection Control Part Management",
336 /* Required function calls to register the header fields and subtrees
338 proto_register_field_array(proto_sccpmg
, hf
, array_length(hf
));
339 proto_register_subtree_array(ett
, array_length(ett
));
340 expert_sccpmg
= expert_register_protocol(proto_sccpmg
);
341 expert_register_field_array(expert_sccpmg
, ei
, array_length(ei
));
343 /* Register the dissector handle */
344 sccpmg_handle
= register_dissector("sccpmg", dissect_sccpmg
, proto_sccpmg
);
348 proto_reg_handoff_sccpmg(void)
350 /* Register for SCCP SSN=1 messages */
351 dissector_add_uint("sccp.ssn", SCCPMG_SSN
, sccpmg_handle
);
355 * Editor modelines - https://www.wireshark.org/tools/modelines.html
360 * indent-tabs-mode: t
363 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
364 * :indentSize=8:tabSize=8:noTabs=false: