e96ab706c5be76355ec69712243a1c5fd5582df8
[obnox/wireshark/wip.git] / packet-m3ua.c
1 /* packet-m3ua.c
2  * Routines for MTP3 User Adaptation Layer dissection
3  * It is hopefully (needs testing) compilant to
4  * http://www.ietf.org/internet-drafts/draft-ietf-sigtran-m3ua-05.txt (expired)
5  * http://www.ietf.org/internet-drafts/draft-ietf-sigtran-m3ua-06.txt (expired)
6  * http://www.ietf.org/rfc/rfc3332.txt
7  *
8  * Copyright 2000, 2001, 2002, 2003 Michael Tuexen <tuexen [AT] fh-muenster.de>
9  *
10  * $Id: packet-m3ua.c,v 1.36 2003/10/06 20:46:51 guy Exp $
11  *
12  * Ethereal - Network traffic analyzer
13  * By Gerald Combs <gerald@ethereal.com>
14  * Copyright 1998 Gerald Combs
15  *
16  * Copied from README.developer
17  *
18  * This program is free software; you can redistribute it and/or
19  * modify it under the terms of the GNU General Public License
20  * as published by the Free Software Foundation; either version 2
21  * of the License, or (at your option) any later version.
22  *
23  * This program is distributed in the hope that it will be useful,
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26  * GNU General Public License for more details.
27  *
28  * You should have received a copy of the GNU General Public License
29  * along with this program; if not, write to the Free Software
30  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31  */
32
33 #ifdef HAVE_CONFIG_H
34 # include "config.h"
35 #endif
36
37 #include <stdio.h>
38 #include <stdlib.h>
39
40
41 #include <string.h>
42 #include <glib.h>
43
44 #include <epan/packet.h>
45 #include "prefs.h"
46 #include "sctpppids.h"
47
48 #define SCTP_PORT_M3UA         2905
49 #define NETWORK_BYTE_ORDER     FALSE
50 #define ADD_PADDING(x) ((((x) + 3) >> 2) << 2)
51
52 #define VERSION_LENGTH         1
53 #define RESERVED_LENGTH        1
54 #define MESSAGE_CLASS_LENGTH   1
55 #define MESSAGE_TYPE_LENGTH    1
56 #define MESSAGE_LENGTH_LENGTH  4
57 #define COMMON_HEADER_LENGTH   (VERSION_LENGTH + RESERVED_LENGTH + MESSAGE_CLASS_LENGTH + \
58                                 MESSAGE_TYPE_LENGTH + MESSAGE_LENGTH_LENGTH)
59
60 #define VERSION_OFFSET         0
61 #define RESERVED_OFFSET        (VERSION_OFFSET + VERSION_LENGTH)
62 #define MESSAGE_CLASS_OFFSET   (RESERVED_OFFSET + RESERVED_LENGTH)
63 #define MESSAGE_TYPE_OFFSET    (MESSAGE_CLASS_OFFSET + MESSAGE_CLASS_LENGTH)
64 #define MESSAGE_LENGTH_OFFSET  (MESSAGE_TYPE_OFFSET + MESSAGE_TYPE_LENGTH)
65
66 #define PARAMETER_TAG_LENGTH    2
67 #define PARAMETER_LENGTH_LENGTH 2
68 #define PARAMETER_HEADER_LENGTH (PARAMETER_TAG_LENGTH + PARAMETER_LENGTH_LENGTH)
69
70 #define PARAMETER_TAG_OFFSET    0
71 #define PARAMETER_LENGTH_OFFSET (PARAMETER_TAG_OFFSET + PARAMETER_TAG_LENGTH)
72 #define PARAMETER_VALUE_OFFSET  (PARAMETER_LENGTH_OFFSET + PARAMETER_LENGTH_LENGTH)
73 #define PARAMETER_HEADER_OFFSET PARAMETER_TAG_OFFSET
74
75 #define PROTOCOL_VERSION_RELEASE_1             1
76
77 static const value_string protocol_version_values[] = {
78   { PROTOCOL_VERSION_RELEASE_1,  "Release 1" },
79   { 0,                           NULL } };
80
81 #define MESSAGE_CLASS_MGMT_MESSAGE        0
82 #define MESSAGE_CLASS_TFER_MESSAGE        1
83 #define MESSAGE_CLASS_SSNM_MESSAGE        2
84 #define MESSAGE_CLASS_ASPSM_MESSAGE       3
85 #define MESSAGE_CLASS_ASPTM_MESSAGE       4
86 #define MESSAGE_CLASS_RKM_MESSAGE         9
87
88 static const value_string message_class_values[] = {
89   { MESSAGE_CLASS_MGMT_MESSAGE,   "Management messages" },
90   { MESSAGE_CLASS_TFER_MESSAGE,   "Transfer messages" },
91   { MESSAGE_CLASS_SSNM_MESSAGE,   "SS7 signalling network management messages" },
92   { MESSAGE_CLASS_ASPSM_MESSAGE,  "ASP state maintenance messages" },
93   { MESSAGE_CLASS_ASPTM_MESSAGE,  "ASP traffic maintenance messages" },
94   { MESSAGE_CLASS_RKM_MESSAGE,    "Routing key management messages" },
95   { 0,                           NULL } };
96
97 static const value_string v5_message_class_values[] = {
98   { MESSAGE_CLASS_MGMT_MESSAGE,   "Management messages" },
99   { MESSAGE_CLASS_TFER_MESSAGE,   "Transfer messages" },
100   { MESSAGE_CLASS_SSNM_MESSAGE,   "SS7 signalling network management messages" },
101   { MESSAGE_CLASS_ASPSM_MESSAGE,  "ASP state maintenance messages" },
102   { MESSAGE_CLASS_ASPTM_MESSAGE,  "ASP traffic maintenance messages" },
103   { 0,                           NULL } };
104
105 #define MESSAGE_TYPE_ERR                  0
106 #define MESSAGE_TYPE_NTFY                 1
107
108 #define MESSAGE_TYPE_DATA                 1
109
110 #define MESSAGE_TYPE_DUNA                 1
111 #define MESSAGE_TYPE_DAVA                 2
112 #define MESSAGE_TYPE_DAUD                 3
113 #define MESSAGE_TYPE_SCON                 4
114 #define MESSAGE_TYPE_DUPU                 5
115 #define MESSAGE_TYPE_DRST                 6
116
117 #define MESSAGE_TYPE_UP                   1
118 #define MESSAGE_TYPE_DOWN                 2
119 #define MESSAGE_TYPE_BEAT                 3
120 #define MESSAGE_TYPE_UP_ACK               4
121 #define MESSAGE_TYPE_DOWN_ACK             5
122 #define MESSAGE_TYPE_BEAT_ACK             6
123
124 #define MESSAGE_TYPE_ACTIVE               1
125 #define MESSAGE_TYPE_INACTIVE             2
126 #define MESSAGE_TYPE_ACTIVE_ACK           3
127 #define MESSAGE_TYPE_INACTIVE_ACK         4
128
129 #define MESSAGE_TYPE_REG_REQ              1
130 #define MESSAGE_TYPE_REG_RSP              2
131 #define MESSAGE_TYPE_DEREG_REQ            3
132 #define MESSAGE_TYPE_DEREG_RSP            4
133
134 static const value_string v5_message_class_type_values[] = {
135   { MESSAGE_CLASS_MGMT_MESSAGE  * 256 + MESSAGE_TYPE_ERR,           "Error (ERR)" },
136   { MESSAGE_CLASS_MGMT_MESSAGE  * 256 + MESSAGE_TYPE_NTFY,          "Notify (NTFY)" },
137   { MESSAGE_CLASS_TFER_MESSAGE  * 256 + MESSAGE_TYPE_DATA,          "Payload data (DATA)" },
138   { MESSAGE_CLASS_SSNM_MESSAGE  * 256 + MESSAGE_TYPE_DUNA,          "Destination unavailable (DUNA)" },
139   { MESSAGE_CLASS_SSNM_MESSAGE  * 256 + MESSAGE_TYPE_DAVA,          "Destination available (DAVA)" },
140   { MESSAGE_CLASS_SSNM_MESSAGE  * 256 + MESSAGE_TYPE_DAUD,          "Destination state audit (DAUD)" },
141   { MESSAGE_CLASS_SSNM_MESSAGE  * 256 + MESSAGE_TYPE_SCON,          "SS7 Network congestion state (SCON)" },
142   { MESSAGE_CLASS_SSNM_MESSAGE  * 256 + MESSAGE_TYPE_DUPU,          "Destination userpart unavailable (DUPU)" },
143   { MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_UP,            "ASP up (UP)" },
144   { MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_DOWN,          "ASP down (DOWN)" },
145   { MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_BEAT,          "Heartbeat (BEAT)" },
146   { MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_UP_ACK,        "ASP up ack (UP ACK)" },
147   { MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_DOWN_ACK,      "ASP down ack (DOWN ACK)" },
148   { MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_BEAT_ACK,      "Heartbeat ack (BEAT ACK)" },
149   { MESSAGE_CLASS_ASPTM_MESSAGE * 256 + MESSAGE_TYPE_ACTIVE ,       "ASP active (ACTIVE)" },
150   { MESSAGE_CLASS_ASPTM_MESSAGE * 256 + MESSAGE_TYPE_INACTIVE ,     "ASP inactive (INACTIVE)" },
151   { MESSAGE_CLASS_ASPTM_MESSAGE * 256 + MESSAGE_TYPE_ACTIVE_ACK ,   "ASP active ack (ACTIVE ACK)" },
152   { MESSAGE_CLASS_ASPTM_MESSAGE * 256 + MESSAGE_TYPE_INACTIVE_ACK , "ASP inactive ack (INACTIVE ACK)" },
153   { 0,                                                              NULL } };
154
155 static const value_string message_class_type_values[] = {
156   { MESSAGE_CLASS_MGMT_MESSAGE  * 256 + MESSAGE_TYPE_ERR,           "Error (ERR)" },
157   { MESSAGE_CLASS_MGMT_MESSAGE  * 256 + MESSAGE_TYPE_NTFY,          "Notify (NTFY)" },
158   { MESSAGE_CLASS_TFER_MESSAGE  * 256 + MESSAGE_TYPE_DATA,          "Payload data (DATA)" },
159   { MESSAGE_CLASS_SSNM_MESSAGE  * 256 + MESSAGE_TYPE_DUNA,          "Destination unavailable (DUNA)" },
160   { MESSAGE_CLASS_SSNM_MESSAGE  * 256 + MESSAGE_TYPE_DAVA,          "Destination available (DAVA)" },
161   { MESSAGE_CLASS_SSNM_MESSAGE  * 256 + MESSAGE_TYPE_DAUD,          "Destination state audit (DAUD)" },
162   { MESSAGE_CLASS_SSNM_MESSAGE  * 256 + MESSAGE_TYPE_SCON,          "SS7 Network congestion state (SCON)" },
163   { MESSAGE_CLASS_SSNM_MESSAGE  * 256 + MESSAGE_TYPE_DUPU,          "Destination userpart unavailable (DUPU)" },
164   { MESSAGE_CLASS_SSNM_MESSAGE  * 256 + MESSAGE_TYPE_DRST,          "Destination Restricted (DRST)" },
165   { MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_UP,            "ASP up (ASPUP)" },
166   { MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_DOWN,          "ASP down (ASPDN)" },
167   { MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_BEAT,          "Heartbeat (BEAT)" },
168   { MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_UP_ACK,        "ASP up ack (ASPUP_ACK)" },
169   { MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_DOWN_ACK,      "ASP down ack (ASPDN_ACK)" },
170   { MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_BEAT_ACK,      "Heartbeat ack (BEAT_ACK)" },
171   { MESSAGE_CLASS_ASPTM_MESSAGE * 256 + MESSAGE_TYPE_ACTIVE ,       "ASP active (ASPAC)" },
172   { MESSAGE_CLASS_ASPTM_MESSAGE * 256 + MESSAGE_TYPE_INACTIVE ,     "ASP inactive (ASPIA)" },
173   { MESSAGE_CLASS_ASPTM_MESSAGE * 256 + MESSAGE_TYPE_ACTIVE_ACK ,   "ASP active ack (ASPAC_ACK)" },
174   { MESSAGE_CLASS_ASPTM_MESSAGE * 256 + MESSAGE_TYPE_INACTIVE_ACK , "ASP inactive ack (ASPIA_ACK)" },
175   { MESSAGE_CLASS_RKM_MESSAGE   * 256 + MESSAGE_TYPE_REG_REQ ,      "Registration request (REG_REQ)" },
176   { MESSAGE_CLASS_RKM_MESSAGE   * 256 + MESSAGE_TYPE_REG_RSP ,      "Registration response (REG_RSP)" },
177   { MESSAGE_CLASS_RKM_MESSAGE   * 256 + MESSAGE_TYPE_DEREG_REQ ,    "Deregistration request (DEREG_REQ)" },
178   { MESSAGE_CLASS_RKM_MESSAGE   * 256 + MESSAGE_TYPE_DEREG_RSP ,    "Deregistration response (DEREG_RSP)" },
179   { 0,                           NULL } };
180
181 static const value_string v5_message_class_type_acro_values[] = {
182   { MESSAGE_CLASS_MGMT_MESSAGE  * 256 + MESSAGE_TYPE_ERR,           "ERR" },
183   { MESSAGE_CLASS_MGMT_MESSAGE  * 256 + MESSAGE_TYPE_NTFY,          "NTFY" },
184   { MESSAGE_CLASS_TFER_MESSAGE  * 256 + MESSAGE_TYPE_DATA,          "DATA" },
185   { MESSAGE_CLASS_SSNM_MESSAGE  * 256 + MESSAGE_TYPE_DUNA,          "DUNA" },
186   { MESSAGE_CLASS_SSNM_MESSAGE  * 256 + MESSAGE_TYPE_DAVA,          "DAVA" },
187   { MESSAGE_CLASS_SSNM_MESSAGE  * 256 + MESSAGE_TYPE_DAUD,          "DAUD" },
188   { MESSAGE_CLASS_SSNM_MESSAGE  * 256 + MESSAGE_TYPE_SCON,          "SCON" },
189   { MESSAGE_CLASS_SSNM_MESSAGE  * 256 + MESSAGE_TYPE_DUPU,          "DUPU" },
190   { MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_UP,            "ASP_UP" },
191   { MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_DOWN,          "ASP_DOWN" },
192   { MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_BEAT,          "BEAT" },
193   { MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_UP_ACK,        "ASP_UP_ACK" },
194   { MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_DOWN_ACK,      "ASP_DOWN_ACK" },
195   { MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_BEAT_ACK,      "BEAT_ACK" },
196   { MESSAGE_CLASS_ASPTM_MESSAGE * 256 + MESSAGE_TYPE_ACTIVE ,       "ASP_ACTIVE" },
197   { MESSAGE_CLASS_ASPTM_MESSAGE * 256 + MESSAGE_TYPE_INACTIVE ,     "ASP_INACTIVE" },
198   { MESSAGE_CLASS_ASPTM_MESSAGE * 256 + MESSAGE_TYPE_ACTIVE_ACK ,   "ASP_ACTIVE_ACK" },
199   { MESSAGE_CLASS_ASPTM_MESSAGE * 256 + MESSAGE_TYPE_INACTIVE_ACK , "ASP_INACTIVE_ACK" },
200   { 0,                                                              NULL } };
201
202 static const value_string message_class_type_acro_values[] = {
203   { MESSAGE_CLASS_MGMT_MESSAGE  * 256 + MESSAGE_TYPE_ERR,           "ERR" },
204   { MESSAGE_CLASS_MGMT_MESSAGE  * 256 + MESSAGE_TYPE_NTFY,          "NTFY" },
205   { MESSAGE_CLASS_TFER_MESSAGE  * 256 + MESSAGE_TYPE_DATA,          "DATA" },
206   { MESSAGE_CLASS_SSNM_MESSAGE  * 256 + MESSAGE_TYPE_DUNA,          "DUNA" },
207   { MESSAGE_CLASS_SSNM_MESSAGE  * 256 + MESSAGE_TYPE_DAVA,          "DAVA" },
208   { MESSAGE_CLASS_SSNM_MESSAGE  * 256 + MESSAGE_TYPE_DAUD,          "DAUD" },
209   { MESSAGE_CLASS_SSNM_MESSAGE  * 256 + MESSAGE_TYPE_SCON,          "SCON" },
210   { MESSAGE_CLASS_SSNM_MESSAGE  * 256 + MESSAGE_TYPE_DUPU,          "DUPU" },
211   { MESSAGE_CLASS_SSNM_MESSAGE  * 256 + MESSAGE_TYPE_DRST,          "DRST" },
212   { MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_UP,            "ASPUP" },
213   { MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_DOWN,          "ASPDN" },
214   { MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_BEAT,          "BEAT" },
215   { MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_UP_ACK,        "ASPUP_ACK" },
216   { MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_DOWN_ACK,      "ASPDN_ACK" },
217   { MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_BEAT_ACK,      "BEAT_ACK" },
218   { MESSAGE_CLASS_ASPTM_MESSAGE * 256 + MESSAGE_TYPE_ACTIVE ,       "ASPAC" },
219   { MESSAGE_CLASS_ASPTM_MESSAGE * 256 + MESSAGE_TYPE_INACTIVE ,     "ASPIA" },
220   { MESSAGE_CLASS_ASPTM_MESSAGE * 256 + MESSAGE_TYPE_ACTIVE_ACK ,   "ASPAC_ACK" },
221   { MESSAGE_CLASS_ASPTM_MESSAGE * 256 + MESSAGE_TYPE_INACTIVE_ACK , "ASPIA_ACK" },
222   { MESSAGE_CLASS_RKM_MESSAGE   * 256 + MESSAGE_TYPE_REG_REQ ,      "REG_REQ" },
223   { MESSAGE_CLASS_RKM_MESSAGE   * 256 + MESSAGE_TYPE_REG_RSP ,      "REG_RSP" },
224   { MESSAGE_CLASS_RKM_MESSAGE   * 256 + MESSAGE_TYPE_DEREG_REQ ,    "DEREG_REQ" },
225   { MESSAGE_CLASS_RKM_MESSAGE   * 256 + MESSAGE_TYPE_DEREG_RSP ,    "DEREG_RSP" },
226   { 0,                           NULL } };
227
228 /* Initialize the protocol and registered fields */
229 static int proto_m3ua = -1;
230 static int hf_version = -1;
231 static int hf_reserved = -1;
232 static int hf_message_class = -1;
233 static int hf_v5_message_class = -1;
234 static int hf_message_type = -1;
235 static int hf_message_length = -1;
236 static int hf_v5_parameter_tag = -1;
237 static int hf_v6_parameter_tag = -1;
238 static int hf_parameter_tag = -1;
239 static int hf_parameter_length = -1;
240 static int hf_parameter_value = -1;
241 static int hf_parameter_padding = -1;
242 static int hf_parameter_trailer = -1;
243 static int hf_network_appearance = -1;
244 static int hf_info_string = -1;
245 static int hf_routing_context = -1;
246 static int hf_diagnostic_information = -1;
247 static int hf_heartbeat_data = -1;
248 static int hf_v5_error_code = -1;
249 static int hf_v6_error_code = -1;
250 static int hf_error_code = -1;
251 static int hf_status_type = -1;
252 static int hf_status_info = -1;
253 static int hf_asp_identifier = -1;
254 static int hf_affected_point_code_mask = -1;
255 static int hf_affected_point_code_pc = -1;
256 static int hf_cause = -1;
257 static int hf_user = -1;
258 static int hf_reason = -1;
259 static int hf_v5_traffic_mode_type = -1;
260 static int hf_v6_traffic_mode_type = -1;
261 static int hf_traffic_mode_type = -1;
262 static int hf_congestion_reserved = -1;
263 static int hf_congestion_level = -1;
264 static int hf_concerned_dest_reserved = -1;
265 static int hf_concerned_dest_pc = -1;
266 static int hf_local_rk_identifier = -1;
267 static int hf_dpc_mask = -1;
268 static int hf_dpc_pc = -1;
269 static int hf_si = -1;
270 static int hf_ssn = -1;
271 static int hf_opc_list_mask = -1;
272 static int hf_opc_list_pc = -1;
273 static int hf_cic_range_mask = -1;
274 static int hf_cic_range_pc = -1;
275 static int hf_cic_range_upper = -1;
276 static int hf_cic_range_lower = -1;
277 static int hf_protocol_data_opc = -1;
278 static int hf_protocol_data_dpc = -1;
279 static int hf_protocol_data_si = -1;
280 static int hf_protocol_data_ni = -1;
281 static int hf_protocol_data_mp = -1;
282 static int hf_protocol_data_sls = -1;
283 static int hf_correlation_identifier = -1;
284 static int hf_registration_status = -1;
285 static int hf_deregistration_status = -1;
286 static int hf_registration_result_identifier = -1;
287 static int hf_registration_result_status = -1;
288 static int hf_registration_result_context = -1;
289 static int hf_v6_deregistration_result_status = -1;
290 static int hf_v6_deregistration_result_context = -1;
291 static int hf_li = -1;
292
293 /* Initialize the subtree pointers */
294 static gint ett_m3ua = -1;
295 static gint ett_parameter = -1;
296
297 static module_t *m3ua_module;
298 static dissector_handle_t mtp3_handle, data_handle;
299 static dissector_table_t si_dissector_table;
300
301 /* stuff for supporting multiple versions */
302 typedef enum {
303   M3UA_V5,
304   M3UA_V6,
305   M3UA_RFC
306 } Version_Type;
307
308 static Version_Type version = M3UA_RFC;
309
310 static void
311 dissect_parameters(tvbuff_t *, packet_info *, proto_tree *, proto_tree *);
312
313 static void
314 dissect_v5_common_header(tvbuff_t *common_header_tvb, packet_info *pinfo, proto_tree *m3ua_tree)
315 {
316   guint8  message_class, message_type;
317
318   /* Extract the common header */
319   message_class  = tvb_get_guint8(common_header_tvb, MESSAGE_CLASS_OFFSET);
320   message_type   = tvb_get_guint8(common_header_tvb, MESSAGE_TYPE_OFFSET);
321
322   if (check_col(pinfo->cinfo, COL_INFO))
323     col_add_fstr(pinfo->cinfo, COL_INFO, "%s ", val_to_str(message_class * 256 + message_type, v5_message_class_type_acro_values, "reserved"));
324
325   if (m3ua_tree) {
326     /* add the components of the common header to the protocol tree */
327     proto_tree_add_item(m3ua_tree, hf_version, common_header_tvb, VERSION_OFFSET, VERSION_LENGTH, NETWORK_BYTE_ORDER);
328     proto_tree_add_item(m3ua_tree, hf_reserved, common_header_tvb, RESERVED_OFFSET, RESERVED_LENGTH, NETWORK_BYTE_ORDER);
329     proto_tree_add_item(m3ua_tree, hf_v5_message_class, common_header_tvb, MESSAGE_CLASS_OFFSET, MESSAGE_CLASS_LENGTH, NETWORK_BYTE_ORDER);
330     proto_tree_add_uint_format(m3ua_tree, hf_message_type, common_header_tvb, MESSAGE_TYPE_OFFSET, MESSAGE_TYPE_LENGTH, message_type,
331                                "Message type: %s (%u)", val_to_str(message_class * 256 + message_type, v5_message_class_type_values, "reserved"), message_type);
332     proto_tree_add_item(m3ua_tree, hf_message_length, common_header_tvb, MESSAGE_LENGTH_OFFSET, MESSAGE_LENGTH_LENGTH, NETWORK_BYTE_ORDER);
333   }
334 }
335
336 static void
337 dissect_common_header(tvbuff_t *common_header_tvb, packet_info *pinfo, proto_tree *m3ua_tree)
338 {
339   guint8  message_class, message_type;
340
341   /* Extract the common header */
342   message_class  = tvb_get_guint8(common_header_tvb, MESSAGE_CLASS_OFFSET);
343   message_type   = tvb_get_guint8(common_header_tvb, MESSAGE_TYPE_OFFSET);
344
345   if (check_col(pinfo->cinfo, COL_INFO))
346     col_add_fstr(pinfo->cinfo, COL_INFO,"%s ", val_to_str(message_class * 256 + message_type, message_class_type_acro_values, "reserved"));
347
348   if (m3ua_tree) {
349     /* add the components of the common header to the protocol tree */
350     proto_tree_add_item(m3ua_tree, hf_version, common_header_tvb, VERSION_OFFSET, VERSION_LENGTH, NETWORK_BYTE_ORDER);
351     proto_tree_add_item(m3ua_tree, hf_reserved, common_header_tvb, RESERVED_OFFSET, RESERVED_LENGTH, NETWORK_BYTE_ORDER);
352     proto_tree_add_item(m3ua_tree, hf_message_class, common_header_tvb, MESSAGE_CLASS_OFFSET, MESSAGE_CLASS_LENGTH, NETWORK_BYTE_ORDER);
353     proto_tree_add_uint_format(m3ua_tree, hf_message_type, common_header_tvb, MESSAGE_TYPE_OFFSET, MESSAGE_TYPE_LENGTH, message_type,
354                                "Message type: %s (%u)", val_to_str(message_class * 256 + message_type, message_class_type_values, "reserved"), message_type);
355     proto_tree_add_item(m3ua_tree, hf_message_length, common_header_tvb, MESSAGE_LENGTH_OFFSET, MESSAGE_LENGTH_LENGTH, NETWORK_BYTE_ORDER);
356   }
357 }
358
359 #define NETWORK_APPEARANCE_LENGTH 4
360 #define NETWORK_APPEARANCE_OFFSET PARAMETER_VALUE_OFFSET
361
362 static void
363 dissect_network_appearance_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
364 {
365   proto_tree_add_item(parameter_tree, hf_network_appearance, parameter_tvb, NETWORK_APPEARANCE_OFFSET, NETWORK_APPEARANCE_LENGTH, NETWORK_BYTE_ORDER);
366   proto_item_append_text(parameter_item, " (%u)", tvb_get_ntohl(parameter_tvb, NETWORK_APPEARANCE_OFFSET));
367 }
368
369 #define V5_PROTOCOL_DATA_OFFSET PARAMETER_VALUE_OFFSET
370
371 static void
372 dissect_v5_protocol_data_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, proto_tree *tree, proto_item *parameter_item)
373 {
374   guint16 length, protocol_data_length;
375   tvbuff_t *payload_tvb;
376
377   length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET);
378   protocol_data_length = length - PARAMETER_HEADER_LENGTH;
379   payload_tvb          = tvb_new_subset(parameter_tvb, V5_PROTOCOL_DATA_OFFSET, protocol_data_length, protocol_data_length);
380   proto_item_append_text(parameter_item, " (SS7 message of %u byte%s)", protocol_data_length, plurality(protocol_data_length, "", "s"));
381   proto_item_set_len(parameter_item, PARAMETER_HEADER_LENGTH);
382   call_dissector(mtp3_handle, payload_tvb, pinfo, tree);
383 }
384
385 #define INFO_STRING_OFFSET PARAMETER_VALUE_OFFSET
386
387 static void
388 dissect_info_string_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
389 {
390   guint16 info_string_length;
391
392   info_string_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH;
393   proto_tree_add_item(parameter_tree, hf_info_string, parameter_tvb, INFO_STRING_OFFSET, info_string_length, NETWORK_BYTE_ORDER);
394   proto_item_append_text(parameter_item, " (%.*s)", info_string_length,
395                          (const char *)tvb_get_ptr(parameter_tvb, INFO_STRING_OFFSET, info_string_length));
396 }
397
398 #define AFFECTED_MASK_LENGTH 1
399 #define AFFECTED_DPC_LENGTH  3
400 #define AFFECTED_DESTINATION_LENGTH (AFFECTED_MASK_LENGTH + AFFECTED_DPC_LENGTH)
401
402 #define AFFECTED_MASK_OFFSET 0
403 #define AFFECTED_DPC_OFFSET  1
404
405 static void
406 dissect_affected_destinations_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
407 {
408   guint16 number_of_destinations, destination_number;
409   gint destination_offset;
410
411   number_of_destinations = (tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH) >> 2;
412   destination_offset = PARAMETER_VALUE_OFFSET;
413   for(destination_number=1; destination_number <= number_of_destinations; destination_number++) {
414     proto_tree_add_item(parameter_tree, hf_affected_point_code_mask, parameter_tvb, destination_offset + AFFECTED_MASK_OFFSET, AFFECTED_MASK_LENGTH, NETWORK_BYTE_ORDER);
415     proto_tree_add_item(parameter_tree, hf_affected_point_code_pc,   parameter_tvb, destination_offset + AFFECTED_DPC_OFFSET,  AFFECTED_DPC_LENGTH,  NETWORK_BYTE_ORDER);
416     destination_offset += AFFECTED_DESTINATION_LENGTH;
417   }
418   proto_item_append_text(parameter_item, " (%u destination%s)", number_of_destinations, plurality(number_of_destinations, "", "s"));
419 }
420
421 #define ROUTING_CONTEXT_LENGTH 4
422
423 static void
424 dissect_routing_context_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
425 {
426   guint16 number_of_contexts, context_number;
427   gint context_offset;
428
429   number_of_contexts = (tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH) >> 2;
430   context_offset = PARAMETER_VALUE_OFFSET;
431   for(context_number=1; context_number <= number_of_contexts; context_number++) {
432     proto_tree_add_item(parameter_tree, hf_routing_context, parameter_tvb, context_offset, ROUTING_CONTEXT_LENGTH, NETWORK_BYTE_ORDER);
433     context_offset += ROUTING_CONTEXT_LENGTH;
434   };
435   proto_item_append_text(parameter_item, " (%u context%s)", number_of_contexts, plurality(number_of_contexts, "", "s"));
436 }
437
438 #define DIAGNOSTIC_INFO_OFFSET PARAMETER_VALUE_OFFSET
439
440 static void
441 dissect_diagnostic_information_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
442 {
443   guint16 diag_info_length;
444
445   diag_info_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH;
446   proto_tree_add_item(parameter_tree, hf_diagnostic_information, parameter_tvb, DIAGNOSTIC_INFO_OFFSET, diag_info_length, NETWORK_BYTE_ORDER);
447   proto_item_append_text(parameter_item, " (%u byte%s)", diag_info_length, plurality(diag_info_length, "", "s"));
448 }
449
450 #define HEARTBEAT_DATA_OFFSET PARAMETER_VALUE_OFFSET
451
452 static void
453 dissect_heartbeat_data_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
454 {
455   guint16 heartbeat_data_length;
456
457   heartbeat_data_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH;
458   proto_tree_add_item(parameter_tree, hf_heartbeat_data, parameter_tvb, HEARTBEAT_DATA_OFFSET, heartbeat_data_length, NETWORK_BYTE_ORDER);
459   proto_item_append_text(parameter_item, " (%u byte%s)", heartbeat_data_length, plurality(heartbeat_data_length, "", "s"));
460 }
461
462 #define UNKNOWN_UNAVAIL_CAUSE                  0
463 #define UNEQUIPPED_REMOTE_USER_UNAVAIL_CAUSE   1
464 #define INACCESSABLE_REMOTE_USER_UNAVAIL_CAUSE 2
465
466 static const value_string unavailability_cause_values[] = {
467   { UNKNOWN_UNAVAIL_CAUSE,                  "Unknown"                  },
468   { UNEQUIPPED_REMOTE_USER_UNAVAIL_CAUSE,   "Unequipped remote user"   },
469   { INACCESSABLE_REMOTE_USER_UNAVAIL_CAUSE, "Inaccessable remote user" },
470   {0,                                       NULL } };
471
472 #define RESERVED_0_USER_ID                0
473 #define RESERVED_1_USER_ID                1
474 #define RESERVED_2_USER_ID                2
475 #define SCCP_USER_ID                      3
476 #define TUP_USER_ID                       4
477 #define ISUP_USER_ID                      5
478 #define RESERVED_6_USER_ID                6
479 #define RESERVED_7_USER_ID                7
480 #define RESERVED_8_USER_ID                8
481 #define BROADBAND_ISUP_USER_ID            9
482 #define SATELLITE_ISUP_USER_ID           10
483 #define RESERVED_11_USER_ID              11
484 #define AAL_2_SIGNALING_USER_ID          12
485 #define BICC_USER_ID                     13
486 #define GATEWAY_CONTROL_PROTOCOL_USER_ID 14
487 #define RESERVED_15_USER_ID              15
488
489 static const value_string user_identity_values[] = {
490   { RESERVED_0_USER_ID,     "Reserved"       },
491   { RESERVED_1_USER_ID,     "Reserved"       },
492   { RESERVED_2_USER_ID,     "Reserved"       },
493   { SCCP_USER_ID,           "SCCP"           },
494   { TUP_USER_ID,            "TUP"            },
495   { ISUP_USER_ID,           "ISUP"           },
496   { RESERVED_6_USER_ID,     "Reserved"       },
497   { RESERVED_7_USER_ID,     "Reserved"       },
498   { RESERVED_8_USER_ID,     "Reserved"       },
499   { BROADBAND_ISUP_USER_ID, "Broadband ISUP" },
500   { SATELLITE_ISUP_USER_ID, "Satellite ISUP" },
501   { RESERVED_11_USER_ID,    "Reserved"       }, 
502   { AAL_2_SIGNALING_USER_ID,"AAL type2 Signaling"},
503   { BICC_USER_ID,           "Bearer Independent Call Control (BICC)"},  
504   { GATEWAY_CONTROL_PROTOCOL_USER_ID, "Gateway Control Protocol"},
505   { RESERVED_15_USER_ID,    "Reserved"       },
506
507   {0,                       NULL             } };
508
509 #define CAUSE_LENGTH 2
510 #define USER_LENGTH  2
511
512 #define CAUSE_OFFSET  PARAMETER_VALUE_OFFSET
513 #define USER_OFFSET   (CAUSE_OFFSET + CAUSE_LENGTH)
514
515 static void
516 dissect_user_cause_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
517 {
518   proto_tree_add_item(parameter_tree, hf_cause, parameter_tvb, CAUSE_OFFSET, CAUSE_LENGTH, NETWORK_BYTE_ORDER);
519   proto_tree_add_item(parameter_tree, hf_user,  parameter_tvb, USER_OFFSET,  USER_LENGTH,  NETWORK_BYTE_ORDER);
520   proto_item_append_text(parameter_item, " (%s: %s)", 
521                          val_to_str(tvb_get_ntohs(parameter_tvb, USER_OFFSET),  user_identity_values,        "Unknown user"),
522                          val_to_str(tvb_get_ntohs(parameter_tvb, CAUSE_OFFSET), unavailability_cause_values, "unknown cause"));
523 }
524
525 #define UNSPECIFIED_REASON          0
526 #define USER_UNAVAILABLE_REASON     1
527 #define MANAGEMENT_BLOCKING_REASON  2
528
529 static const value_string reason_values[] = {
530   { UNSPECIFIED_REASON,         "Unspecified" },
531   { USER_UNAVAILABLE_REASON,    "User unavailable" },
532   { MANAGEMENT_BLOCKING_REASON, "Management blocking" },
533   {0,                           NULL } };
534
535 #define REASON_LENGTH 4
536 #define REASON_OFFSET PARAMETER_VALUE_OFFSET
537
538 static void
539 dissect_reason_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
540 {
541   proto_tree_add_item(parameter_tree, hf_reason, parameter_tvb, REASON_OFFSET, REASON_LENGTH, NETWORK_BYTE_ORDER);
542   proto_item_append_text(parameter_item, " (%s)", val_to_str(tvb_get_ntohl(parameter_tvb, REASON_OFFSET), reason_values, "unknown"));
543 }
544
545 #define TRAFFIC_MODE_TYPE_LENGTH 4
546 #define TRAFFIC_MODE_TYPE_OFFSET PARAMETER_VALUE_OFFSET
547
548 static const value_string v5_traffic_mode_type_values[] = {
549   { 1, "Over-ride"            },
550   { 2, "Load-share"           },
551   { 3, "Over-ride (standby)"  },
552   { 4, "Load-share (standby)" },
553   { 0, NULL                   } };
554
555 static void
556 dissect_v5_traffic_mode_type_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
557 {
558   proto_tree_add_item(parameter_tree, hf_v5_traffic_mode_type, parameter_tvb, TRAFFIC_MODE_TYPE_OFFSET, TRAFFIC_MODE_TYPE_LENGTH, NETWORK_BYTE_ORDER);
559   proto_item_append_text(parameter_item, " (%s)", val_to_str(tvb_get_ntohl(parameter_tvb, TRAFFIC_MODE_TYPE_OFFSET), v5_traffic_mode_type_values, "unknown"));
560 }
561
562 static const value_string v6_traffic_mode_type_values[] = {
563   { 1, "Over-ride"            },
564   { 2, "Load-share"           },
565   { 3, "Over-ride (standby)"  },
566   { 4, "Load-share (standby)" },
567   { 0, NULL                   } };
568
569 static void
570 dissect_v6_traffic_mode_type_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
571 {
572   proto_tree_add_item(parameter_tree, hf_v6_traffic_mode_type, parameter_tvb, TRAFFIC_MODE_TYPE_OFFSET, TRAFFIC_MODE_TYPE_LENGTH, NETWORK_BYTE_ORDER);
573   proto_item_append_text(parameter_item, " (%s)", val_to_str(tvb_get_ntohl(parameter_tvb, TRAFFIC_MODE_TYPE_OFFSET), v6_traffic_mode_type_values, "unknown"));
574 }
575
576 static const value_string traffic_mode_type_values[] = {
577   { 1, "Over-ride"  },
578   { 2, "Load-share" },
579   { 3, "Broadcast"  },
580   { 0, NULL         } };
581
582 static void
583 dissect_traffic_mode_type_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
584 {
585   proto_tree_add_item(parameter_tree, hf_traffic_mode_type, parameter_tvb, TRAFFIC_MODE_TYPE_OFFSET, TRAFFIC_MODE_TYPE_LENGTH, NETWORK_BYTE_ORDER);
586   proto_item_append_text(parameter_item, " (%s)", val_to_str(tvb_get_ntohl(parameter_tvb, TRAFFIC_MODE_TYPE_OFFSET), traffic_mode_type_values, "unknown"));
587 }
588
589 #define ERROR_CODE_LENGTH 4
590 #define ERROR_CODE_OFFSET PARAMETER_VALUE_OFFSET
591
592 static const value_string v5_error_code_values[] = {
593   {  1, "Invalid version"               },
594   {  2, "Invalid network appearance"    },
595   {  3, "Unsupported message class"     },
596   {  4, "Unsupported message type"      },
597   {  5, "Invalid traffic handling mode" },
598   {  6, "Unexpected message"            },
599   {  7, "Protocol error"                },
600   {  8, "Invalid routing context"       },
601   {  0,  NULL                           } };
602   
603 static void
604 dissect_v5_error_code_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
605 {
606   proto_tree_add_item(parameter_tree, hf_v5_error_code, parameter_tvb, ERROR_CODE_OFFSET, ERROR_CODE_LENGTH, NETWORK_BYTE_ORDER);
607   proto_item_append_text(parameter_item, " (%s)", val_to_str(tvb_get_ntohl(parameter_tvb, ERROR_CODE_OFFSET), v5_error_code_values, "unknown"));
608 }
609
610 static const value_string v6_error_code_values[] = {
611   {  1, "Invalid version"               },
612   {  2, "Invalid network appearance"    },
613   {  3, "Unsupported message class"     },
614   {  4, "Unsupported message type"      },
615   {  5, "Invalid traffic handling mode" },
616   {  6, "Unexpected message"            },
617   {  7, "Protocol error"                },
618   {  8, "Invalid routing context"       },
619   {  9, "Invalid stream identifier"     },
620   { 10, "Invalid parameter value"       },
621   {  0,  NULL                           } };
622
623
624 static void
625 dissect_v6_error_code_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
626 {
627   proto_tree_add_item(parameter_tree, hf_v6_error_code, parameter_tvb, ERROR_CODE_OFFSET, ERROR_CODE_LENGTH, NETWORK_BYTE_ORDER);
628   proto_item_append_text(parameter_item, " (%s)", val_to_str(tvb_get_ntohl(parameter_tvb, ERROR_CODE_OFFSET), v6_error_code_values, "unknown"));
629 }
630
631 static const value_string error_code_values[] = {
632   { 0x01, "Invalid version"                   },
633   { 0x03, "Unsupported message class"         },
634   { 0x04, "Unsupported message type"          },
635   { 0x05, "Unsupported traffic handling mode" },
636   { 0x06, "Unexpected message"                },
637   { 0x07, "Protocol error"                    },
638   { 0x09, "Invalid stream identifier"         },
639   { 0x0d, "Refused - management blocking"     },
640   { 0x0e, "ASP identifier required"           },
641   { 0x0f, "Invalid ASP identifier"            },
642   { 0x11, "Invalid parameter value"           },
643   { 0x12, "Parameter field error"             },
644   { 0x13, "Unexpected parameter"              },
645   { 0x14, "Destination status unknown"        },
646   { 0x15, "Invalid network appearance"        },
647   { 0x16, "Missing parameter"                 },
648   { 0x19, "Invalid routing context"           },
649   { 0x1a, "No configured AS for ASP"          },
650   { 0,    NULL                                } };
651
652 static void
653 dissect_error_code_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
654 {
655   proto_tree_add_item(parameter_tree, hf_error_code, parameter_tvb, ERROR_CODE_OFFSET, ERROR_CODE_LENGTH, NETWORK_BYTE_ORDER);
656   proto_item_append_text(parameter_item, " (%s)", val_to_str(tvb_get_ntohl(parameter_tvb, ERROR_CODE_OFFSET), error_code_values, "unknown"));
657 }
658
659 #define AS_STATE_CHANGE_TYPE       1
660 #define OTHER_TYPE                 2
661
662 static const value_string status_type_values[] = {
663   { AS_STATE_CHANGE_TYPE,            "Application server state change" },
664   { OTHER_TYPE,                      "Other" },
665   { 0,                           NULL } };
666
667 #define RESERVED_INFO              1
668 #define AS_INACTIVE_INFO           2
669 #define AS_ACTIVE_INFO             3
670 #define AS_PENDING_INFO            4
671
672 #define INSUFFICIENT_ASP_RES_INFO  1
673 #define ALTERNATE_ASP_ACTIVE_INFO  2
674 #define ASP_FAILURE_INFO           3
675
676 static const value_string v56_status_type_info_values[] = {
677   { AS_STATE_CHANGE_TYPE * 256 * 256 + RESERVED_INFO,             "Reserved" },
678   { AS_STATE_CHANGE_TYPE * 256 * 256 + AS_INACTIVE_INFO,          "Application server inactive" },
679   { AS_STATE_CHANGE_TYPE * 256 * 256 + AS_ACTIVE_INFO,            "Application server active" },
680   { AS_STATE_CHANGE_TYPE * 256 * 256 + AS_PENDING_INFO,           "Application server pending" },
681   { OTHER_TYPE           * 256 * 256 + INSUFFICIENT_ASP_RES_INFO, "Insufficient ASP resources active in AS" },
682   { OTHER_TYPE           * 256 * 256 + ALTERNATE_ASP_ACTIVE_INFO, "Alternate ASP active" },
683   {0,                           NULL } };
684
685
686 #define STATUS_TYPE_LENGTH 2
687 #define STATUS_INFO_LENGTH 2
688
689 #define STATUS_TYPE_OFFSET PARAMETER_VALUE_OFFSET
690 #define STATUS_INFO_OFFSET (STATUS_TYPE_OFFSET + STATUS_TYPE_LENGTH)
691
692 static void
693 dissect_v56_status_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
694 {
695   guint16 status_type, status_info;
696
697   status_type = tvb_get_ntohs(parameter_tvb, STATUS_TYPE_OFFSET);
698   status_info = tvb_get_ntohs(parameter_tvb, STATUS_INFO_OFFSET);
699
700   proto_tree_add_item(parameter_tree, hf_status_type, parameter_tvb, STATUS_TYPE_OFFSET, STATUS_TYPE_LENGTH, NETWORK_BYTE_ORDER);
701   proto_tree_add_uint_format(parameter_tree, hf_status_info, parameter_tvb, STATUS_INFO_OFFSET, STATUS_INFO_LENGTH, status_info,
702                              "Status info: %s (%u)", val_to_str(status_type * 256 * 256 + status_info, v56_status_type_info_values, "unknown"), status_info);
703
704   proto_item_append_text(parameter_item, " (%s)", val_to_str(status_type * 256 * 256 + status_info, v56_status_type_info_values, "unknown status information"));
705 }
706
707 static const value_string status_type_info_values[] = {
708   { AS_STATE_CHANGE_TYPE * 256 * 256 + RESERVED_INFO,             "Reserved" },
709   { AS_STATE_CHANGE_TYPE * 256 * 256 + AS_INACTIVE_INFO,          "Application server inactive" },
710   { AS_STATE_CHANGE_TYPE * 256 * 256 + AS_ACTIVE_INFO,            "Application server active" },
711   { AS_STATE_CHANGE_TYPE * 256 * 256 + AS_PENDING_INFO,           "Application server pending" },
712   { OTHER_TYPE           * 256 * 256 + INSUFFICIENT_ASP_RES_INFO, "Insufficient ASP resources active in AS" },
713   { OTHER_TYPE           * 256 * 256 + ALTERNATE_ASP_ACTIVE_INFO, "Alternate ASP active" },
714   { OTHER_TYPE           * 256 * 256 + ASP_FAILURE_INFO,          "ASP Failure" },
715   {0,                           NULL } };
716
717 static void
718 dissect_status_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
719 {
720   guint16 status_type, status_info;
721
722   status_type = tvb_get_ntohs(parameter_tvb, STATUS_TYPE_OFFSET);
723   status_info = tvb_get_ntohs(parameter_tvb, STATUS_INFO_OFFSET);
724
725   proto_tree_add_item(parameter_tree, hf_status_type, parameter_tvb, STATUS_TYPE_OFFSET, STATUS_TYPE_LENGTH, NETWORK_BYTE_ORDER);
726   proto_tree_add_uint_format(parameter_tree, hf_status_info, parameter_tvb, STATUS_INFO_OFFSET, STATUS_INFO_LENGTH, status_info,
727                              "Status info: %s (%u)", val_to_str(status_type * 256 * 256 + status_info, status_type_info_values, "unknown"), status_info);
728
729   proto_item_append_text(parameter_item, " (%s)", val_to_str(status_type * 256 * 256 + status_info, status_type_info_values, "unknown status information"));
730 }
731
732 static const value_string congestion_level_values[] = {
733   { 0, "No congestion or undefined" },
734   { 1, "Congestion level 1"         },
735   { 2, "Congestion level 2"         },
736   { 3, "Congestion level 3"         },
737   { 0, NULL                         } };
738
739 #define CONG_IND_RESERVED_LENGTH    3
740 #define CONG_IND_LEVEL_LENGTH       1
741
742 #define CONG_IND_RESERVED_OFFSET     PARAMETER_VALUE_OFFSET
743 #define CONG_IND_LEVEL_OFFSET        (CONG_IND_RESERVED_OFFSET + CONG_IND_RESERVED_LENGTH)
744
745 static void
746 dissect_congestion_indication_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
747 {
748   proto_tree_add_item(parameter_tree, hf_congestion_reserved, parameter_tvb, CONG_IND_RESERVED_OFFSET, CONG_IND_RESERVED_LENGTH, NETWORK_BYTE_ORDER);
749   proto_tree_add_item(parameter_tree, hf_congestion_level,    parameter_tvb, CONG_IND_LEVEL_OFFSET,    CONG_IND_LEVEL_LENGTH,    NETWORK_BYTE_ORDER);
750   proto_item_append_text(parameter_item, " (%s)", val_to_str(tvb_get_guint8(parameter_tvb, CONG_IND_LEVEL_OFFSET), congestion_level_values, "unknown"));
751 }
752
753 #define ASP_IDENTIFIER_OFFSET PARAMETER_VALUE_OFFSET
754 #define ASP_IDENTIFIER_LENGTH  4
755
756 static void
757 dissect_asp_identifier_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
758 {
759   proto_tree_add_item(parameter_tree, hf_asp_identifier, parameter_tvb, ASP_IDENTIFIER_OFFSET, ASP_IDENTIFIER_LENGTH, NETWORK_BYTE_ORDER);
760   proto_item_append_text(parameter_item, " (%u)", tvb_get_ntohl(parameter_tvb, ASP_IDENTIFIER_OFFSET));
761 }
762
763 #define PROTOCOL_DATA_1_OFFSET PARAMETER_VALUE_OFFSET
764
765 static void
766 dissect_protocol_data_1_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, proto_tree *tree, proto_item *parameter_item)
767 {
768   guint16 protocol_data_length;
769   tvbuff_t *payload_tvb;
770
771   protocol_data_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH;
772   payload_tvb          = tvb_new_subset(parameter_tvb, PROTOCOL_DATA_1_OFFSET, protocol_data_length, protocol_data_length);
773   proto_item_append_text(parameter_item, " (SS7 message of %u byte%s)", protocol_data_length, plurality(protocol_data_length, "", "s"));
774   proto_item_set_len(parameter_item, PARAMETER_HEADER_LENGTH);
775   call_dissector(mtp3_handle, payload_tvb, pinfo, tree);
776 }
777
778 #define LI_OCTETT_LENGTH 1
779 #define LI_OCTETT_OFFSET PARAMETER_VALUE_OFFSET
780 #define PROTOCOL_DATA_2_OFFSET (PARAMETER_VALUE_OFFSET + LI_OCTETT_LENGTH)
781
782 static void
783 dissect_protocol_data_2_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, proto_tree *tree, proto_tree *parameter_tree, proto_item *parameter_item)
784 {
785   guint8 li;
786   guint16 protocol_data_length;
787   tvbuff_t *payload_tvb;
788
789   li                   = tvb_get_guint8(parameter_tvb, LI_OCTETT_OFFSET);
790   protocol_data_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH - LI_OCTETT_LENGTH;
791   payload_tvb          = tvb_new_subset(parameter_tvb, PROTOCOL_DATA_2_OFFSET, protocol_data_length, protocol_data_length);
792   proto_tree_add_item(parameter_tree, hf_li, parameter_tvb, LI_OCTETT_OFFSET, LI_OCTETT_LENGTH, NETWORK_BYTE_ORDER);
793   proto_item_append_text(parameter_item, " (SS7 message of %u byte%s)", protocol_data_length, plurality(protocol_data_length, "", "s"));
794   proto_item_set_len(parameter_item, PARAMETER_HEADER_LENGTH + LI_OCTETT_LENGTH);
795   call_dissector(mtp3_handle, payload_tvb, pinfo, tree);
796 }
797
798
799
800 #define CON_DEST_RESERVED_LENGTH    1
801 #define CON_DEST_PC_LENGTH          3
802
803 #define CON_DEST_RESERVED_OFFSET    PARAMETER_VALUE_OFFSET
804 #define CON_DEST_PC_OFFSET          (CON_DEST_RESERVED_OFFSET + CON_DEST_RESERVED_LENGTH)
805
806 static void
807 dissect_concerned_destination_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
808 {
809   proto_tree_add_item(parameter_tree, hf_concerned_dest_reserved, parameter_tvb, CON_DEST_RESERVED_OFFSET, CON_DEST_RESERVED_LENGTH, NETWORK_BYTE_ORDER);
810   proto_tree_add_item(parameter_tree, hf_concerned_dest_pc,       parameter_tvb, CON_DEST_PC_OFFSET,       CON_DEST_PC_LENGTH,       NETWORK_BYTE_ORDER);
811   proto_item_append_text(parameter_item, " (%u)", tvb_get_ntoh24(parameter_tvb, CON_DEST_PC_OFFSET));
812 }
813
814 static void
815 dissect_routing_key_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, proto_tree *tree, proto_tree *parameter_tree)
816 {
817   tvbuff_t *parameters_tvb;
818   guint16 length, parameters_length;
819
820   length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET);
821   parameters_length = length - PARAMETER_HEADER_LENGTH;
822   parameters_tvb          = tvb_new_subset(parameter_tvb, PARAMETER_VALUE_OFFSET, parameters_length, parameters_length);
823   dissect_parameters(parameters_tvb, pinfo, tree, parameter_tree);
824 }
825
826 static const value_string registration_result_status_values[] = {
827   { 0, "Successfully Registered" } ,
828   { 1, "Error - Unknown" } ,
829   { 2, "Error - Invalid DPC" } ,
830   { 3, "Error - Invalid Network Appearance" } ,
831   { 4, "Error - Invalid Routing Key" } ,
832   { 5, "Error - Permission Denied" } ,
833   { 6, "Error - Overlapping (Non-unique) Routing Key" } ,
834   { 7, "Error - Routing Key not Provisioned" } ,
835   { 8, "Error - Insufficient Resources" } ,
836   { 0, NULL } };
837
838 #define REG_RES_IDENTIFIER_LENGTH 4
839 #define REG_RES_STATUS_LENGTH     4
840 #define REG_RES_CONTEXT_LENGTH    4
841
842 #define REG_RES_IDENTIFIER_OFFSET PARAMETER_VALUE_OFFSET
843 #define REG_RES_STATUS_OFFSET     (REG_RES_IDENTIFIER_OFFSET + REG_RES_IDENTIFIER_LENGTH)
844 #define REG_RES_CONTEXT_OFFSET    (REG_RES_STATUS_OFFSET + REG_RES_STATUS_LENGTH)
845
846 static void
847 dissect_v6_registration_result_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree)
848 {
849   proto_tree_add_item(parameter_tree, hf_registration_result_identifier, parameter_tvb, REG_RES_IDENTIFIER_OFFSET, REG_RES_IDENTIFIER_LENGTH, NETWORK_BYTE_ORDER);
850   proto_tree_add_item(parameter_tree, hf_registration_result_status,     parameter_tvb, REG_RES_STATUS_OFFSET,     REG_RES_STATUS_LENGTH,     NETWORK_BYTE_ORDER);
851   proto_tree_add_item(parameter_tree, hf_registration_result_context,    parameter_tvb, REG_RES_CONTEXT_OFFSET,    REG_RES_CONTEXT_LENGTH,    NETWORK_BYTE_ORDER);
852 }
853
854 static void
855 dissect_registration_result_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, proto_tree *tree, proto_tree *parameter_tree)
856 {
857   tvbuff_t *parameters_tvb;
858   guint16 length, parameters_length;
859
860   length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET);
861   parameters_length = length - PARAMETER_HEADER_LENGTH;
862   parameters_tvb          = tvb_new_subset(parameter_tvb, PARAMETER_VALUE_OFFSET, parameters_length, parameters_length);
863   dissect_parameters(parameters_tvb, pinfo, tree, parameter_tree);
864 }
865
866 static const value_string v6_deregistration_result_status_values[] = {
867   { 0, "Successfully De-registered" } ,
868   { 1, "Error - Unknown" } ,
869   { 2, "Error - Invalid Routing context" } ,
870   { 3, "Error - Permission Denied" } ,
871   { 4, "Error - Not registered" } ,
872   { 0, NULL } };
873
874 #define DEREG_RES_CONTEXT_LENGTH 4
875 #define DEREG_RES_STATUS_LENGTH  4
876
877 #define DEREG_RES_CONTEXT_OFFSET PARAMETER_VALUE_OFFSET
878 #define DEREG_RES_STATUS_OFFSET  (DEREG_RES_CONTEXT_OFFSET + DEREG_RES_CONTEXT_LENGTH)
879
880 static void
881 dissect_v6_deregistration_result_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree)
882 {
883   proto_tree_add_item(parameter_tree, hf_v6_deregistration_result_context, parameter_tvb, DEREG_RES_CONTEXT_OFFSET, DEREG_RES_CONTEXT_LENGTH, NETWORK_BYTE_ORDER);
884   proto_tree_add_item(parameter_tree, hf_v6_deregistration_result_status,  parameter_tvb, DEREG_RES_STATUS_OFFSET,  DEREG_RES_STATUS_LENGTH,  NETWORK_BYTE_ORDER);
885 }
886
887 static void
888 dissect_deregistration_result_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, proto_tree *tree, proto_tree *parameter_tree)
889 {
890   tvbuff_t *parameters_tvb;
891   guint16 length, parameters_length;
892
893   length            = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET);
894   parameters_length = length - PARAMETER_HEADER_LENGTH;
895   parameters_tvb    = tvb_new_subset(parameter_tvb, PARAMETER_VALUE_OFFSET, parameters_length, parameters_length);
896   dissect_parameters(parameters_tvb, pinfo, tree, parameter_tree);
897 }
898
899
900 #define LOCAL_RK_IDENTIFIER_OFFSET PARAMETER_VALUE_OFFSET
901 #define LOCAL_RK_IDENTIFIER_LENGTH 4
902
903 static void
904 dissect_local_routing_key_identifier_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
905 {
906   guint32 id;
907
908   id = tvb_get_ntohl(parameter_tvb, LOCAL_RK_IDENTIFIER_OFFSET);
909   proto_tree_add_item(parameter_tree, hf_local_rk_identifier, parameter_tvb, LOCAL_RK_IDENTIFIER_OFFSET, LOCAL_RK_IDENTIFIER_LENGTH, NETWORK_BYTE_ORDER);
910   proto_item_append_text(parameter_item, " (%u)", tvb_get_ntohl(parameter_tvb, LOCAL_RK_IDENTIFIER_OFFSET));
911 }
912
913 #define DPC_MASK_LENGTH    1
914 #define DPC_PC_LENGTH      3
915
916 #define DPC_MASK_OFFSET    PARAMETER_VALUE_OFFSET
917 #define DPC_PC_OFFSET      (DPC_MASK_OFFSET + DPC_MASK_LENGTH)
918
919 static void
920 dissect_destination_point_code_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
921 {
922   proto_tree_add_item(parameter_tree, hf_dpc_mask, parameter_tvb, DPC_MASK_OFFSET, DPC_MASK_LENGTH, NETWORK_BYTE_ORDER);
923   proto_tree_add_item(parameter_tree, hf_dpc_pc,   parameter_tvb, DPC_PC_OFFSET,   DPC_PC_LENGTH,   NETWORK_BYTE_ORDER);
924   proto_item_append_text(parameter_item, " (%u)", tvb_get_ntoh24(parameter_tvb, DPC_PC_OFFSET));
925 }
926
927 #define SI_LENGTH 1
928
929 static void
930 dissect_service_indicators_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
931 {
932   guint16 length, number_of_sis, si_number;
933   gint si_offset;
934
935   length        = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET);
936   number_of_sis = length - PARAMETER_HEADER_LENGTH;
937
938   si_offset = PARAMETER_VALUE_OFFSET;
939   for(si_number=1; si_number <= number_of_sis; si_number++) {
940     proto_tree_add_item(parameter_tree, hf_si, parameter_tvb, si_offset, SI_LENGTH, NETWORK_BYTE_ORDER);
941     si_offset += SI_LENGTH;
942   };
943   proto_item_append_text(parameter_item, " (%u indicator%s)", number_of_sis, plurality(number_of_sis, "", "s"));
944
945 }
946 #define SSN_LENGTH 1
947
948 static void
949 dissect_subsystem_numbers_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
950 {
951   guint16 length, number_of_ssns, ssn_number;
952   gint ssn_offset;
953
954   length         = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET);
955   number_of_ssns = length - PARAMETER_HEADER_LENGTH;
956
957   ssn_offset = PARAMETER_VALUE_OFFSET;
958   for(ssn_number=1; ssn_number <= number_of_ssns; ssn_number++) {
959     proto_tree_add_item(parameter_tree, hf_ssn, parameter_tvb, ssn_offset, SSN_LENGTH, NETWORK_BYTE_ORDER);
960     ssn_offset += SSN_LENGTH;
961   };
962   proto_item_append_text(parameter_item, " (%u number%s)", number_of_ssns, plurality(number_of_ssns, "", "s"));
963
964 }
965
966 #define OPC_MASK_LENGTH             1
967 #define OPC_PC_LENGTH               3
968 #define OPC_LENGTH                  (OPC_MASK_LENGTH + OPC_PC_LENGTH)
969 #define OPC_MASK_OFFSET             0
970 #define OPC_PC_OFFSET               (OPC_MASK_OFFSET + OPC_MASK_LENGTH)
971
972 static void
973 dissect_originating_point_code_list_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
974 {
975   guint16 length, number_of_point_codes, point_code_number;
976   gint point_code_offset;
977
978   length                = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET);
979   number_of_point_codes = (length - PARAMETER_HEADER_LENGTH) / 4;
980
981   point_code_offset = PARAMETER_VALUE_OFFSET;
982   for(point_code_number=1; point_code_number <= number_of_point_codes; point_code_number++) {
983     proto_tree_add_item(parameter_tree, hf_opc_list_mask, parameter_tvb, point_code_offset + OPC_MASK_OFFSET, OPC_MASK_LENGTH, NETWORK_BYTE_ORDER);
984     proto_tree_add_item(parameter_tree, hf_opc_list_pc,   parameter_tvb, point_code_offset + OPC_PC_OFFSET,   OPC_PC_LENGTH,   NETWORK_BYTE_ORDER);
985     point_code_offset += OPC_LENGTH;
986   };
987   proto_item_append_text(parameter_item, " (%u point code%s)", number_of_point_codes, plurality(number_of_point_codes, "", "s"));
988 }
989
990 #define CIC_RANGE_MASK_LENGTH             1
991 #define CIC_RANGE_PC_LENGTH               3
992 #define CIC_RANGE_LOWER_LENGTH            2
993 #define CIC_RANGE_UPPER_LENGTH            2
994 #define CIC_RANGE_LENGTH                  (CIC_RANGE_MASK_LENGTH + CIC_RANGE_PC_LENGTH + CIC_RANGE_LOWER_LENGTH + CIC_RANGE_UPPER_LENGTH)
995 #define CIC_RANGE_MASK_OFFSET             0
996 #define CIC_RANGE_PC_OFFSET               (CIC_RANGE_MASK_OFFSET + CIC_RANGE_MASK_LENGTH)
997 #define CIC_RANGE_LOWER_OFFSET            (CIC_RANGE_PC_OFFSET + CIC_RANGE_PC_LENGTH)
998 #define CIC_RANGE_UPPER_OFFSET            (CIC_RANGE_LOWER_OFFSET + CIC_RANGE_LOWER_LENGTH)
999
1000 static void
1001 dissect_circuit_range_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
1002 {
1003   guint16 length, number_of_point_codes, point_code_number;
1004   gint point_code_offset;
1005
1006   length                = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET);
1007   number_of_point_codes = (length - PARAMETER_HEADER_LENGTH) / CIC_RANGE_LENGTH;
1008
1009   point_code_offset = PARAMETER_VALUE_OFFSET;
1010   for(point_code_number = 1; point_code_number <= number_of_point_codes; point_code_number++) {
1011     proto_tree_add_item(parameter_tree, hf_cic_range_mask,  parameter_tvb, point_code_offset + CIC_RANGE_MASK_OFFSET,  CIC_RANGE_MASK_LENGTH,  NETWORK_BYTE_ORDER);
1012     proto_tree_add_item(parameter_tree, hf_cic_range_pc,    parameter_tvb, point_code_offset + CIC_RANGE_PC_OFFSET,    CIC_RANGE_PC_LENGTH,    NETWORK_BYTE_ORDER);
1013     proto_tree_add_item(parameter_tree, hf_cic_range_lower, parameter_tvb, point_code_offset + CIC_RANGE_LOWER_OFFSET, CIC_RANGE_LOWER_LENGTH, NETWORK_BYTE_ORDER);
1014     proto_tree_add_item(parameter_tree, hf_cic_range_upper, parameter_tvb, point_code_offset + CIC_RANGE_UPPER_OFFSET, CIC_RANGE_UPPER_LENGTH, NETWORK_BYTE_ORDER);
1015     point_code_offset += CIC_RANGE_LENGTH;
1016   };
1017   proto_item_append_text(parameter_item, " (%u range%s)", number_of_point_codes, plurality(number_of_point_codes, "", "s"));
1018 }
1019
1020 #define DATA_OPC_LENGTH   4
1021 #define DATA_DPC_LENGTH   4
1022 #define DATA_SI_LENGTH    1
1023 #define DATA_NI_LENGTH    1
1024 #define DATA_MP_LENGTH    1
1025 #define DATA_SLS_LENGTH   1
1026 #define DATA_HDR_LENGTH   (DATA_OPC_LENGTH + DATA_DPC_LENGTH + DATA_SI_LENGTH + DATA_NI_LENGTH + DATA_MP_LENGTH + DATA_SLS_LENGTH)
1027
1028 #define DATA_OPC_OFFSET   PARAMETER_VALUE_OFFSET
1029 #define DATA_DPC_OFFSET   (DATA_OPC_OFFSET + DATA_OPC_LENGTH)
1030 #define DATA_SI_OFFSET    (DATA_DPC_OFFSET + DATA_DPC_LENGTH)
1031 #define DATA_NI_OFFSET    (DATA_SI_OFFSET  + DATA_SI_LENGTH)
1032 #define DATA_MP_OFFSET    (DATA_NI_OFFSET  + DATA_NI_LENGTH)
1033 #define DATA_SLS_OFFSET   (DATA_MP_OFFSET  + DATA_MP_LENGTH)
1034 #define DATA_ULP_OFFSET   (DATA_SLS_OFFSET + DATA_SLS_LENGTH)
1035
1036 static void
1037 dissect_protocol_data_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, proto_tree *tree, proto_tree *parameter_tree, proto_item *parameter_item)
1038 {
1039   guint16 ulp_length;
1040   tvbuff_t *payload_tvb;
1041
1042   ulp_length  = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH - DATA_HDR_LENGTH;
1043
1044   if (parameter_tree) {
1045     proto_tree_add_item(parameter_tree, hf_protocol_data_opc, parameter_tvb, DATA_OPC_OFFSET, DATA_OPC_LENGTH, NETWORK_BYTE_ORDER);
1046     proto_tree_add_item(parameter_tree, hf_protocol_data_dpc, parameter_tvb, DATA_DPC_OFFSET, DATA_DPC_LENGTH, NETWORK_BYTE_ORDER);
1047     proto_tree_add_item(parameter_tree, hf_protocol_data_si,  parameter_tvb, DATA_SI_OFFSET,  DATA_SI_LENGTH,  NETWORK_BYTE_ORDER);
1048     proto_tree_add_item(parameter_tree, hf_protocol_data_ni,  parameter_tvb, DATA_NI_OFFSET,  DATA_NI_LENGTH,  NETWORK_BYTE_ORDER);
1049     proto_tree_add_item(parameter_tree, hf_protocol_data_mp,  parameter_tvb, DATA_MP_OFFSET,  DATA_MP_LENGTH,  NETWORK_BYTE_ORDER);
1050     proto_tree_add_item(parameter_tree, hf_protocol_data_sls, parameter_tvb, DATA_SLS_OFFSET, DATA_SLS_LENGTH, NETWORK_BYTE_ORDER);
1051
1052     proto_item_append_text(parameter_item, " (SS7 message of %u byte%s)", ulp_length, plurality(ulp_length, "", "s"));
1053     proto_item_set_len(parameter_item, PARAMETER_HEADER_LENGTH + DATA_HDR_LENGTH);
1054   }
1055   
1056   payload_tvb = tvb_new_subset(parameter_tvb, DATA_ULP_OFFSET, ulp_length, ulp_length);
1057   if (!dissector_try_port(si_dissector_table, tvb_get_guint8(parameter_tvb, DATA_SI_OFFSET), payload_tvb, pinfo, tree))
1058     call_dissector(data_handle, payload_tvb, pinfo, tree);
1059 }
1060
1061 #define CORR_ID_OFFSET PARAMETER_VALUE_OFFSET
1062 #define CORR_ID_LENGTH 4
1063
1064 static void
1065 dissect_correlation_identifier_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
1066 {
1067   proto_tree_add_item(parameter_tree, hf_correlation_identifier, parameter_tvb, CORR_ID_OFFSET, CORR_ID_LENGTH, NETWORK_BYTE_ORDER);
1068   proto_item_append_text(parameter_item, " (%u)", tvb_get_ntohl(parameter_tvb, CORR_ID_OFFSET));
1069 }
1070
1071 #define REG_STATUS_LENGTH  4
1072 #define REG_STATUS_OFFSET  PARAMETER_VALUE_OFFSET
1073
1074 static const value_string registration_status_values[] = {
1075   {  0, "Successfully Registered" },
1076   {  1, "Error - Unknown" },
1077   {  2, "Error - Invalid DPC" },
1078   {  3, "Error - Invalid Network Appearance" },
1079   {  4, "Error - Invalid Routing Key" },
1080   {  5, "Error - Permission Denied" },
1081   {  6, "Error - Cannot Support Unique Routing" },
1082   {  7, "Error - Routing Key not Currently Provisioned" },
1083   {  8, "Error - Insufficient Resources" },
1084   {  9, "Error - Unsupported RK parameter Field" },
1085   { 10, "Error - Unsupported/Invalid Traffic Handling Mode" },
1086   {  0, NULL } };
1087
1088 static void
1089 dissect_registration_status_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
1090 {
1091   proto_tree_add_item(parameter_tree, hf_registration_status, parameter_tvb, REG_STATUS_OFFSET, REG_STATUS_LENGTH, NETWORK_BYTE_ORDER);
1092   proto_item_append_text(parameter_item, " (%s)", val_to_str(tvb_get_ntohl(parameter_tvb, REG_STATUS_OFFSET), registration_status_values, "unknown"));
1093 }
1094
1095 #define DEREG_STATUS_LENGTH  4
1096 #define DEREG_STATUS_OFFSET  PARAMETER_VALUE_OFFSET
1097
1098 static const value_string deregistration_status_values[] = {
1099   { 0, "Successfully Deregistered" },
1100   { 1, "Error - Unknown" },
1101   { 2, "Error - Invalid Routing Context" },
1102   { 3, "Error - Permission Denied" },
1103   { 4, "Error - Not Registered" },
1104   { 5, "Error - ASP Currently Active for Routing Context" },
1105   { 0, NULL } };
1106
1107 static void
1108 dissect_deregistration_status_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
1109 {
1110   proto_tree_add_item(parameter_tree, hf_deregistration_status, parameter_tvb, DEREG_STATUS_OFFSET, DEREG_STATUS_LENGTH, NETWORK_BYTE_ORDER);
1111   proto_item_append_text(parameter_item, " (%s)", val_to_str(tvb_get_ntohl(parameter_tvb, DEREG_STATUS_OFFSET), deregistration_status_values, "unknown"));
1112 }
1113
1114 static void
1115 dissect_registration_results_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, proto_tree *tree, proto_tree *parameter_tree)
1116 {
1117   tvbuff_t *parameters_tvb;
1118   guint16 parameters_length;
1119
1120   parameters_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH;
1121   parameters_tvb    = tvb_new_subset(parameter_tvb, PARAMETER_VALUE_OFFSET, parameters_length, parameters_length);
1122   dissect_parameters(parameters_tvb, pinfo, tree, parameter_tree);
1123 }
1124
1125 static void
1126 dissect_deregistration_results_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, proto_tree *tree, proto_tree *parameter_tree)
1127 {
1128   tvbuff_t *parameters_tvb;
1129   guint16 parameters_length;
1130
1131   parameters_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH;
1132   parameters_tvb    = tvb_new_subset(parameter_tvb, PARAMETER_VALUE_OFFSET, parameters_length, parameters_length);
1133   dissect_parameters(parameters_tvb, pinfo, tree, parameter_tree);
1134 }
1135
1136 static void
1137 dissect_unknown_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
1138 {
1139   guint16 tag, parameter_value_length;
1140
1141   tag                    = tvb_get_ntohs(parameter_tvb, PARAMETER_TAG_OFFSET);
1142   parameter_value_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH;
1143   proto_tree_add_item(parameter_tree, hf_parameter_value, parameter_tvb, PARAMETER_VALUE_OFFSET, parameter_value_length, NETWORK_BYTE_ORDER);
1144   proto_item_append_text(parameter_item, " (tag %u and %u byte%s value)", tag, parameter_value_length, plurality(parameter_value_length, "", "s"));
1145 }
1146
1147 #define V5_NETWORK_APPEARANCE_PARAMETER_TAG       1
1148 #define V5_PROTOCOL_DATA_PARAMETER_TAG            3
1149 #define V5_INFO_PARAMETER_TAG                     4
1150 #define V5_AFFECTED_DESTINATIONS_PARAMETER_TAG    5
1151 #define V5_ROUTING_CONTEXT_PARAMETER_TAG          6
1152 #define V5_DIAGNOSTIC_INFORMATION_PARAMETER_TAG   7
1153 #define V5_HEARTBEAT_DATA_PARAMETER_TAG           8
1154 #define V5_USER_CAUSE_PARAMETER_TAG               9
1155 #define V5_REASON_PARAMETER_TAG                   10
1156 #define V5_TRAFFIC_MODE_TYPE_PARAMETER_TAG        11
1157 #define V5_ERROR_CODE_PARAMETER_TAG               12
1158 #define V5_STATUS_PARAMETER_TAG                   13
1159 #define V5_CONGESTION_INDICATION_PARAMETER_TAG    14
1160
1161 static const value_string v5_parameter_tag_values[] = {
1162   { V5_NETWORK_APPEARANCE_PARAMETER_TAG,     "Network appearance" },
1163   { V5_PROTOCOL_DATA_PARAMETER_TAG,          "Protocol data" },
1164   { V5_INFO_PARAMETER_TAG,                   "Info" },
1165   { V5_AFFECTED_DESTINATIONS_PARAMETER_TAG,  "Affected destinations" },
1166   { V5_ROUTING_CONTEXT_PARAMETER_TAG,        "Routing context" },
1167   { V5_DIAGNOSTIC_INFORMATION_PARAMETER_TAG, "Diagnostic information" },
1168   { V5_HEARTBEAT_DATA_PARAMETER_TAG,         "Heartbeat data" },
1169   { V5_USER_CAUSE_PARAMETER_TAG,             "User / Cause" },
1170   { V5_REASON_PARAMETER_TAG,                 "Reason" },
1171   { V5_TRAFFIC_MODE_TYPE_PARAMETER_TAG,      "Traffic mode type" },
1172   { V5_ERROR_CODE_PARAMETER_TAG,             "Error code" },
1173   { V5_STATUS_PARAMETER_TAG,                 "Status" },
1174   { V5_CONGESTION_INDICATION_PARAMETER_TAG,  "Congestion indication" },
1175   { 0,                                       NULL } };
1176
1177 static void
1178 dissect_v5_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, proto_tree *tree, proto_tree *m3ua_tree)
1179 {
1180   guint16 tag, length, padding_length;
1181   proto_item *parameter_item;
1182   proto_tree *parameter_tree;
1183
1184   /* extract tag and length from the parameter */
1185   tag            = tvb_get_ntohs(parameter_tvb, PARAMETER_TAG_OFFSET);
1186   length         = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET);
1187   padding_length = tvb_length(parameter_tvb) - length;
1188
1189   if (!tree && tag != V5_PROTOCOL_DATA_PARAMETER_TAG)
1190     return;     /* Nothing to do here */
1191
1192   /* create proto_tree stuff */
1193   parameter_item   = proto_tree_add_text(m3ua_tree, parameter_tvb, PARAMETER_HEADER_OFFSET, tvb_length(parameter_tvb), val_to_str(tag, v5_parameter_tag_values, "Unknown parameter"));
1194   parameter_tree   = proto_item_add_subtree(parameter_item, ett_parameter);
1195
1196   /* add tag and length to the parameter tree */
1197   proto_tree_add_item(parameter_tree, hf_v5_parameter_tag, parameter_tvb, PARAMETER_TAG_OFFSET,    PARAMETER_TAG_LENGTH,    NETWORK_BYTE_ORDER);
1198   proto_tree_add_item(parameter_tree, hf_parameter_length, parameter_tvb, PARAMETER_LENGTH_OFFSET, PARAMETER_LENGTH_LENGTH, NETWORK_BYTE_ORDER);
1199
1200   switch(tag) {
1201   case V5_NETWORK_APPEARANCE_PARAMETER_TAG:
1202     dissect_network_appearance_parameter(parameter_tvb, parameter_tree, parameter_item);
1203     break;
1204   case V5_PROTOCOL_DATA_PARAMETER_TAG:
1205     dissect_v5_protocol_data_parameter(parameter_tvb, pinfo, tree, parameter_item);
1206     break;
1207   case V5_INFO_PARAMETER_TAG:
1208     dissect_info_string_parameter(parameter_tvb, parameter_tree, parameter_item);
1209     break;
1210   case V5_AFFECTED_DESTINATIONS_PARAMETER_TAG:
1211     dissect_affected_destinations_parameter(parameter_tvb, parameter_tree, parameter_item);
1212     break;
1213   case V5_ROUTING_CONTEXT_PARAMETER_TAG:
1214     dissect_routing_context_parameter(parameter_tvb, parameter_tree, parameter_item);
1215     break;
1216   case V5_DIAGNOSTIC_INFORMATION_PARAMETER_TAG:
1217     dissect_diagnostic_information_parameter(parameter_tvb, parameter_tree, parameter_item);
1218     break;
1219   case V5_HEARTBEAT_DATA_PARAMETER_TAG:
1220     dissect_heartbeat_data_parameter(parameter_tvb, parameter_tree, parameter_item);
1221     break;
1222   case V5_USER_CAUSE_PARAMETER_TAG:
1223     dissect_user_cause_parameter(parameter_tvb, parameter_tree, parameter_item);
1224     break;
1225   case V5_REASON_PARAMETER_TAG:
1226     dissect_reason_parameter(parameter_tvb, parameter_tree, parameter_item);
1227     break;
1228   case V5_TRAFFIC_MODE_TYPE_PARAMETER_TAG:
1229     dissect_v5_traffic_mode_type_parameter(parameter_tvb, parameter_tree, parameter_item);
1230     break;
1231   case V5_ERROR_CODE_PARAMETER_TAG:
1232     dissect_v5_error_code_parameter(parameter_tvb, parameter_tree, parameter_item);
1233     break;
1234   case V5_STATUS_PARAMETER_TAG:
1235     dissect_v56_status_parameter(parameter_tvb, parameter_tree, parameter_item);
1236     break;
1237   case V5_CONGESTION_INDICATION_PARAMETER_TAG:
1238     dissect_congestion_indication_parameter(parameter_tvb, parameter_tree, parameter_item);
1239     break;
1240   default:
1241     dissect_unknown_parameter(parameter_tvb, parameter_tree, parameter_item);
1242     break;
1243   };
1244   if (padding_length > 0)
1245     proto_tree_add_item(parameter_tree, hf_parameter_padding, parameter_tvb, PARAMETER_HEADER_OFFSET + length, padding_length, NETWORK_BYTE_ORDER);
1246 }
1247
1248 #define V6_NETWORK_APPEARANCE_PARAMETER_TAG            1
1249 #define V6_PROTOCOL_DATA_1_PARAMETER_TAG               2
1250 #define V6_PROTOCOL_DATA_2_PARAMETER_TAG               3
1251 #define V6_INFO_PARAMETER_TAG                          4
1252 #define V6_AFFECTED_DESTINATIONS_PARAMETER_TAG         5
1253 #define V6_ROUTING_CONTEXT_PARAMETER_TAG               6
1254 #define V6_DIAGNOSTIC_INFORMATION_PARAMETER_TAG        7
1255 #define V6_HEARTBEAT_DATA_PARAMETER_TAG                8
1256 #define V6_USER_CAUSE_PARAMETER_TAG                    9
1257 #define V6_REASON_PARAMETER_TAG                       10
1258 #define V6_TRAFFIC_MODE_TYPE_PARAMETER_TAG            11
1259 #define V6_ERROR_CODE_PARAMETER_TAG                   12
1260 #define V6_STATUS_PARAMETER_TAG                       13
1261 #define V6_CONGESTION_INDICATION_PARAMETER_TAG        14
1262 #define V6_CONCERNED_DESTINATION_PARAMETER_TAG        15
1263 #define V6_ROUTING_KEY_PARAMETER_TAG                  16
1264 #define V6_REGISTRATION_RESULT_PARAMETER_TAG          17
1265 #define V6_DEREGISTRATION_RESULT_PARAMETER_TAG        18
1266 #define V6_LOCAL_ROUTING_KEY_IDENTIFIER_PARAMETER_TAG 19
1267 #define V6_DESTINATION_POINT_CODE_PARAMETER_TAG       20
1268 #define V6_SERVICE_INDICATORS_PARAMETER_TAG           21
1269 #define V6_SUBSYSTEM_NUMBERS_PARAMETER_TAG            22
1270 #define V6_ORIGINATING_POINT_CODE_LIST_PARAMETER_TAG  23
1271 #define V6_CIRCUIT_RANGE_PARAMETER_TAG                24
1272 #define V6_REGISTRATION_RESULTS_PARAMETER_TAG         25
1273 #define V6_DEREGISTRATION_RESULTS_PARAMETER_TAG       26
1274
1275 static const value_string v6_parameter_tag_values[] = {
1276   { V6_NETWORK_APPEARANCE_PARAMETER_TAG,           "Network appearance" },
1277   { V6_PROTOCOL_DATA_1_PARAMETER_TAG,              "Protocol data 1" },
1278   { V6_PROTOCOL_DATA_2_PARAMETER_TAG,              "Protocol data 2" },
1279   { V6_INFO_PARAMETER_TAG,                         "Info" },
1280   { V6_AFFECTED_DESTINATIONS_PARAMETER_TAG,        "Affected destinations" },
1281   { V6_ROUTING_CONTEXT_PARAMETER_TAG,              "Routing context" },
1282   { V6_DIAGNOSTIC_INFORMATION_PARAMETER_TAG,       "Diagnostic information" },
1283   { V6_HEARTBEAT_DATA_PARAMETER_TAG,               "Heartbeat data" },
1284   { V6_USER_CAUSE_PARAMETER_TAG,                   "User / Cause" },
1285   { V6_REASON_PARAMETER_TAG,                       "Reason" },
1286   { V6_TRAFFIC_MODE_TYPE_PARAMETER_TAG,            "Traffic mode type" },
1287   { V6_ERROR_CODE_PARAMETER_TAG,                   "Error code" },
1288   { V6_STATUS_PARAMETER_TAG,                       "Status" },
1289   { V6_CONGESTION_INDICATION_PARAMETER_TAG,        "Congestion indication" },
1290   { V6_CONCERNED_DESTINATION_PARAMETER_TAG,        "Concerned destination" },
1291   { V6_ROUTING_KEY_PARAMETER_TAG,                  "Routing Key" },
1292   { V6_REGISTRATION_RESULT_PARAMETER_TAG,          "Registration result" },
1293   { V6_DEREGISTRATION_RESULT_PARAMETER_TAG,        "De-registration result" },
1294   { V6_LOCAL_ROUTING_KEY_IDENTIFIER_PARAMETER_TAG, "Local routing key identifier" },
1295   { V6_DESTINATION_POINT_CODE_PARAMETER_TAG,       "Destination point code" },
1296   { V6_SERVICE_INDICATORS_PARAMETER_TAG,           "Service indicators" },
1297   { V6_SUBSYSTEM_NUMBERS_PARAMETER_TAG,            "Subsystem numbers" },
1298   { V6_ORIGINATING_POINT_CODE_LIST_PARAMETER_TAG,  "Originating point code list" },
1299   { V6_CIRCUIT_RANGE_PARAMETER_TAG,                "Circuit range" },
1300   { V6_REGISTRATION_RESULTS_PARAMETER_TAG,         "Registration results" },
1301   { V6_DEREGISTRATION_RESULTS_PARAMETER_TAG,       "De-registration results" },
1302   { 0,                           NULL } };
1303   
1304 static void
1305 dissect_v6_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, proto_tree *tree, proto_tree *m3ua_tree)
1306 {
1307   guint16 tag, length, padding_length;
1308   proto_item *parameter_item;
1309   proto_tree *parameter_tree;
1310
1311   /* extract tag and length from the parameter */
1312   tag            = tvb_get_ntohs(parameter_tvb, PARAMETER_TAG_OFFSET);
1313   length         = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET);
1314   padding_length = tvb_length(parameter_tvb) - length;
1315
1316   if (!tree && tag != V6_PROTOCOL_DATA_1_PARAMETER_TAG && tag != V6_PROTOCOL_DATA_2_PARAMETER_TAG)
1317     return;     /* Nothing to do here */
1318
1319   /* create proto_tree stuff */
1320   parameter_item   = proto_tree_add_text(m3ua_tree, parameter_tvb, PARAMETER_HEADER_OFFSET, tvb_length(parameter_tvb), val_to_str(tag, v6_parameter_tag_values, "Unknown parameter"));
1321   parameter_tree   = proto_item_add_subtree(parameter_item, ett_parameter);
1322
1323   /* add tag and length to the parameter tree */
1324   proto_tree_add_item(parameter_tree, hf_v6_parameter_tag, parameter_tvb, PARAMETER_TAG_OFFSET,    PARAMETER_TAG_LENGTH,    NETWORK_BYTE_ORDER);
1325   proto_tree_add_item(parameter_tree, hf_parameter_length, parameter_tvb, PARAMETER_LENGTH_OFFSET, PARAMETER_LENGTH_LENGTH, NETWORK_BYTE_ORDER);
1326
1327   switch(tag) {
1328   case V6_NETWORK_APPEARANCE_PARAMETER_TAG:
1329     dissect_network_appearance_parameter(parameter_tvb, parameter_tree, parameter_item);
1330     break;
1331   case V6_PROTOCOL_DATA_1_PARAMETER_TAG:
1332     dissect_protocol_data_1_parameter(parameter_tvb, pinfo, tree, parameter_item);
1333     break;
1334   case V6_PROTOCOL_DATA_2_PARAMETER_TAG:
1335     dissect_protocol_data_2_parameter(parameter_tvb, pinfo, tree, parameter_tree, parameter_item);
1336     break;
1337   case V6_INFO_PARAMETER_TAG:
1338     dissect_info_string_parameter(parameter_tvb, parameter_tree, parameter_item);
1339     break;
1340   case V6_AFFECTED_DESTINATIONS_PARAMETER_TAG:
1341     dissect_affected_destinations_parameter(parameter_tvb, parameter_tree, parameter_item);
1342     break;
1343   case V6_ROUTING_CONTEXT_PARAMETER_TAG:
1344     dissect_routing_context_parameter(parameter_tvb, parameter_tree, parameter_item);
1345     break;
1346   case V6_DIAGNOSTIC_INFORMATION_PARAMETER_TAG:
1347     dissect_diagnostic_information_parameter(parameter_tvb, parameter_tree, parameter_item);
1348     break;
1349   case V6_HEARTBEAT_DATA_PARAMETER_TAG:
1350     dissect_heartbeat_data_parameter(parameter_tvb, parameter_tree, parameter_item);
1351     break;
1352   case V6_USER_CAUSE_PARAMETER_TAG:
1353     dissect_user_cause_parameter(parameter_tvb, parameter_tree, parameter_item);
1354     break;
1355   case V6_REASON_PARAMETER_TAG:
1356     dissect_reason_parameter(parameter_tvb, parameter_tree, parameter_item);
1357     break;
1358   case V6_TRAFFIC_MODE_TYPE_PARAMETER_TAG:
1359     dissect_v6_traffic_mode_type_parameter(parameter_tvb, parameter_tree, parameter_item);
1360     break;
1361   case V6_ERROR_CODE_PARAMETER_TAG:
1362     dissect_v6_error_code_parameter(parameter_tvb, parameter_tree, parameter_item);
1363     break;
1364   case V6_STATUS_PARAMETER_TAG:
1365     dissect_v56_status_parameter(parameter_tvb, parameter_tree, parameter_item);
1366     break;
1367   case V6_CONGESTION_INDICATION_PARAMETER_TAG:
1368     dissect_congestion_indication_parameter(parameter_tvb, parameter_tree, parameter_item);
1369     break;
1370   case V6_CONCERNED_DESTINATION_PARAMETER_TAG:
1371     dissect_concerned_destination_parameter(parameter_tvb, parameter_tree, parameter_item);
1372     break;
1373   case V6_ROUTING_KEY_PARAMETER_TAG:
1374     dissect_routing_key_parameter(parameter_tvb, pinfo, tree, parameter_tree);
1375     break;
1376   case V6_REGISTRATION_RESULT_PARAMETER_TAG:
1377     dissect_v6_registration_result_parameter(parameter_tvb, parameter_tree);
1378     break;
1379   case V6_DEREGISTRATION_RESULT_PARAMETER_TAG:
1380     dissect_v6_deregistration_result_parameter(parameter_tvb, parameter_tree);
1381     break;
1382   case V6_LOCAL_ROUTING_KEY_IDENTIFIER_PARAMETER_TAG:
1383     dissect_local_routing_key_identifier_parameter(parameter_tvb, parameter_tree, parameter_item);
1384     break;
1385   case V6_DESTINATION_POINT_CODE_PARAMETER_TAG:
1386     dissect_destination_point_code_parameter(parameter_tvb, parameter_tree, parameter_item);
1387     break;
1388   case V6_SERVICE_INDICATORS_PARAMETER_TAG:
1389     dissect_service_indicators_parameter(parameter_tvb, parameter_tree, parameter_item);
1390     break;
1391   case V6_SUBSYSTEM_NUMBERS_PARAMETER_TAG:
1392     dissect_subsystem_numbers_parameter(parameter_tvb, parameter_tree, parameter_item);
1393     break;
1394   case V6_ORIGINATING_POINT_CODE_LIST_PARAMETER_TAG:
1395     dissect_originating_point_code_list_parameter(parameter_tvb, parameter_tree, parameter_item);
1396     break;
1397   case V6_CIRCUIT_RANGE_PARAMETER_TAG:
1398     dissect_circuit_range_parameter(parameter_tvb, parameter_tree, parameter_item);
1399     break;
1400   case V6_REGISTRATION_RESULTS_PARAMETER_TAG:
1401     dissect_registration_results_parameter(parameter_tvb, pinfo, tree, parameter_tree);
1402     break;
1403   case V6_DEREGISTRATION_RESULTS_PARAMETER_TAG:
1404     dissect_deregistration_results_parameter(parameter_tvb, pinfo, tree, parameter_tree);
1405     break;
1406   default:
1407     dissect_unknown_parameter(parameter_tvb, parameter_tree, parameter_item);
1408     break;
1409   };
1410
1411   if (padding_length > 0)
1412     proto_tree_add_item(parameter_tree, hf_parameter_padding, parameter_tvb, PARAMETER_HEADER_OFFSET + length, padding_length, NETWORK_BYTE_ORDER);
1413 }
1414
1415 #define INFO_STRING_PARAMETER_TAG                  0x0004
1416 #define ROUTING_CONTEXT_PARAMETER_TAG              0x0006
1417 #define DIAGNOSTIC_INFORMATION_PARAMETER_TAG       0x0007
1418 #define HEARTBEAT_DATA_PARAMETER_TAG               0x0009
1419 #define TRAFFIC_MODE_TYPE_PARAMETER_TAG            0x000b
1420 #define ERROR_CODE_PARAMETER_TAG                   0x000c
1421 #define STATUS_PARAMETER_TAG                       0x000d
1422 #define ASP_IDENTIFIER_PARAMETER_TAG               0x0011
1423 #define AFFECTED_POINT_CODE_PARAMETER_TAG          0x0012
1424 #define CORRELATION_IDENTIFIER_PARAMETER_TAG       0x0013
1425
1426 #define NETWORK_APPEARANCE_PARAMETER_TAG           0x0200
1427 #define USER_CAUSE_PARAMETER_TAG                   0x0204
1428 #define CONGESTION_INDICATIONS_PARAMETER_TAG       0x0205
1429 #define CONCERNED_DESTINATION_PARAMETER_TAG        0x0206
1430 #define ROUTING_KEY_PARAMETER_TAG                  0x0207
1431 #define REGISTRATION_RESULT_PARAMETER_TAG          0x0208
1432 #define DEREGISTRATION_RESULT_PARAMETER_TAG        0x0209
1433 #define LOCAL_ROUTING_KEY_IDENTIFIER_PARAMETER_TAG 0x020a
1434 #define DESTINATION_POINT_CODE_PARAMETER_TAG       0x020b
1435 #define SERVICE_INDICATORS_PARAMETER_TAG           0x020c
1436 #define ORIGINATING_POINT_CODE_LIST_PARAMETER_TAG  0x020e
1437 #define CIRCUIT_RANGE_PARAMETER_TAG                0x020f
1438 #define PROTOCOL_DATA_PARAMETER_TAG                0x0210
1439 #define REGISTRATION_STATUS_PARAMETER_TAG          0x0212
1440 #define DEREGISTRATION_STATUS_PARAMETER_TAG        0x0213
1441
1442 static const value_string parameter_tag_values[] = {
1443   { INFO_STRING_PARAMETER_TAG,                  "Info string" } ,
1444   { ROUTING_CONTEXT_PARAMETER_TAG,              "Routing context" } ,
1445   { DIAGNOSTIC_INFORMATION_PARAMETER_TAG,       "Diagnostic Information" } ,
1446   { HEARTBEAT_DATA_PARAMETER_TAG,               "Heartbeat data" } ,
1447   { TRAFFIC_MODE_TYPE_PARAMETER_TAG,            "Traffic mode type" } ,
1448   { ERROR_CODE_PARAMETER_TAG,                   "Error code" } ,
1449   { STATUS_PARAMETER_TAG,                       "Status" } ,
1450   { ASP_IDENTIFIER_PARAMETER_TAG,               "ASP identifier" } ,
1451   { AFFECTED_POINT_CODE_PARAMETER_TAG,          "Affected point code" } ,
1452   { CORRELATION_IDENTIFIER_PARAMETER_TAG,       "Correlation identifier" } ,
1453   { NETWORK_APPEARANCE_PARAMETER_TAG,           "Network appearance" } ,
1454   { USER_CAUSE_PARAMETER_TAG,                   "User / cause" } ,
1455   { CONGESTION_INDICATIONS_PARAMETER_TAG,       "Congestion indications" } ,
1456   { CONCERNED_DESTINATION_PARAMETER_TAG,        "Concerned destination" } ,
1457   { ROUTING_KEY_PARAMETER_TAG,                  "Routing key" } ,
1458   { REGISTRATION_RESULT_PARAMETER_TAG,          "Registration result" } ,
1459   { DEREGISTRATION_RESULT_PARAMETER_TAG,        "Deregistration result" } ,
1460   { LOCAL_ROUTING_KEY_IDENTIFIER_PARAMETER_TAG, "Local routing key identifier" } ,
1461   { DESTINATION_POINT_CODE_PARAMETER_TAG,       "Destination point code" } ,
1462   { SERVICE_INDICATORS_PARAMETER_TAG,           "Service indicators" } ,
1463   { ORIGINATING_POINT_CODE_LIST_PARAMETER_TAG,  "Originating point code list" } ,
1464   { CIRCUIT_RANGE_PARAMETER_TAG,                "Circuit range" } ,
1465   { PROTOCOL_DATA_PARAMETER_TAG,                "Protocol data" } ,
1466   { REGISTRATION_STATUS_PARAMETER_TAG,          "Registration status" } ,
1467   { DEREGISTRATION_STATUS_PARAMETER_TAG,        "Deregistration status" } ,
1468   { 0,                           NULL } };
1469
1470 static void
1471 dissect_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, proto_tree *tree, proto_tree *m3ua_tree)
1472 {
1473   guint16 tag, length, padding_length;
1474   proto_item *parameter_item;
1475   proto_tree *parameter_tree;
1476
1477   /* extract tag and length from the parameter */
1478   tag            = tvb_get_ntohs(parameter_tvb, PARAMETER_TAG_OFFSET);
1479   length         = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET);
1480   padding_length = tvb_length(parameter_tvb) - length;
1481
1482
1483   if (!tree && tag != PROTOCOL_DATA_PARAMETER_TAG)
1484     return;     /* Nothing to do here */
1485
1486   /* create proto_tree stuff */
1487   parameter_item   = proto_tree_add_text(m3ua_tree, parameter_tvb, PARAMETER_HEADER_OFFSET, tvb_length(parameter_tvb), val_to_str(tag, parameter_tag_values, "Unknown parameter"));
1488   parameter_tree   = proto_item_add_subtree(parameter_item, ett_parameter);
1489
1490   /* add tag and length to the parameter tree */
1491   proto_tree_add_item(parameter_tree, hf_parameter_tag,    parameter_tvb, PARAMETER_TAG_OFFSET,    PARAMETER_TAG_LENGTH,    NETWORK_BYTE_ORDER);
1492   proto_tree_add_item(parameter_tree, hf_parameter_length, parameter_tvb, PARAMETER_LENGTH_OFFSET, PARAMETER_LENGTH_LENGTH, NETWORK_BYTE_ORDER);
1493
1494   switch(tag) {
1495   case INFO_STRING_PARAMETER_TAG:
1496     dissect_info_string_parameter(parameter_tvb, parameter_tree, parameter_item);
1497     break;
1498   case ROUTING_CONTEXT_PARAMETER_TAG:
1499     dissect_routing_context_parameter(parameter_tvb, parameter_tree, parameter_item);
1500     break;
1501   case DIAGNOSTIC_INFORMATION_PARAMETER_TAG:
1502     dissect_diagnostic_information_parameter(parameter_tvb, parameter_tree, parameter_item);
1503     break;
1504   case HEARTBEAT_DATA_PARAMETER_TAG:
1505     dissect_heartbeat_data_parameter(parameter_tvb, parameter_tree, parameter_item);
1506     break;
1507   case TRAFFIC_MODE_TYPE_PARAMETER_TAG:
1508     dissect_traffic_mode_type_parameter(parameter_tvb, parameter_tree, parameter_item);
1509     break;
1510   case ERROR_CODE_PARAMETER_TAG:
1511     dissect_error_code_parameter(parameter_tvb, parameter_tree, parameter_item);
1512     break;
1513   case STATUS_PARAMETER_TAG:
1514     dissect_status_parameter(parameter_tvb, parameter_tree, parameter_item);
1515     break;
1516   case ASP_IDENTIFIER_PARAMETER_TAG:
1517     dissect_asp_identifier_parameter(parameter_tvb, parameter_tree, parameter_item);
1518     break;
1519   case AFFECTED_POINT_CODE_PARAMETER_TAG:
1520     dissect_affected_destinations_parameter(parameter_tvb, parameter_tree, parameter_item);
1521     break;
1522   case NETWORK_APPEARANCE_PARAMETER_TAG:
1523     dissect_network_appearance_parameter(parameter_tvb, parameter_tree, parameter_item);
1524     break;
1525   case USER_CAUSE_PARAMETER_TAG:
1526     dissect_user_cause_parameter(parameter_tvb, parameter_tree, parameter_item);
1527     break;
1528   case CONGESTION_INDICATIONS_PARAMETER_TAG:
1529     dissect_congestion_indication_parameter(parameter_tvb, parameter_tree, parameter_item);
1530     break;
1531   case CONCERNED_DESTINATION_PARAMETER_TAG:
1532     dissect_concerned_destination_parameter(parameter_tvb, parameter_tree, parameter_item);
1533     break;
1534   case ROUTING_KEY_PARAMETER_TAG:
1535     dissect_routing_key_parameter(parameter_tvb, pinfo, tree, parameter_tree);
1536     break;
1537   case REGISTRATION_RESULT_PARAMETER_TAG:
1538     dissect_registration_result_parameter(parameter_tvb, pinfo, tree, parameter_tree);
1539     break;
1540   case DEREGISTRATION_RESULT_PARAMETER_TAG:
1541     dissect_deregistration_result_parameter(parameter_tvb, pinfo, tree, parameter_tree);
1542     break;
1543   case LOCAL_ROUTING_KEY_IDENTIFIER_PARAMETER_TAG:
1544     dissect_local_routing_key_identifier_parameter(parameter_tvb, parameter_tree, parameter_item);
1545     break;
1546   case DESTINATION_POINT_CODE_PARAMETER_TAG:
1547     dissect_destination_point_code_parameter(parameter_tvb, parameter_tree, parameter_item);
1548     break;
1549   case SERVICE_INDICATORS_PARAMETER_TAG:
1550     dissect_service_indicators_parameter(parameter_tvb, parameter_tree, parameter_item);
1551     break;
1552   case ORIGINATING_POINT_CODE_LIST_PARAMETER_TAG:
1553     dissect_originating_point_code_list_parameter(parameter_tvb, parameter_tree, parameter_item);
1554     break;
1555   case CIRCUIT_RANGE_PARAMETER_TAG:
1556     dissect_circuit_range_parameter(parameter_tvb, parameter_tree, parameter_item);
1557     break;
1558   case PROTOCOL_DATA_PARAMETER_TAG:
1559     dissect_protocol_data_parameter(parameter_tvb, pinfo, tree, parameter_tree, parameter_item);
1560     break;
1561   case CORRELATION_IDENTIFIER_PARAMETER_TAG:
1562     dissect_correlation_identifier_parameter(parameter_tvb, parameter_tree, parameter_item);
1563     break;
1564   case REGISTRATION_STATUS_PARAMETER_TAG:
1565     dissect_registration_status_parameter(parameter_tvb, parameter_tree, parameter_item);
1566     break;
1567   case DEREGISTRATION_STATUS_PARAMETER_TAG:
1568     dissect_deregistration_status_parameter(parameter_tvb, parameter_tree, parameter_item);
1569     break;
1570   default:
1571     dissect_unknown_parameter(parameter_tvb, parameter_tree, parameter_item);
1572     break;
1573   };
1574
1575   if (padding_length > 0)
1576     proto_tree_add_item(parameter_tree, hf_parameter_padding, parameter_tvb, PARAMETER_HEADER_OFFSET + length, padding_length, NETWORK_BYTE_ORDER);
1577 }
1578
1579 static void
1580 dissect_parameters(tvbuff_t *parameters_tvb, packet_info *pinfo, proto_tree *tree, proto_tree *m3ua_tree)
1581 {
1582   gint offset, length, total_length, remaining_length;
1583   tvbuff_t *parameter_tvb;
1584
1585   offset = 0;
1586   while((remaining_length = tvb_length_remaining(parameters_tvb, offset))) {
1587     length       = tvb_get_ntohs(parameters_tvb, offset + PARAMETER_LENGTH_OFFSET);
1588     total_length = ADD_PADDING(length);
1589     if (remaining_length >= length)
1590       total_length = MIN(total_length, remaining_length);
1591     /* create a tvb for the parameter including the padding bytes */
1592     parameter_tvb    = tvb_new_subset(parameters_tvb, offset, total_length, total_length);
1593     switch(version) {
1594       case M3UA_V5:
1595         dissect_v5_parameter(parameter_tvb, pinfo, tree, m3ua_tree);
1596         break;
1597       case M3UA_V6:
1598         dissect_v6_parameter(parameter_tvb, pinfo, tree, m3ua_tree);
1599         break;
1600       case M3UA_RFC:
1601         dissect_parameter(parameter_tvb, pinfo, tree, m3ua_tree);
1602         break;
1603     }
1604     /* get rid of the handled parameter */
1605     offset += total_length;
1606   }
1607 }
1608
1609
1610 static void
1611 dissect_message(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *tree, proto_tree *m3ua_tree)
1612 {
1613   tvbuff_t *common_header_tvb, *parameters_tvb;
1614
1615   common_header_tvb = tvb_new_subset(message_tvb, 0, COMMON_HEADER_LENGTH, COMMON_HEADER_LENGTH);
1616   parameters_tvb    = tvb_new_subset(message_tvb, COMMON_HEADER_LENGTH, -1, -1);
1617   if (version == M3UA_V5)
1618         dissect_v5_common_header(common_header_tvb, pinfo, m3ua_tree);
1619   else
1620     dissect_common_header(common_header_tvb, pinfo, m3ua_tree);
1621
1622   /*  Need to dissect (certain) parameters even when !tree, so subdissectors
1623    *  (e.g., MTP3) are always called.
1624    */
1625   dissect_parameters(parameters_tvb, pinfo, tree, m3ua_tree);
1626 }
1627
1628 static void
1629 dissect_m3ua(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *tree)
1630 {
1631   proto_item *m3ua_item;
1632   proto_tree *m3ua_tree;
1633
1634   /* make entry in the Protocol column on summary display */
1635   if (check_col(pinfo->cinfo, COL_PROTOCOL))
1636     switch(version) {
1637       case M3UA_V5:
1638         col_set_str(pinfo->cinfo, COL_PROTOCOL, "M3UA (ID 05)");
1639         break;
1640       case M3UA_V6:
1641         col_set_str(pinfo->cinfo, COL_PROTOCOL, "M3UA (ID 06)");
1642         break;
1643       case M3UA_RFC:
1644         col_set_str(pinfo->cinfo, COL_PROTOCOL, "M3UA (RFC 3332)");
1645         break;
1646       };      
1647
1648   /* In the interest of speed, if "tree" is NULL, don't do any work not
1649      necessary to generate protocol tree items. */
1650   if (tree) {
1651     /* create the m3ua protocol tree */
1652     m3ua_item = proto_tree_add_item(tree, proto_m3ua, message_tvb, 0, -1, FALSE);
1653     m3ua_tree = proto_item_add_subtree(m3ua_item, ett_m3ua);
1654   } else {
1655     m3ua_tree = NULL;
1656   };
1657
1658   /* dissect the message */
1659   dissect_message(message_tvb, pinfo, tree, m3ua_tree);
1660 }
1661
1662 /* Register the protocol with Ethereal */
1663 void
1664 proto_register_m3ua(void)
1665 {
1666
1667   /* Setup list of header fields */
1668   static hf_register_info hf[] = {
1669     { &hf_version,                          { "Version",                      "m3ua.version",                               FT_UINT8,  BASE_DEC,  VALS(protocol_version_values),                0x0, "", HFILL } },
1670     { &hf_reserved,                         { "Reserved",                     "m3ua.reserved",                              FT_UINT8,  BASE_HEX,  NULL,                                         0x0, "", HFILL } },
1671     { &hf_v5_message_class,                 { "Message class",                "m3ua.message_class",                         FT_UINT8,  BASE_DEC,  VALS(v5_message_class_values),                0x0, "", HFILL } },
1672     { &hf_message_class,                    { "Message class",                "m3ua.message_class",                         FT_UINT8,  BASE_DEC,  VALS(message_class_values),                   0x0, "", HFILL } },
1673     { &hf_message_type,                     { "Message Type",                 "m3ua.message_type",                          FT_UINT8,  BASE_DEC,  NULL,                                         0x0, "", HFILL } },
1674     { &hf_message_length,                   { "Message length",               "m3ua.message_length",                        FT_UINT32, BASE_DEC,  NULL,                                         0x0, "", HFILL } },
1675     { &hf_v5_parameter_tag,                 { "Parameter Tag",                "m3ua.parameter_tag",                         FT_UINT16, BASE_DEC,  VALS(v5_parameter_tag_values),                0x0, "", HFILL } },
1676     { &hf_v6_parameter_tag,                 { "Parameter Tag",                "m3ua.parameter_tag",                         FT_UINT16, BASE_DEC,  VALS(v6_parameter_tag_values),                0x0, "", HFILL } },
1677     { &hf_parameter_tag,                    { "Parameter Tag",                "m3ua.parameter_tag",                         FT_UINT16, BASE_DEC,  VALS(parameter_tag_values),                   0x0, "", HFILL } },
1678     { &hf_parameter_length,                 { "Parameter length",             "m3ua.parameter_length",                      FT_UINT16, BASE_DEC,  NULL,                                         0x0, "", HFILL } },
1679     { &hf_parameter_value,                  { "Parameter value",              "m3ua.parameter_value",                       FT_BYTES,  BASE_NONE, NULL,                                         0x0, "", HFILL } },
1680     { &hf_parameter_padding,                { "Padding",                      "m3ua.parameter_padding",                     FT_BYTES,  BASE_NONE, NULL,                                         0x0, "", HFILL } },
1681     { &hf_parameter_trailer,                { "Trailer",                      "m3ua.paramter_trailer",                      FT_BYTES,  BASE_NONE, NULL,                                         0x0, "", HFILL } },
1682     { &hf_network_appearance,               { "Network appearance",           "m3ua.network_appearance",                    FT_UINT32, BASE_DEC,  NULL,                                         0x0, "", HFILL } },
1683     { &hf_info_string,                      { "Info string",                  "m3ua.info_string",                           FT_STRING, BASE_DEC,  NULL,                                         0x0, "", HFILL } },
1684     { &hf_routing_context,                  { "Routing context",              "m3ua.routing_context",                       FT_UINT32, BASE_DEC,  NULL,                                         0x0, "", HFILL } },
1685     { &hf_diagnostic_information,           { "Diagnostic information",       "m3ua.diagnostic_information",                FT_BYTES,  BASE_NONE, NULL,                                         0x0, "", HFILL } },
1686     { &hf_heartbeat_data,                   { "Heartbeat data",               "m3ua.heartbeat_data",                        FT_BYTES,  BASE_NONE, NULL,                                         0x0, "", HFILL } },
1687     { &hf_v5_error_code,                    { "Error code",                   "m3ua.error_code",                            FT_UINT32, BASE_DEC,  VALS(v5_error_code_values),                   0x0, "", HFILL } },
1688     { &hf_v6_error_code,                    { "Error code",                   "m3ua.error_code",                            FT_UINT32, BASE_DEC,  VALS(v6_error_code_values),                   0x0, "", HFILL } },
1689     { &hf_error_code,                       { "Error code",                   "m3ua.error_code",                            FT_UINT32, BASE_DEC,  VALS(error_code_values),                      0x0, "", HFILL } },
1690     { &hf_status_type,                      { "Status type",                  "m3ua.status_type",                           FT_UINT16, BASE_DEC,  VALS(status_type_values),                     0x0, "", HFILL } },
1691     { &hf_status_info,                      { "Status info",                  "m3ua.status_info",                           FT_UINT16, BASE_DEC,  NULL,                                         0x0, "", HFILL } },
1692     { &hf_asp_identifier,                   { "ASP identifier",               "m3ua.asp_identifier",                        FT_UINT32, BASE_DEC,  NULL,                                         0x0, "", HFILL } },
1693     { &hf_affected_point_code_mask,         { "Mask",                         "m3ua.affected_point_code_mask",              FT_UINT8,  BASE_DEC,  NULL,                                         0x0, "", HFILL } },
1694     { &hf_affected_point_code_pc,           { "Affected point code",          "m3ua.affected_point_code_pc",                FT_UINT24, BASE_DEC,  NULL,                                         0x0, "", HFILL } },
1695     { &hf_cause,                            { "Unavailability cause",         "m3ua.unavailability_cause",                  FT_UINT16, BASE_DEC,  VALS(unavailability_cause_values),            0x0, "", HFILL } },
1696     { &hf_user,                             { "User Identity",                "m3ua.user_identity",                         FT_UINT16, BASE_DEC,  VALS(user_identity_values),                   0x0, "", HFILL } },
1697     { &hf_reason,                           { "Reason",                       "m3ua.reason",                                FT_UINT32, BASE_DEC,  VALS(reason_values),                          0x0, "", HFILL } },
1698     { &hf_v5_traffic_mode_type,             { "Traffic mode Type",            "m3ua.traffic_mode_type",                     FT_UINT32, BASE_DEC,  VALS(v5_traffic_mode_type_values),            0x0, "", HFILL } },
1699     { &hf_v6_traffic_mode_type,             { "Traffic mode Type",            "m3ua.traffic_mode_type",                     FT_UINT32, BASE_DEC,  VALS(v6_traffic_mode_type_values),            0x0, "", HFILL } },
1700     { &hf_traffic_mode_type,                { "Traffic mode Type",            "m3ua.traffic_mode_type",                     FT_UINT32, BASE_DEC,  VALS(traffic_mode_type_values),               0x0, "", HFILL } },
1701     { &hf_congestion_reserved,              { "Reserved",                     "m3ua.congestion_reserved",                   FT_BYTES,  BASE_NONE, NULL,                                         0x0, "", HFILL } },
1702     { &hf_congestion_level,                 { "Congestion level",             "m3ua.congestion_level",                      FT_UINT8,  BASE_DEC,  VALS(congestion_level_values),                0x0, "", HFILL } },
1703     { &hf_concerned_dest_reserved,          { "Reserved",                     "m3ua.concerned_reserved",                    FT_BYTES,  BASE_NONE, NULL,                                         0x0, "", HFILL } },
1704     { &hf_concerned_dest_pc,                { "Concerned DPC",                "m3ua.concerned_dpc",                         FT_UINT24, BASE_DEC,  NULL,                                         0x0, "", HFILL } },
1705     { &hf_local_rk_identifier,              { "Local routing key identifier", "m3ua.local_rk_identifier",                   FT_UINT32, BASE_DEC,  NULL,                                         0x0, "", HFILL } },
1706     { &hf_dpc_mask,                         { "Mask",                         "m3ua.dpc_mask",                              FT_UINT8,  BASE_DEC,  NULL,                                         0x0, "", HFILL } },
1707     { &hf_dpc_pc,                           { "Destination point code",       "m3ua.dpc_pc",                                FT_UINT24, BASE_DEC,  NULL,                                         0x0, "", HFILL } },
1708     { &hf_si,                               { "Service indicator",            "m3ua.si",                                    FT_UINT8,  BASE_DEC,  VALS(user_identity_values),                   0x0, "", HFILL } },
1709     { &hf_ssn,                              { "Subsystem number",             "m3ua.ssn",                                   FT_UINT8,  BASE_DEC,  NULL,                                         0x0, "", HFILL } },
1710     { &hf_opc_list_mask,                    { "Mask",                         "m3ua.opc_list_mask",                         FT_UINT8,  BASE_DEC,  NULL,                                         0x0, "", HFILL } },
1711     { &hf_opc_list_pc,                      { "Originating point code",       "m3ua.opc_list_pc",                           FT_UINT24, BASE_DEC,  NULL,                                         0x0, "", HFILL } },
1712     { &hf_cic_range_mask,                   { "Mask",                         "m3ua.cic_range_mask",                        FT_UINT8,  BASE_DEC,  NULL,                                         0x0, "", HFILL } },
1713     { &hf_cic_range_pc,                     { "Originating point code",       "m3ua.cic_range_pc",                          FT_UINT24, BASE_DEC,  NULL,                                         0x0, "", HFILL } },
1714     { &hf_cic_range_lower,                  { "Lower CIC value",              "m3ua.cic_range_lower",                       FT_UINT16, BASE_DEC,  NULL,                                         0x0, "", HFILL } },
1715     { &hf_cic_range_upper,                  { "Upper CIC value",              "m3ua.cic_range_upper",                       FT_UINT16, BASE_DEC,  NULL,                                         0x0, "", HFILL } },
1716     { &hf_li,                               { "Length indicator",             "m3ua.protocol_data_2_li",                    FT_UINT8,  BASE_DEC,  NULL,                                         0x0, "", HFILL } },
1717     { &hf_protocol_data_opc,                { "OPC",                          "m3ua.protocol_data_opc",                     FT_UINT32, BASE_DEC,  NULL,                                         0x0, "", HFILL } },
1718     { &hf_protocol_data_dpc,                { "DPC",                          "m3ua.protocol_data_dpc",                     FT_UINT32, BASE_DEC,  NULL,                                         0x0, "", HFILL } },
1719     { &hf_protocol_data_si,                 { "SI",                           "m3ua.protocol_data_si",                      FT_UINT8,  BASE_DEC,  VALS(user_identity_values),                                         0x0, "", HFILL } },
1720     { &hf_protocol_data_ni,                 { "NI",                           "m3ua.protocol_data_ni",                      FT_UINT8,  BASE_DEC,  NULL,                                         0x0, "", HFILL } },
1721     { &hf_protocol_data_mp,                 { "MP",                           "m3ua.protocol_data_mp",                      FT_UINT8,  BASE_DEC,  NULL,                                         0x0, "", HFILL } },
1722     { &hf_protocol_data_sls,                { "SLS",                          "m3ua.protocol_data_sls",                     FT_UINT8,  BASE_DEC,  NULL,                                         0x0, "", HFILL } },
1723     { &hf_correlation_identifier,           { "Correlation Identifier",       "m3ua.correlation_identifier",                FT_UINT32, BASE_DEC,  NULL,                                         0x0, "", HFILL } },
1724     { &hf_registration_status,              { "Registration status",          "m3ua.registration_status",                   FT_UINT32, BASE_DEC,  VALS(registration_status_values),             0x0, "", HFILL } },
1725     { &hf_deregistration_status,            { "Deregistration status",        "m3ua.deregistration_status",                 FT_UINT32, BASE_DEC,  VALS(deregistration_status_values),           0x0, "", HFILL } },
1726     { &hf_registration_result_identifier,   { "Local RK-identifier value",    "m3ua.registration_result_identifier",        FT_UINT32, BASE_DEC,  NULL,                                         0x0, "", HFILL } },
1727     { &hf_registration_result_status,       { "Registration status",          "m3ua.registration_results_status",           FT_UINT32, BASE_DEC,  VALS(registration_result_status_values),      0x0, "", HFILL } },
1728     { &hf_registration_result_context,      { "Routing context",              "m3ua.registration_result_routing_context",   FT_UINT32, BASE_DEC,  NULL,                                         0x0, "", HFILL } },
1729     { &hf_v6_deregistration_result_status,  { "De-Registration status",       "m3ua.deregistration_results_status",         FT_UINT32, BASE_DEC,  VALS(v6_deregistration_result_status_values), 0x0, "", HFILL } },
1730     { &hf_v6_deregistration_result_context, { "Routing context",              "m3ua.deregistration_result_routing_context", FT_UINT32, BASE_DEC,  NULL,                                         0x0, "", HFILL } },
1731   };
1732
1733   /* Setup protocol subtree array */
1734   static gint *ett[] = {
1735     &ett_m3ua,
1736     &ett_parameter,
1737   };
1738
1739   static enum_val_t options[] = {
1740     { "Internet Draft version 5",        M3UA_V5  },
1741     { "Internet Draft version 6",        M3UA_V6  },
1742     { "RFC 3332",                        M3UA_RFC },
1743     { NULL, 0 }
1744   };
1745
1746   /* Register the protocol name and description */
1747   proto_m3ua = proto_register_protocol("MTP 3 User Adaptation Layer", "M3UA",  "m3ua");
1748   m3ua_module = prefs_register_protocol(proto_m3ua, NULL);
1749   prefs_register_enum_preference(m3ua_module, "version", "M3UA Version", "Version used by Ethereal", (gint *)&version, options, FALSE);
1750
1751   /* Required function calls to register the header fields and subtrees used */
1752   proto_register_field_array(proto_m3ua, hf, array_length(hf));
1753   proto_register_subtree_array(ett, array_length(ett));
1754   si_dissector_table = register_dissector_table("m3ua.protocol_data_si", "MTP3 Service indicator", FT_UINT8, BASE_HEX);
1755
1756 };
1757
1758 void
1759 proto_reg_handoff_m3ua(void)
1760 {
1761   dissector_handle_t m3ua_handle;
1762
1763   /*
1764    * Get a handle for the MTP3 dissector.
1765    */
1766   mtp3_handle = find_dissector("mtp3");
1767   data_handle = find_dissector("data");
1768   m3ua_handle = create_dissector_handle(dissect_m3ua, proto_m3ua);
1769   dissector_add("sctp.ppi",  M3UA_PAYLOAD_PROTOCOL_ID, m3ua_handle);
1770   dissector_add("sctp.port", SCTP_PORT_M3UA, m3ua_handle);
1771 }