2 * Routines for Message Transfer Part Level 3 dissection
3 * Copyright 2001, Michael Tuexen <Michael.Tuexen@icn.siemens.de>
5 * $Id: packet-mtp3.c,v 1.3 2001/05/31 08:51:29 guy Exp $
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@ethereal.com>
9 * Copyright 1998 Gerald Combs
11 * Copied from README.developer
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
36 #ifdef HAVE_SYS_TYPES_H
37 # include <sys/types.h>
40 #ifdef HAVE_NETINET_IN_H
41 # include <netinet/in.h>
49 /* Initialize the protocol and registered fields */
50 static int proto_mtp3 = -1;
51 static module_t *mtp3_module;
53 static int hf_mtp3_service_indicator = -1;
54 static int hf_mtp3_network_indicator = -1;
55 static int hf_mtp3_spare = -1;
56 static int hf_mtp3_opc = -1;
57 static int hf_mtp3_dpc = -1;
58 static int hf_mtp3_sls = -1;
60 /* Initialize the subtree pointers */
61 static gint ett_mtp3 = -1;
62 static gint ett_mtp3_sio = -1;
63 static gint ett_mtp3_label = -1;
65 static dissector_table_t mtp3_sio_dissector_table;
67 #define ITU_STANDARD 1
68 #define ANSI_STANDARD 2
70 static gint mtp3_standard = ITU_STANDARD;
72 #define ITU_SIO_OFFSET 0
73 #define ITU_SIO_LENGTH 1
74 #define ITU_ROUTING_LABEL_OFFSET 1
75 #define ITU_ROUTING_LABEL_LENGTH 4
76 #define ITU_MTP_PAYLOAD_OFFSET 5
78 #define SERVICE_INDICATOR_MASK 0x0F
79 #define SPARE_MASK 0x30
80 #define NETWORK_INDICATOR_MASK 0xC0
81 #define DPC_MASK 0x00003FFF
82 #define OPC_MASK 0x0FFFC000
83 #define SLS_MASK 0xF0000000
85 static const value_string service_indicator_code_vals[] = {
86 { 0x0, "Signalling network management message" },
87 { 0x1, "Signalling network testing and maintenance message" },
92 { 0x6, "DUP (call and circuit related messages)" },
93 { 0x7, "DUP (facility registration and cancellation message)" },
94 { 0x8, "MTP testing user part" },
105 static const value_string network_indicator_vals[] = {
106 { 0x0, "International network" },
107 { 0x1, "Spare (for international use only)" },
108 { 0x2, "National network" },
109 { 0x3, "Reserved for national use" },
114 dissect_mtp3_sio(tvbuff_t *tvb, proto_tree *mtp3_tree)
117 proto_item *sio_item;
118 proto_tree *sio_tree;
120 sio_item = proto_tree_add_text(mtp3_tree, tvb, ITU_SIO_OFFSET, ITU_SIO_LENGTH, "Service information octet");
121 sio_tree = proto_item_add_subtree(sio_item, ett_mtp3_sio);
123 sio = tvb_get_guint8(tvb, ITU_SIO_OFFSET);
124 proto_tree_add_uint(sio_tree, hf_mtp3_network_indicator,
125 tvb, ITU_SIO_OFFSET, ITU_SIO_LENGTH,
127 proto_tree_add_uint(sio_tree, hf_mtp3_spare,
128 tvb, ITU_SIO_OFFSET, ITU_SIO_LENGTH,
130 proto_tree_add_uint(sio_tree, hf_mtp3_service_indicator,
131 tvb, ITU_SIO_OFFSET, ITU_SIO_LENGTH,
136 dissect_mtp3_routing_label(tvbuff_t *tvb, proto_tree *mtp3_tree)
139 proto_item *label_item;
140 proto_tree *label_tree;
142 label_item = proto_tree_add_text(mtp3_tree, tvb, ITU_ROUTING_LABEL_OFFSET, ITU_ROUTING_LABEL_LENGTH, "Routing label");
143 label_tree = proto_item_add_subtree(label_item, ett_mtp3_label);
145 label = tvb_get_letohl(tvb, ITU_ROUTING_LABEL_OFFSET);
146 proto_tree_add_uint(label_tree, hf_mtp3_dpc,
147 tvb, ITU_ROUTING_LABEL_OFFSET, ITU_ROUTING_LABEL_LENGTH,
149 proto_tree_add_uint(label_tree, hf_mtp3_opc,
150 tvb, ITU_ROUTING_LABEL_OFFSET, ITU_ROUTING_LABEL_LENGTH,
152 proto_tree_add_uint(label_tree, hf_mtp3_sls,
153 tvb, ITU_ROUTING_LABEL_OFFSET, ITU_ROUTING_LABEL_LENGTH,
158 dissect_mtp3_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
161 guint8 service_indicator;
162 tvbuff_t *payload_tvb;
164 sio = tvb_get_guint8(tvb, ITU_SIO_OFFSET);
165 service_indicator = sio & SERVICE_INDICATOR_MASK;
166 payload_tvb = tvb_new_subset(tvb, ITU_MTP_PAYLOAD_OFFSET, -1, -1);
167 if (!dissector_try_port(mtp3_sio_dissector_table, service_indicator, payload_tvb, pinfo, tree)) {
168 proto_tree_add_text(tree, payload_tvb, 0, tvb_length(payload_tvb),
169 "Payload (%u byte%s)",
170 tvb_length(payload_tvb), plurality(tvb_length(payload_tvb), "", "s"));
174 /* Code to actually dissect the packets */
176 dissect_mtp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
179 /* Set up structures needed to add the protocol subtree and manage it */
180 proto_item *mtp3_item;
181 proto_tree *mtp3_tree;
183 /* Make entries in Protocol column and Info column on summary display */
184 if (check_col(pinfo->fd, COL_PROTOCOL))
185 col_set_str(pinfo->fd, COL_PROTOCOL, "MTP3");
186 if (check_col(pinfo->fd, COL_INFO))
187 col_clear(pinfo->fd, COL_INFO);
189 /* In the interest of speed, if "tree" is NULL, don't do any work not
190 necessary to generate protocol tree items. */
194 /* create display subtree for the protocol */
195 mtp3_item = proto_tree_add_item(tree, proto_mtp3, tvb, 0, tvb_length(tvb), FALSE);
196 mtp3_tree = proto_item_add_subtree(mtp3_item, ett_mtp3);
198 /* dissect the packet */
199 dissect_mtp3_sio(tvb, mtp3_tree);
200 dissect_mtp3_routing_label(tvb, mtp3_tree);
201 dissect_mtp3_payload(tvb, pinfo, tree);
206 proto_register_mtp3(void)
209 /* Setup list of header fields See Section 1.6.1 for details*/
210 static hf_register_info hf[] = {
211 { &hf_mtp3_service_indicator,
212 { "Service indicator",
213 "mtp3.service_indicator",
214 FT_UINT8, BASE_HEX, VALS(service_indicator_code_vals), SERVICE_INDICATOR_MASK,
216 { &hf_mtp3_network_indicator,
217 { "Network indicator",
218 "mtp3.network_indicator",
219 FT_UINT8, BASE_HEX, VALS(network_indicator_vals), NETWORK_INDICATOR_MASK,
224 FT_UINT8, BASE_HEX, NULL, SPARE_MASK,
229 FT_UINT32, BASE_DEC, NULL, OPC_MASK,
234 FT_UINT32, BASE_DEC, NULL, DPC_MASK,
239 FT_UINT32, BASE_DEC, NULL, SLS_MASK,
243 /* Setup protocol subtree array */
244 static gint *ett[] = {
250 static enum_val_t mtp3_options[] = {
251 {"ITU", ITU_STANDARD},
252 /* {"ANSI", ANSI_STANDARD}, */
256 /* Register the protocol name and description */
257 proto_mtp3 = proto_register_protocol("Message Transfer Part Level 3",
260 /* Required function calls to register the header fields and subtrees used */
261 proto_register_field_array(proto_mtp3, hf, array_length(hf));
262 proto_register_subtree_array(ett, array_length(ett));
264 /* Register the dissector */
265 register_dissector("mtp3", dissect_mtp3, proto_mtp3);
267 mtp3_sio_dissector_table = register_dissector_table("mtp3.service_indicator");
269 mtp3_module = prefs_register_protocol(proto_mtp3, NULL);
271 prefs_register_enum_preference(mtp3_module,
276 mtp3_options, FALSE);