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>
17 * Wireshark - Network traffic analyzer
18 * By Gerald Combs <gerald@wireshark.org>
19 * Copyright 1998 Gerald Combs
21 * This program is free software; you can redistribute it and/or
22 * modify it under the terms of the GNU General Public License
23 * as published by the Free Software Foundation; either version 2
24 * of the License, or (at your option) any later version.
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
31 * You should have received a copy of the GNU General Public License
32 * along with this program; if not, write to the Free Software
33 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
40 #include <epan/packet.h>
41 #include "packet-mtp3.h"
45 #define SCCPMG_MESSAGE_TYPE_SSA 0x01
46 #define SCCPMG_MESSAGE_TYPE_SSP 0x02
47 #define SCCPMG_MESSAGE_TYPE_SST 0x03
48 #define SCCPMG_MESSAGE_TYPE_SOR 0x04
49 #define SCCPMG_MESSAGE_TYPE_SOG 0x05
51 #define SCCPMG_MESSAGE_TYPE_SSC 0x06
52 /* Below are ANSI only */
53 #define SCCPMG_MESSAGE_TYPE_SBR 0xfd
54 #define SCCPMG_MESSAGE_TYPE_SNR 0xfe
55 #define SCCPMG_MESSAGE_TYPE_SRT 0xff
57 /* Same as below but with names typed out */
58 static const value_string sccpmg_message_type_values
[] = {
59 { SCCPMG_MESSAGE_TYPE_SSA
, "SubSystem Allowed" },
60 { SCCPMG_MESSAGE_TYPE_SSP
, "SubSystem Prohibited" },
61 { SCCPMG_MESSAGE_TYPE_SST
, "Subsystem Status Test" },
62 { SCCPMG_MESSAGE_TYPE_SOR
, "Subsystem Out of service Request" },
63 { SCCPMG_MESSAGE_TYPE_SOG
, "Subsystem Out of service Grant" },
64 { SCCPMG_MESSAGE_TYPE_SSC
, "SubSystem Congested (ITU)" },
65 { SCCPMG_MESSAGE_TYPE_SBR
, "Subsystem Backup Routing (ANSI)" },
66 { SCCPMG_MESSAGE_TYPE_SNR
, "Subsystem Normal Routing (ANSI)" },
67 { SCCPMG_MESSAGE_TYPE_SRT
, "Subsystem Routing status Test (ANSI)" },
70 /* Same as above but in acronym for (for the Info column) */
71 static const value_string sccpmg_message_type_acro_values
[] = {
72 { SCCPMG_MESSAGE_TYPE_SSA
, "SSA" },
73 { SCCPMG_MESSAGE_TYPE_SSP
, "SSP" },
74 { SCCPMG_MESSAGE_TYPE_SST
, "SST" },
75 { SCCPMG_MESSAGE_TYPE_SOR
, "SOR" },
76 { SCCPMG_MESSAGE_TYPE_SOG
, "SOG" },
77 { SCCPMG_MESSAGE_TYPE_SSC
, "SSC" },
78 { SCCPMG_MESSAGE_TYPE_SBR
, "SBR" },
79 { SCCPMG_MESSAGE_TYPE_SNR
, "SNR" },
80 { SCCPMG_MESSAGE_TYPE_SRT
, "SRT" },
84 #define SCCPMG_MESSAGE_TYPE_OFFSET 0
85 #define SCCPMG_MESSAGE_TYPE_LENGTH 1
87 #define SCCPMG_AFFECTED_SSN_OFFSET SCCPMG_MESSAGE_TYPE_LENGTH
88 #define SCCPMG_AFFECTED_SSN_LENGTH 1
90 #define SCCPMG_AFFECTED_PC_OFFSET (SCCPMG_AFFECTED_SSN_OFFSET + SCCPMG_AFFECTED_SSN_LENGTH)
91 #define ITU_SCCPMG_AFFECTED_PC_LENGTH 2
92 #define ANSI_SCCPMG_AFFECTED_PC_LENGTH 3
94 #define ITU_SCCPMG_SMI_OFFSET (SCCPMG_AFFECTED_PC_OFFSET + ITU_SCCPMG_AFFECTED_PC_LENGTH)
95 #define ANSI_SCCPMG_SMI_OFFSET (SCCPMG_AFFECTED_PC_OFFSET + ANSI_SCCPMG_AFFECTED_PC_LENGTH)
96 #define SCCPMG_SMI_LENGTH 1
97 #define SCCPMG_SMI_MASK 0x3
99 #define ITU_SCCPMG_CONGESTION_OFFSET (ITU_SCCPMG_SMI_OFFSET + SCCPMG_SMI_LENGTH)
100 #define ITU_SCCPMG_CONGESTION_LENGTH 1
101 #define ITU_SCCPMG_CONGESTION_MASK 0x0f
102 #define CHINESE_ITU_SCCPMG_CONGESTION_OFFSET (ANSI_SCCPMG_SMI_OFFSET + SCCPMG_SMI_LENGTH)
104 #define SCCPMG_SSN_LENGTH 1
106 /* Initialize the protocol and registered fields */
107 static int proto_sccpmg
= -1;
108 static int hf_sccpmg_message_type
= -1;
109 static int hf_sccpmg_affected_ssn
= -1;
110 static int hf_sccpmg_affected_itu_pc
= -1;
111 static int hf_sccpmg_affected_japan_pc
= -1;
112 static int hf_sccpmg_affected_ansi_pc
= -1;
113 static int hf_sccpmg_affected_chinese_pc
= -1;
114 static int hf_sccpmg_affected_pc_member
= -1;
115 static int hf_sccpmg_affected_pc_cluster
= -1;
116 static int hf_sccpmg_affected_pc_network
= -1;
117 static int hf_sccpmg_smi
= -1;
118 static int hf_sccpmg_congestion_level
= -1;
120 /* Initialize the subtree pointers */
121 static gint ett_sccpmg
= -1;
122 static gint ett_sccpmg_affected_pc
= -1;
125 dissect_sccpmg_unknown_message(tvbuff_t
*message_tvb
, proto_tree
*sccpmg_tree
)
127 guint32 message_length
;
129 message_length
= tvb_length(message_tvb
);
131 proto_tree_add_text(sccpmg_tree
, message_tvb
, 0, message_length
,
132 "Unknown message (%u byte%s)", message_length
,
133 plurality(message_length
, "", "s"));
137 dissect_sccpmg_affected_ssn(tvbuff_t
*tvb
, proto_tree
*sccpmg_tree
)
139 proto_tree_add_item(sccpmg_tree
, hf_sccpmg_affected_ssn
, tvb
,
140 SCCPMG_AFFECTED_SSN_OFFSET
, SCCPMG_SSN_LENGTH
,
145 dissect_sccpmg_affected_pc(tvbuff_t
*tvb
, proto_tree
*sccpmg_tree
)
147 guint8 offset
= SCCPMG_AFFECTED_PC_OFFSET
;
149 if (mtp3_standard
== ITU_STANDARD
) {
150 proto_tree_add_item(sccpmg_tree
, hf_sccpmg_affected_itu_pc
, tvb
,
151 offset
, ITU_PC_LENGTH
, ENC_LITTLE_ENDIAN
);
152 } else if (mtp3_standard
== JAPAN_STANDARD
) {
153 proto_tree_add_item(sccpmg_tree
, hf_sccpmg_affected_japan_pc
,
154 tvb
, offset
, JAPAN_PC_LENGTH
, ENC_LITTLE_ENDIAN
);
155 } else /* ANSI_STANDARD and CHINESE_ITU_STANDARD */ {
158 if (mtp3_standard
== ANSI_STANDARD
)
160 hf_affected_pc
= &hf_sccpmg_affected_ansi_pc
;
161 } else /* CHINESE_ITU_STANDARD */ {
162 hf_affected_pc
= &hf_sccpmg_affected_chinese_pc
;
165 /* create and fill the PC tree */
166 dissect_mtp3_3byte_pc(tvb
, offset
, sccpmg_tree
,
167 ett_sccpmg_affected_pc
, *hf_affected_pc
,
168 hf_sccpmg_affected_pc_network
,
169 hf_sccpmg_affected_pc_cluster
,
170 hf_sccpmg_affected_pc_member
, 0, 0);
176 dissect_sccpmg_smi(tvbuff_t
*tvb
, proto_tree
*sccpmg_tree
)
180 if (mtp3_standard
== ITU_STANDARD
|| mtp3_standard
== JAPAN_STANDARD
)
181 offset
= ITU_SCCPMG_SMI_OFFSET
;
182 else /* ANSI_STANDARD and CHINESE_ITU_STANDARD */
183 offset
= ANSI_SCCPMG_SMI_OFFSET
;
185 proto_tree_add_item(sccpmg_tree
, hf_sccpmg_smi
, tvb
, offset
,
186 SCCPMG_SMI_LENGTH
, ENC_BIG_ENDIAN
);
190 dissect_sccpmg_congestion_level(tvbuff_t
*tvb
, proto_tree
*sccpmg_tree
)
194 if (mtp3_standard
== CHINESE_ITU_STANDARD
)
195 offset
= CHINESE_ITU_SCCPMG_CONGESTION_OFFSET
;
196 else /* ITU_STANDARD or JAPAN_STANDARD */
197 offset
= ITU_SCCPMG_CONGESTION_OFFSET
;
199 proto_tree_add_item(sccpmg_tree
, hf_sccpmg_congestion_level
, tvb
,
200 offset
, ITU_SCCPMG_CONGESTION_LENGTH
, ENC_BIG_ENDIAN
);
204 dissect_sccpmg_message(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*sccpmg_tree
)
208 /* Extract the message type; all other processing is based on this */
209 message_type
= tvb_get_guint8(tvb
, SCCPMG_MESSAGE_TYPE_OFFSET
);
211 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "%s ", val_to_str_const(message_type
, sccpmg_message_type_acro_values
, "Unknown"));
214 /* add the message type to the protocol tree */
215 proto_tree_add_uint(sccpmg_tree
, hf_sccpmg_message_type
, tvb
,
216 SCCPMG_MESSAGE_TYPE_OFFSET
,
217 SCCPMG_MESSAGE_TYPE_LENGTH
, message_type
);
220 switch(message_type
) {
221 case SCCPMG_MESSAGE_TYPE_SBR
:
222 case SCCPMG_MESSAGE_TYPE_SNR
:
223 case SCCPMG_MESSAGE_TYPE_SRT
:
224 if (mtp3_standard
!= ANSI_STANDARD
)
226 dissect_sccpmg_unknown_message(tvb
, sccpmg_tree
);
229 /* else fallthrough */
230 case SCCPMG_MESSAGE_TYPE_SSA
:
231 case SCCPMG_MESSAGE_TYPE_SSP
:
232 case SCCPMG_MESSAGE_TYPE_SST
:
233 case SCCPMG_MESSAGE_TYPE_SOR
:
234 case SCCPMG_MESSAGE_TYPE_SOG
:
235 dissect_sccpmg_affected_ssn(tvb
, sccpmg_tree
);
236 dissect_sccpmg_affected_pc(tvb
, sccpmg_tree
);
237 dissect_sccpmg_smi(tvb
, sccpmg_tree
);
240 case SCCPMG_MESSAGE_TYPE_SSC
:
241 if (mtp3_standard
!= ANSI_STANDARD
)
243 dissect_sccpmg_affected_ssn(tvb
, sccpmg_tree
);
244 dissect_sccpmg_affected_pc(tvb
, sccpmg_tree
);
245 dissect_sccpmg_smi(tvb
, sccpmg_tree
);
246 dissect_sccpmg_congestion_level(tvb
, sccpmg_tree
);
248 /* else fallthrough */
251 dissect_sccpmg_unknown_message(tvb
, sccpmg_tree
);
256 dissect_sccpmg(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
258 proto_item
*sccpmg_item
;
259 proto_tree
*sccpmg_tree
= NULL
;
261 /* Make entry in the Protocol column on summary display */
262 switch(mtp3_standard
) {
264 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "SCCPMG (Int. ITU)");
267 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "SCCPMG (ANSI)");
269 case CHINESE_ITU_STANDARD
:
270 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "SCCPMG (Chin. ITU)");
274 /* In the interest of speed, if "tree" is NULL, don't do any work not
275 necessary to generate protocol tree items. */
277 /* create the sccpmg protocol tree */
278 sccpmg_item
= proto_tree_add_item(tree
, proto_sccpmg
, tvb
, 0,
280 sccpmg_tree
= proto_item_add_subtree(sccpmg_item
, ett_sccpmg
);
283 /* dissect the message */
284 dissect_sccpmg_message(tvb
, pinfo
, sccpmg_tree
);
287 /* Register the protocol with Wireshark */
289 proto_register_sccpmg(void)
291 /* Setup list of header fields */
292 static hf_register_info hf
[] = {
293 { &hf_sccpmg_message_type
,
294 { "Message Type", "sccpmg.message_type",
295 FT_UINT8
, BASE_HEX
, VALS(sccpmg_message_type_values
), 0x0,
297 { &hf_sccpmg_affected_ssn
,
298 { "Affected SubSystem Number", "sccpmg.ssn",
299 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
301 { &hf_sccpmg_affected_itu_pc
,
302 { "Affected Point Code", "sccpmg.pc",
303 FT_UINT16
, BASE_DEC
, NULL
, ITU_PC_MASK
,
305 { &hf_sccpmg_affected_japan_pc
,
306 { "Affected Point Code", "sccpmg.pc",
307 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
309 { &hf_sccpmg_affected_ansi_pc
,
310 { "Affected Point Code", "sccpmg.ansi_pc",
311 FT_STRING
, BASE_NONE
, NULL
, 0x0,
313 { &hf_sccpmg_affected_chinese_pc
,
314 { "Affected Point Code", "sccpmg.chinese_pc",
315 FT_STRING
, BASE_NONE
, NULL
, 0x0,
317 { &hf_sccpmg_affected_pc_network
,
318 { "Affected PC Network", "sccpmg.network",
319 FT_UINT24
, BASE_DEC
, NULL
, ANSI_NETWORK_MASK
,
321 { &hf_sccpmg_affected_pc_cluster
,
322 { "Affected PC Cluster", "sccpmg.cluster",
323 FT_UINT24
, BASE_DEC
, NULL
, ANSI_CLUSTER_MASK
,
325 { &hf_sccpmg_affected_pc_member
,
326 { "Affected PC Member", "sccpmg.member",
327 FT_UINT24
, BASE_DEC
, NULL
, ANSI_MEMBER_MASK
,
330 { "Subsystem Multiplicity Indicator", "sccpmg.smi",
331 FT_UINT8
, BASE_DEC
, NULL
, SCCPMG_SMI_MASK
,
333 { &hf_sccpmg_congestion_level
,
334 { "SCCP Congestion Level (ITU)", "sccpmg.congestion",
335 FT_UINT8
, BASE_DEC
, NULL
, ITU_SCCPMG_CONGESTION_MASK
,
339 /* Setup protocol subtree array */
340 static gint
*ett
[] = {
342 &ett_sccpmg_affected_pc
345 /* Register the protocol name and description */
346 proto_sccpmg
= proto_register_protocol("Signalling Connection Control Part Management",
349 /* Required function calls to register the header fields and subtrees
351 proto_register_field_array(proto_sccpmg
, hf
, array_length(hf
));
352 proto_register_subtree_array(ett
, array_length(ett
));
356 proto_reg_handoff_sccpmg(void)
358 dissector_handle_t sccpmg_handle
;
360 sccpmg_handle
= create_dissector_handle(dissect_sccpmg
, proto_sccpmg
);
362 /* Register for SCCP SSN=1 messages */
363 dissector_add_uint("sccp.ssn", SCCPMG_SSN
, sccpmg_handle
);