2 * Routines for Signalling Connection Control Part (SCCP) Management dissection
3 * It is hopefully compliant to:
7 * Copyright 2002, Jeff Morriss <jeff.morriss[AT]ulticom.com>
9 * $Id: packet-sccpmg.c,v 1.1 2002/09/20 09:22:46 sahlberg Exp $
11 * Ethereal - Network traffic analyzer
12 * By Gerald Combs <gerald@ethereal.com>
13 * Copyright 1998 Gerald Combs
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 #include "epan/packet.h"
35 #include "packet-mtp3.h"
39 #define SCCPMG_MESSAGE_TYPE_SSA 0x01
40 #define SCCPMG_MESSAGE_TYPE_SSP 0x02
41 #define SCCPMG_MESSAGE_TYPE_SST 0x03
42 #define SCCPMG_MESSAGE_TYPE_SOR 0x04
43 #define SCCPMG_MESSAGE_TYPE_SOG 0x05
45 #define SCCPMG_MESSAGE_TYPE_SSC 0x06
46 /* Below are ANSI only */
47 #define SCCPMG_MESSAGE_TYPE_SBR 0xfd
48 #define SCCPMG_MESSAGE_TYPE_SNR 0xfe
49 #define SCCPMG_MESSAGE_TYPE_SRT 0xff
51 /* Same as below but with names typed out */
52 static const value_string sccpmg_message_type_values[] = {
53 { SCCPMG_MESSAGE_TYPE_SSA, "SubSystem Allowed" },
54 { SCCPMG_MESSAGE_TYPE_SSP, "SubSystem Prohibited" },
55 { SCCPMG_MESSAGE_TYPE_SST, "Subsystem Status Test" },
56 { SCCPMG_MESSAGE_TYPE_SOR, "Subsystem Out of service Request" },
57 { SCCPMG_MESSAGE_TYPE_SOG, "Subsystem Out of service Grant" },
58 { SCCPMG_MESSAGE_TYPE_SSC, "SubSystem Congested (ITU)" },
59 { SCCPMG_MESSAGE_TYPE_SBR, "Subsystem Backup Routing (ANSI)" },
60 { SCCPMG_MESSAGE_TYPE_SNR, "Subsystem Normal Routing (ANSI)" },
61 { SCCPMG_MESSAGE_TYPE_SRT, "Subsystem Routing status Test (ANSI)" },
64 /* Same as above but in acronym for (for the Info column) */
65 static const value_string sccpmg_message_type_acro_values[] = {
66 { SCCPMG_MESSAGE_TYPE_SSA, "SSA" },
67 { SCCPMG_MESSAGE_TYPE_SSP, "SSP" },
68 { SCCPMG_MESSAGE_TYPE_SST, "SST" },
69 { SCCPMG_MESSAGE_TYPE_SOR, "SOR" },
70 { SCCPMG_MESSAGE_TYPE_SOG, "SOG" },
71 { SCCPMG_MESSAGE_TYPE_SSC, "SSC" },
72 { SCCPMG_MESSAGE_TYPE_SBR, "SBR" },
73 { SCCPMG_MESSAGE_TYPE_SNR, "SNR" },
74 { SCCPMG_MESSAGE_TYPE_SRT, "SRT" },
78 #define SCCPMG_MESSAGE_TYPE_OFFSET 0
79 #define SCCPMG_MESSAGE_TYPE_LENGTH 1
81 #define SCCPMG_AFFECTED_SSN_OFFSET SCCPMG_MESSAGE_TYPE_LENGTH
82 #define SCCPMG_AFFECTED_SSN_LENGTH 1
84 #define SCCPMG_AFFECTED_PC_OFFSET (SCCPMG_AFFECTED_SSN_OFFSET + SCCPMG_AFFECTED_SSN_LENGTH)
85 #define ITU_SCCPMG_AFFECTED_PC_LENGTH 2
86 #define ANSI_SCCPMG_AFFECTED_PC_LENGTH 3
88 #define ITU_SCCPMG_SMI_OFFSET (SCCPMG_AFFECTED_PC_OFFSET + ITU_SCCPMG_AFFECTED_PC_LENGTH)
89 #define ANSI_SCCPMG_SMI_OFFSET (SCCPMG_AFFECTED_PC_OFFSET + ANSI_SCCPMG_AFFECTED_PC_LENGTH)
90 #define SCCPMG_SMI_LENGTH 1
91 #define SCCPMG_SMI_MASK 0x3
93 #define ITU_SCCPMG_CONGESTION_OFFSET (ITU_SCCPMG_SMI_OFFSET + SCCPMG_SMI_LENGTH)
94 #define ITU_SCCPMG_CONGESTION_LENGTH 1
95 #define ITU_SCCPMG_CONGESTION_MASK 0x0f
97 #define SCCPMG_SSN_LENGTH 1
99 /* Initialize the protocol and registered fields */
100 static int proto_sccpmg = -1;
101 static int hf_sccpmg_message_type = -1;
102 static int hf_sccpmg_affected_ssn = -1;
103 static int hf_sccpmg_affected_pc = -1;
104 static int hf_sccpmg_affected_pc_member = -1;
105 static int hf_sccpmg_affected_pc_cluster = -1;
106 static int hf_sccpmg_affected_pc_network = -1;
107 static int hf_sccpmg_smi = -1;
108 static int hf_sccpmg_congestion_level = -1;
110 /* Initialize the subtree pointers */
111 static gint ett_sccpmg = -1;
112 static gint ett_sccpmg_affected_pc = -1;
115 dissect_sccpmg_unknown_message(tvbuff_t *message_tvb, proto_tree *sccpmg_tree)
117 guint32 message_length;
119 message_length = tvb_length(message_tvb);
121 proto_tree_add_text(sccpmg_tree, message_tvb, 0, message_length,
122 "Unknown message (%u byte%s)", message_length,
123 plurality(message_length, "", "s"));
127 dissect_sccpmg_affected_ssn(tvbuff_t *tvb, proto_tree *sccpmg_tree)
129 proto_tree_add_item(sccpmg_tree, hf_sccpmg_affected_ssn, tvb,
130 SCCPMG_AFFECTED_SSN_OFFSET, SCCPMG_SSN_LENGTH,
135 dissect_sccpmg_affected_pc(tvbuff_t *tvb, proto_tree *sccpmg_tree)
137 proto_item *pc_item = 0;
138 proto_tree *pc_tree = 0;
140 guint8 offset = SCCPMG_AFFECTED_PC_OFFSET;
142 if (mtp3_standard == ITU_STANDARD) {
143 proto_tree_add_item(sccpmg_tree, hf_sccpmg_affected_pc, tvb,
144 offset, ITU_PC_LENGTH, TRUE);
145 } else if (mtp3_standard == ANSI_STANDARD) {
146 /* create the DPC tree; modified from that in packet-sccp.c */
147 dpc = tvb_get_ntoh24(tvb, offset);
148 pc_item = proto_tree_add_text(sccpmg_tree, tvb, offset,
149 ANSI_PC_LENGTH, "PC (%d-%d-%d)",
150 (dpc & ANSI_NETWORK_MASK),
151 ((dpc & ANSI_CLUSTER_MASK) >> 8),
152 ((dpc & ANSI_MEMBER_MASK) >> 16));
154 pc_tree = proto_item_add_subtree(pc_item,
155 ett_sccpmg_affected_pc);
157 proto_tree_add_uint(pc_tree, hf_sccpmg_affected_pc_member, tvb,
158 offset, ANSI_NCM_LENGTH, dpc);
159 offset += ANSI_NCM_LENGTH;
160 proto_tree_add_uint(pc_tree, hf_sccpmg_affected_pc_cluster, tvb,
161 offset, ANSI_NCM_LENGTH, dpc);
162 offset += ANSI_NCM_LENGTH;
163 proto_tree_add_uint(pc_tree, hf_sccpmg_affected_pc_network,
164 tvb, offset, ANSI_NCM_LENGTH, dpc);
169 dissect_sccpmg_smi(tvbuff_t *tvb, proto_tree *sccpmg_tree)
173 if (mtp3_standard == ITU_STANDARD)
174 offset = ITU_SCCPMG_SMI_OFFSET;
176 offset = ANSI_SCCPMG_SMI_OFFSET;
178 proto_tree_add_item(sccpmg_tree, hf_sccpmg_smi, tvb, offset,
179 SCCPMG_SMI_LENGTH, FALSE);
183 dissect_sccpmg_congestion_level(tvbuff_t *tvb, proto_tree *sccpmg_tree)
185 proto_tree_add_item(sccpmg_tree, hf_sccpmg_congestion_level, tvb,
186 ITU_SCCPMG_CONGESTION_OFFSET,
187 ITU_SCCPMG_CONGESTION_LENGTH, FALSE);
191 dissect_sccpmg_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *sccpmg_tree)
196 /* Extract the message type; all other processing is based on this */
197 message_type = tvb_get_guint8(tvb, SCCPMG_MESSAGE_TYPE_OFFSET);
198 offset = SCCPMG_MESSAGE_TYPE_LENGTH;
200 if (check_col(pinfo->cinfo, COL_INFO)) {
201 col_append_fstr(pinfo->cinfo, COL_INFO, "(%s) ",
202 val_to_str(message_type,
203 sccpmg_message_type_acro_values,
208 /* add the message type to the protocol tree */
209 proto_tree_add_uint(sccpmg_tree, hf_sccpmg_message_type, tvb,
210 SCCPMG_MESSAGE_TYPE_OFFSET,
211 SCCPMG_MESSAGE_TYPE_LENGTH, message_type);
214 switch(message_type) {
215 case SCCPMG_MESSAGE_TYPE_SBR:
216 case SCCPMG_MESSAGE_TYPE_SNR:
217 case SCCPMG_MESSAGE_TYPE_SRT:
218 if (mtp3_standard == ITU_STANDARD)
220 dissect_sccpmg_unknown_message(tvb, sccpmg_tree);
223 /* else fallthrough */
224 case SCCPMG_MESSAGE_TYPE_SSA:
225 case SCCPMG_MESSAGE_TYPE_SSP:
226 case SCCPMG_MESSAGE_TYPE_SST:
227 case SCCPMG_MESSAGE_TYPE_SOR:
228 case SCCPMG_MESSAGE_TYPE_SOG:
229 dissect_sccpmg_affected_ssn(tvb, sccpmg_tree);
230 dissect_sccpmg_affected_pc(tvb, sccpmg_tree);
231 dissect_sccpmg_smi(tvb, sccpmg_tree);
234 case SCCPMG_MESSAGE_TYPE_SSC:
235 if (mtp3_standard == ITU_STANDARD)
237 dissect_sccpmg_affected_ssn(tvb, sccpmg_tree);
238 dissect_sccpmg_affected_pc(tvb, sccpmg_tree);
239 dissect_sccpmg_smi(tvb, sccpmg_tree);
240 dissect_sccpmg_congestion_level(tvb, sccpmg_tree);
242 /* else fallthrough */
245 dissect_sccpmg_unknown_message(tvb, sccpmg_tree);
250 dissect_sccpmg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
252 proto_item *sccpmg_item;
253 proto_tree *sccpmg_tree = NULL;
255 /* Make entry in the Protocol column on summary display */
256 if (check_col(pinfo->cinfo, COL_PROTOCOL))
257 col_set_str(pinfo->cinfo, COL_PROTOCOL, "SCCPMG");
259 /* In the interest of speed, if "tree" is NULL, don't do any work not
260 necessary to generate protocol tree items. */
262 /* create the sccpmg protocol tree */
263 sccpmg_item = proto_tree_add_item(tree, proto_sccpmg, tvb, 0,
265 sccpmg_tree = proto_item_add_subtree(sccpmg_item, ett_sccpmg);
268 /* dissect the message */
269 dissect_sccpmg_message(tvb, pinfo, sccpmg_tree);
272 /* Register the protocol with Ethereal */
274 proto_register_sccpmg(void)
276 /* Setup list of header fields */
277 static hf_register_info hf[] = {
278 { &hf_sccpmg_message_type,
279 { "Message Type", "sccpmg.message_type",
280 FT_UINT8, BASE_HEX, VALS(sccpmg_message_type_values), 0x0,
282 { &hf_sccpmg_affected_ssn,
283 { "Affected SubSystem Number", "sccpmg.ssn",
284 FT_UINT8, BASE_DEC, NULL, 0x0,
286 { &hf_sccpmg_affected_pc,
287 { "Affected Point Code", "sccpmg.pc",
288 FT_UINT16, BASE_DEC, NULL, ITU_PC_MASK,
290 { &hf_sccpmg_affected_pc_network,
291 { "Affected PC Network",
293 FT_UINT24, BASE_DEC, NULL, ANSI_NETWORK_MASK,
295 { &hf_sccpmg_affected_pc_cluster,
296 { "Affected PC Cluster",
298 FT_UINT24, BASE_DEC, NULL, ANSI_CLUSTER_MASK,
300 { &hf_sccpmg_affected_pc_member,
301 { "Affected PC Member",
303 FT_UINT24, BASE_DEC, NULL, ANSI_MEMBER_MASK,
306 { "Subsystem Multiplicity Indicator",
308 FT_UINT8, BASE_DEC, NULL, SCCPMG_SMI_MASK,
310 { &hf_sccpmg_congestion_level,
311 { "SCCP Congestionl Level (ITU)",
313 FT_UINT8, BASE_DEC, NULL, ITU_SCCPMG_CONGESTION_MASK,
317 /* Setup protocol subtree array */
318 static gint *ett[] = {
320 &ett_sccpmg_affected_pc
323 /* Register the protocol name and description */
324 proto_sccpmg = proto_register_protocol("Signalling Connection Control Part Management",
327 /* Required function calls to register the header fields and subtrees
329 proto_register_field_array(proto_sccpmg, hf, array_length(hf));
330 proto_register_subtree_array(ett, array_length(ett));
334 proto_reg_handoff_sccpmg(void)
336 dissector_handle_t sccpmg_handle;
338 sccpmg_handle = create_dissector_handle(dissect_sccpmg, proto_sccpmg);
340 /* Register for SCCP SSN=1 messages */
341 dissector_add("sccp.ssn", SCCPMG_SSN, sccpmg_handle);