aboutsummaryrefslogtreecommitdiffstats
path: root/packet-m2pa.c
diff options
context:
space:
mode:
authorMichael Tüxen <tuexen@fh-muenster.de>2002-11-09 19:00:09 +0000
committerMichael Tüxen <tuexen@fh-muenster.de>2002-11-09 19:00:09 +0000
commit78266cfe46a18894bbb19a949f578ef4ea663e86 (patch)
treee094f8ca3d92e3efd2330c6c95b7e074e2374b07 /packet-m2pa.c
parent753ef1fb73a48e39119d8ea5a5fa51d6dac255f2 (diff)
Added support for version 2 of the ID, port number can now be selected.
Based on a patch of Jeff Morriss. svn path=/trunk/; revision=6595
Diffstat (limited to 'packet-m2pa.c')
-rw-r--r--packet-m2pa.c390
1 files changed, 276 insertions, 114 deletions
diff --git a/packet-m2pa.c b/packet-m2pa.c
index 88dc17b918..5f77a0b371 100644
--- a/packet-m2pa.c
+++ b/packet-m2pa.c
@@ -1,12 +1,13 @@
/* packet-m2pa.c
* Routines for MTP2 Peer Adaptation Layer dissection
* It is hopefully (needs testing) compliant to
+ * http://www.ietf.org/internet-drafts/draft-ietf-sigtran-m2pa-02.txt
* http://www.ietf.org/internet-drafts/draft-ietf-sigtran-m2pa-06.txt
*
* Copyright 2001, 2002, Jeff Morriss <jeff.morriss[AT]ulticom.com>,
* updated by Michael Tuexen <michael.tuexen[AT]siemens.com>
*
- * $Id: packet-m2pa.c,v 1.14 2002/09/22 12:12:32 tuexen Exp $
+ * $Id: packet-m2pa.c,v 1.15 2002/11/09 19:00:09 tuexen Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -35,23 +36,35 @@
#endif
#include <epan/packet.h>
+#include "prefs.h"
#define NETWORK_BYTE_ORDER FALSE
#define SCTP_PORT_M2PA 3565
#define M2PA_PAYLOAD_PROTOCOL_ID 5
+static int global_sctp_port = SCTP_PORT_M2PA;
+static int sctp_port = 0;
+
+void proto_reg_handoff_m2pa(void);
+
static int proto_m2pa = -1;
+static module_t *m2pa_module;
+
static int hf_version = -1;
static int hf_spare = -1;
-static int hf_type = -1;
+static int hf_v2_type = -1;
+static int hf_v6_type = -1;
static int hf_class = -1;
static int hf_length = -1;
static int hf_unused = -1;
static int hf_bsn = -1;
static int hf_fsn = -1;
-static int hf_status = -1;
-static int hf_li_spare = -1;
-static int hf_li_prio = -1;
+static int hf_v2_status = -1;
+static int hf_v6_status = -1;
+static int hf_v2_li_spare = -1;
+static int hf_v6_li_spare = -1;
+static int hf_v2_li_prio = -1;
+static int hf_v6_li_prio = -1;
static int hf_filler = -1;
static int hf_unknown_data = -1;
@@ -61,59 +74,88 @@ static gint ett_m2pa_li = -1;
static int mtp3_proto_id;
static dissector_handle_t mtp3_handle;
+typedef enum {
+ M2PA_V2 = 1,
+ M2PA_V6 = 2
+} Version_Type;
+
+static Version_Type m2pa_version = M2PA_V6;
+
#define VERSION_LENGTH 1
#define SPARE_LENGTH 1
#define CLASS_LENGTH 1
-#define TYPE_LENGTH 1
+#define V2_TYPE_LENGTH 2
+#define V6_TYPE_LENGTH 1
#define LENGTH_LENGTH 4
#define UNUSED_LENGTH 1
#define BSN_LENGTH 3
#define FSN_LENGTH 3
-#define HEADER_LENGTH (VERSION_LENGTH + SPARE_LENGTH + \
- CLASS_LENGTH + TYPE_LENGTH + LENGTH_LENGTH + \
- UNUSED_LENGTH + BSN_LENGTH + UNUSED_LENGTH + FSN_LENGTH)
+#define V2_HEADER_LENGTH (VERSION_LENGTH + SPARE_LENGTH + \
+ V2_TYPE_LENGTH + LENGTH_LENGTH)
+
+#define V6_HEADER_LENGTH (VERSION_LENGTH + SPARE_LENGTH + \
+ CLASS_LENGTH + V6_TYPE_LENGTH + LENGTH_LENGTH + \
+ UNUSED_LENGTH + BSN_LENGTH + UNUSED_LENGTH + \
+ FSN_LENGTH)
#define HEADER_OFFSET 0
#define VERSION_OFFSET HEADER_OFFSET
#define SPARE_OFFSET (VERSION_OFFSET + VERSION_LENGTH)
#define CLASS_OFFSET (SPARE_OFFSET + SPARE_LENGTH)
-#define TYPE_OFFSET (CLASS_OFFSET + CLASS_LENGTH)
-#define LENGTH_OFFSET (TYPE_OFFSET + TYPE_LENGTH)
-#define FIRST_UNUSED_OFFSET (LENGTH_OFFSET + LENGTH_LENGTH)
+#define V2_TYPE_OFFSET (SPARE_OFFSET + SPARE_LENGTH)
+#define V6_TYPE_OFFSET (CLASS_OFFSET + CLASS_LENGTH)
+#define V6_LENGTH_OFFSET (V6_TYPE_OFFSET + V6_TYPE_LENGTH)
+#define V2_LENGTH_OFFSET (V2_TYPE_OFFSET + V2_TYPE_LENGTH)
+#define FIRST_UNUSED_OFFSET (V6_LENGTH_OFFSET + LENGTH_LENGTH)
#define BSN_OFFSET (FIRST_UNUSED_OFFSET + UNUSED_LENGTH)
#define SECOND_UNUSED_OFFSET (BSN_OFFSET + BSN_LENGTH)
#define FSN_OFFSET (SECOND_UNUSED_OFFSET + UNUSED_LENGTH)
-#define PROTOCOL_VERSION_RELEASE_1 1
-
static const value_string protocol_version_values[] = {
- { PROTOCOL_VERSION_RELEASE_1, "Release 1" },
- { 0, NULL } };
-
-#define MESSAGE_CLASS_M2PA 0xb
+ { 1, "Release 1" },
+ { 0, NULL } };
static const value_string message_class_values[] = {
- { MESSAGE_CLASS_M2PA, "M2PA" },
- { 0, NULL } };
+ { 0xb, "M2PA" },
+ { 0, NULL } };
+
+#define V2_USER_DATA_TYPE 0x0601
+#define V2_LINK_STATUS_TYPE 0x0602
+
+static const value_string v2_message_type_values[] = {
+ { V2_USER_DATA_TYPE, "User Data" },
+ { V2_LINK_STATUS_TYPE, "Link Status" },
+ { 0, NULL } };
+
+#define V6_USER_DATA_TYPE 0x0001
+#define V6_LINK_STATUS_TYPE 0x0002
-#define MESSAGE_TYPE_USER_DATA 0x1
-#define MESSAGE_TYPE_LINK_STATUS 0x2
+static const value_string v6_message_type_values[] = {
+ { V6_USER_DATA_TYPE, "User Data" },
+ { V6_LINK_STATUS_TYPE, "Link Status" },
+ { 0, NULL } };
-static const value_string message_type_values[] = {
- { MESSAGE_TYPE_USER_DATA, "User Data" },
- { MESSAGE_TYPE_LINK_STATUS, "Link Status" },
- { 0, NULL } };
+static void
+dissect_v2_header(tvbuff_t *header_tvb, proto_tree *m2pa_tree)
+{
+ if (m2pa_tree) {
+ proto_tree_add_item(m2pa_tree, hf_version, header_tvb, VERSION_OFFSET, VERSION_LENGTH, NETWORK_BYTE_ORDER);
+ proto_tree_add_item(m2pa_tree, hf_spare, header_tvb, SPARE_OFFSET, SPARE_LENGTH, NETWORK_BYTE_ORDER);
+ proto_tree_add_item(m2pa_tree, hf_v2_type, header_tvb, V2_TYPE_OFFSET, V2_TYPE_LENGTH, NETWORK_BYTE_ORDER);
+ proto_tree_add_item(m2pa_tree, hf_length, header_tvb, V2_LENGTH_OFFSET, LENGTH_LENGTH, NETWORK_BYTE_ORDER);
+ }
+}
static void
-dissect_m2pa_header(tvbuff_t *header_tvb, proto_tree *m2pa_tree)
+dissect_v6_header(tvbuff_t *header_tvb, proto_tree *m2pa_tree)
{
if (m2pa_tree) {
proto_tree_add_item(m2pa_tree, hf_version, header_tvb, VERSION_OFFSET, VERSION_LENGTH, NETWORK_BYTE_ORDER);
proto_tree_add_item(m2pa_tree, hf_spare, header_tvb, SPARE_OFFSET, SPARE_LENGTH, NETWORK_BYTE_ORDER);
proto_tree_add_item(m2pa_tree, hf_class, header_tvb, CLASS_OFFSET, CLASS_LENGTH, NETWORK_BYTE_ORDER);
- proto_tree_add_item(m2pa_tree, hf_type, header_tvb, TYPE_OFFSET, TYPE_LENGTH, NETWORK_BYTE_ORDER);
- proto_tree_add_item(m2pa_tree, hf_length, header_tvb, LENGTH_OFFSET, LENGTH_LENGTH, NETWORK_BYTE_ORDER);
+ proto_tree_add_item(m2pa_tree, hf_v6_type, header_tvb, V6_TYPE_OFFSET, V6_TYPE_LENGTH, NETWORK_BYTE_ORDER);
+ proto_tree_add_item(m2pa_tree, hf_length, header_tvb, V6_LENGTH_OFFSET, LENGTH_LENGTH, NETWORK_BYTE_ORDER);
proto_tree_add_item(m2pa_tree, hf_unused, header_tvb, FIRST_UNUSED_OFFSET, UNUSED_LENGTH, NETWORK_BYTE_ORDER);
proto_tree_add_item(m2pa_tree, hf_bsn, header_tvb, BSN_OFFSET, BSN_LENGTH, NETWORK_BYTE_ORDER);
proto_tree_add_item(m2pa_tree, hf_unused, header_tvb, SECOND_UNUSED_OFFSET, UNUSED_LENGTH, NETWORK_BYTE_ORDER);
@@ -121,14 +163,15 @@ dissect_m2pa_header(tvbuff_t *header_tvb, proto_tree *m2pa_tree)
}
}
-#define LI_OFFSET 0
-#define LI_LENGTH 1
-#define MTP3_OFFSET (LI_OFFSET + LI_LENGTH)
-#define LI_SPARE_MASK 0x3f
-#define LI_PRIORITY_MASK 0xc0
+#define LI_OFFSET 0
+#define LI_LENGTH 1
+#define MTP3_OFFSET (LI_OFFSET + LI_LENGTH)
+
+#define V2_LI_SPARE_MASK 0xfc
+#define V2_LI_PRIORITY_MASK 0x3
static void
-dissect_m2pa_user_data_message(tvbuff_t *message_data_tvb, packet_info *pinfo, proto_item *m2pa_item, proto_tree *m2pa_tree, proto_tree *tree)
+dissect_v2_user_data_message(tvbuff_t *message_data_tvb, packet_info *pinfo, proto_item *m2pa_item, proto_tree *m2pa_tree, proto_tree *tree)
{
proto_item *m2pa_li_item;
proto_tree *m2pa_li_tree;
@@ -138,107 +181,181 @@ dissect_m2pa_user_data_message(tvbuff_t *message_data_tvb, packet_info *pinfo, p
if (m2pa_tree) {
m2pa_li_item = proto_tree_add_text(m2pa_tree, message_data_tvb, LI_OFFSET, LI_LENGTH, "Length Indicator");
m2pa_li_tree = proto_item_add_subtree(m2pa_li_item, ett_m2pa_li);
- proto_tree_add_item(m2pa_li_tree, hf_li_prio, message_data_tvb, LI_OFFSET, LI_LENGTH, NETWORK_BYTE_ORDER);
- proto_tree_add_item(m2pa_li_tree, hf_li_spare, message_data_tvb, LI_OFFSET, LI_LENGTH, NETWORK_BYTE_ORDER);
+
+ proto_tree_add_item(m2pa_li_tree, hf_v2_li_spare, message_data_tvb, LI_OFFSET, LI_LENGTH, NETWORK_BYTE_ORDER);
+ proto_tree_add_item(m2pa_li_tree, hf_v2_li_prio, message_data_tvb, LI_OFFSET, LI_LENGTH, NETWORK_BYTE_ORDER);
+
/* Re-adjust length of M2PA item since it will be dissected as MTP3 */
- proto_item_set_len(m2pa_item, HEADER_LENGTH + LI_LENGTH);
+ proto_item_set_len(m2pa_item, V2_HEADER_LENGTH + LI_LENGTH);
+ }
+ }
+
+ payload_tvb = tvb_new_subset(message_data_tvb, MTP3_OFFSET, -1, -1);
+ call_dissector(mtp3_handle, payload_tvb, pinfo, tree);
+
+ if ((!(proto_is_protocol_enabled (mtp3_proto_id))) && (check_col(pinfo->cinfo, COL_INFO)))
+ col_append_str(pinfo->cinfo, COL_INFO, "User Data ");
+}
+
+#define V6_LI_SPARE_MASK 0x3f
+#define V6_LI_PRIORITY_MASK 0xc0
+
+static void
+dissect_v6_user_data_message(tvbuff_t *message_data_tvb, packet_info *pinfo,
+ proto_item *m2pa_item, proto_tree *m2pa_tree,
+ proto_tree *tree)
+{
+ proto_item *m2pa_li_item;
+ proto_tree *m2pa_li_tree;
+ tvbuff_t *payload_tvb;
+
+ if (tvb_length(message_data_tvb) > 0) {
+ if (m2pa_tree) {
+ m2pa_li_item = proto_tree_add_text(m2pa_tree, message_data_tvb, LI_OFFSET, LI_LENGTH, "Length Indicator");
+ m2pa_li_tree = proto_item_add_subtree(m2pa_li_item, ett_m2pa_li);
+ proto_tree_add_item(m2pa_li_tree, hf_v6_li_prio, message_data_tvb, LI_OFFSET, LI_LENGTH, NETWORK_BYTE_ORDER);
+ proto_tree_add_item(m2pa_li_tree, hf_v6_li_spare, message_data_tvb, LI_OFFSET, LI_LENGTH, NETWORK_BYTE_ORDER);
+
+ /* Re-adjust length of M2PA item since it will be dissected as MTP3 */
+ proto_item_set_len(m2pa_item, V6_HEADER_LENGTH + LI_LENGTH);
}
payload_tvb = tvb_new_subset(message_data_tvb, MTP3_OFFSET, -1, -1);
- call_dissector(mtp3_handle, payload_tvb, pinfo, tree);
+ call_dissector(mtp3_handle, payload_tvb, pinfo, tree);
+
if ((!(proto_is_protocol_enabled (mtp3_proto_id))) && (check_col(pinfo->cinfo, COL_INFO)))
- col_append_str(pinfo->cinfo, COL_INFO, "User Data ");
- } else {
- if (check_col(pinfo->cinfo, COL_INFO))
+ col_append_str(pinfo->cinfo, COL_INFO, "User Data ");
+ } else {
+ if (check_col(pinfo->cinfo, COL_INFO))
col_append_str(pinfo->cinfo, COL_INFO, "User Data ");
}
}
+static const value_string v2_link_status_values[] = {
+ { 1, "In Service" },
+ { 2, "Processor Outage" },
+ { 3, "Processor Outage Ended" },
+ { 4, "Busy" },
+ { 5, "Busy Ended" },
+ { 0, NULL } };
+
#define STATUS_LENGTH 4
#define STATUS_OFFSET 0
#define FILLER_OFFSET (STATUS_OFFSET + STATUS_LENGTH)
-#define STATUS_ALIGNMENT 1
-#define STATUS_PROVING_NORMAL 2
-#define STATUS_PROVING_EMERGENCY 3
-#define STATUS_READY 4
-#define STATUS_PROCESSOR_OUTAGE 5
-#define STATUS_PROCESSOR_OUTAGE_ENDED 6
-#define STATUS_BUSY 7
-#define STATUS_BUSY_ENDED 8
-#define STATUS_OUT_OF_SERVICE 9
-
-static const value_string link_status_values[] = {
- { STATUS_ALIGNMENT, "Alignment" },
- { STATUS_PROVING_NORMAL, "Proving Normal" },
- { STATUS_PROVING_EMERGENCY, "Proving Emergency" },
- { STATUS_READY, "Ready" },
- { STATUS_PROCESSOR_OUTAGE, "Processor Outage" },
- { STATUS_PROCESSOR_OUTAGE_ENDED, "Processor Outage Ended" },
- { STATUS_BUSY, "Busy" },
- { STATUS_BUSY_ENDED, "Busy Ended" },
- { STATUS_OUT_OF_SERVICE, "Out of Service" },
- { 0, NULL } };
+static void
+dissect_v2_link_status_message(tvbuff_t *message_data_tvb, packet_info *pinfo, proto_tree *m2pa_tree)
+{
+ if (check_col(pinfo->cinfo, COL_INFO))
+ col_append_str(pinfo->cinfo, COL_INFO, "Link status ");
+
+ if (m2pa_tree)
+ proto_tree_add_item(m2pa_tree, hf_v2_status, message_data_tvb, STATUS_OFFSET, STATUS_LENGTH, NETWORK_BYTE_ORDER);
+}
+
+static const value_string v6_link_status_values[] = {
+ { 1, "Alignment" },
+ { 2, "Proving Normal" },
+ { 3, "Proving Emergency" },
+ { 4, "Ready" },
+ { 5, "Processor Outage" },
+ { 6, "Processor Outage Ended" },
+ { 7, "Busy" },
+ { 8, "Busy Ended" },
+ { 9, "Out of Service" },
+ { 0, NULL } };
static void
-dissect_m2pa_link_status_message(tvbuff_t *message_data_tvb, packet_info *pinfo, proto_tree *m2pa_tree)
+dissect_v6_link_status_message(tvbuff_t *message_data_tvb, packet_info *pinfo, proto_tree *m2pa_tree)
{
guint16 filler_length;
+ filler_length = tvb_length(message_data_tvb) - STATUS_LENGTH;
+
if (check_col(pinfo->cinfo, COL_INFO))
col_append_str(pinfo->cinfo, COL_INFO, "Link status ");
- if (m2pa_tree) {
- filler_length = tvb_length(message_data_tvb) - STATUS_LENGTH;
- proto_tree_add_item(m2pa_tree, hf_status, message_data_tvb, STATUS_OFFSET, STATUS_LENGTH, NETWORK_BYTE_ORDER);
- if (filler_length > 0)
+
+ proto_tree_add_item(m2pa_tree, hf_v6_status, message_data_tvb, STATUS_OFFSET, STATUS_LENGTH, NETWORK_BYTE_ORDER);
+ if (filler_length > 0)
proto_tree_add_item(m2pa_tree, hf_filler, message_data_tvb, FILLER_OFFSET, filler_length, NETWORK_BYTE_ORDER);
- }
}
static void
-dissect_m2pa_unknown_message(tvbuff_t *message_data_tvb, packet_info *pinfo, proto_tree *m2pa_tree)
+dissect_unknown_message(tvbuff_t *message_data_tvb, packet_info *pinfo, proto_tree *m2pa_tree)
{
+ guint length;
+
if (check_col(pinfo->cinfo, COL_INFO))
col_append_str(pinfo->cinfo, COL_INFO, "Unknown ");
- if (m2pa_tree)
- proto_tree_add_item(m2pa_tree, hf_unknown_data, message_data_tvb, 0, tvb_length(message_data_tvb), NETWORK_BYTE_ORDER);
+
+ length = tvb_length(message_data_tvb);
+ if ((m2pa_tree) && (length > 0))
+ proto_tree_add_item(m2pa_tree, hf_unknown_data, message_data_tvb, 0, length, NETWORK_BYTE_ORDER);
}
-#define MESSAGE_DATA_OFFSET (HEADER_OFFSET + HEADER_LENGTH)
+#define V2_MESSAGE_DATA_OFFSET (HEADER_OFFSET + V2_HEADER_LENGTH)
static void
-dissect_m2pa_message_data(tvbuff_t *message_tvb, packet_info *pinfo, proto_item *m2pa_item, proto_tree *m2pa_tree, proto_tree *tree)
+dissect_v2_message_data(tvbuff_t *message_tvb, packet_info *pinfo, proto_item *m2pa_item, proto_tree *m2pa_tree, proto_tree *tree)
{
guint32 message_data_length;
- guint8 type;
+ guint16 type;
tvbuff_t *message_data_tvb;
- message_data_length = tvb_get_ntohl(message_tvb, LENGTH_OFFSET) - HEADER_LENGTH;
- message_data_tvb = tvb_new_subset(message_tvb, MESSAGE_DATA_OFFSET, message_data_length, message_data_length);
- type = tvb_get_guint8(message_tvb, TYPE_OFFSET);
+ message_data_length = tvb_get_ntohl(message_tvb, V2_LENGTH_OFFSET);
+ message_data_tvb = tvb_new_subset(message_tvb, V2_MESSAGE_DATA_OFFSET, message_data_length, message_data_length);
+ type = tvb_get_ntohs(message_tvb, V2_TYPE_OFFSET);
switch(type) {
- case MESSAGE_TYPE_USER_DATA:
- dissect_m2pa_user_data_message(message_data_tvb, pinfo, m2pa_item, m2pa_tree, tree);
+ case V2_USER_DATA_TYPE:
+ dissect_v2_user_data_message(message_data_tvb, pinfo, m2pa_item, m2pa_tree, tree);
break;
-
- case MESSAGE_TYPE_LINK_STATUS:
- dissect_m2pa_link_status_message(message_data_tvb, pinfo, m2pa_tree);
+ case V2_LINK_STATUS_TYPE:
+ dissect_v2_link_status_message(message_data_tvb, pinfo, m2pa_tree);
break;
-
default:
- dissect_m2pa_unknown_message(message_data_tvb, pinfo, m2pa_tree);
+ dissect_unknown_message(message_data_tvb, pinfo, m2pa_tree);
}
+}
+#define V6_MESSAGE_DATA_OFFSET (HEADER_OFFSET + V6_HEADER_LENGTH)
+
+static void
+dissect_v6_message_data(tvbuff_t *message_tvb, packet_info *pinfo, proto_item *m2pa_item, proto_tree *m2pa_tree, proto_tree *tree)
+{
+ guint32 message_data_length;
+ guint16 type;
+ tvbuff_t *message_data_tvb;
+
+ message_data_length = tvb_get_ntohl(message_tvb, V6_LENGTH_OFFSET) - V6_HEADER_LENGTH;
+ message_data_tvb = tvb_new_subset(message_tvb, V6_MESSAGE_DATA_OFFSET, message_data_length, message_data_length);
+ type = tvb_get_guint8(message_tvb, V6_TYPE_OFFSET);
+
+
+ switch(type) {
+ case V6_USER_DATA_TYPE:
+ dissect_v6_user_data_message(message_data_tvb, pinfo, m2pa_item, m2pa_tree, tree);
+ break;
+ case V6_LINK_STATUS_TYPE:
+ dissect_v6_link_status_message(message_data_tvb, pinfo, m2pa_tree);
+ break;
+ default:
+ dissect_unknown_message(message_data_tvb, pinfo, m2pa_tree);
+ }
}
+
static void
-dissect_m2pa_message(tvbuff_t *message_tvb, packet_info *pinfo, proto_item *m2pa_item, proto_tree *m2pa_tree, proto_tree *tree)
+dissect_v2_message(tvbuff_t *message_tvb, packet_info *pinfo, proto_item *m2pa_item, proto_tree *m2pa_tree, proto_tree *tree)
{
- tvbuff_t *header_tvb;
+ dissect_v2_header(message_tvb, m2pa_tree);
+ dissect_v2_message_data(message_tvb, pinfo, m2pa_item, m2pa_tree, tree);
+}
- header_tvb = tvb_new_subset(message_tvb, HEADER_OFFSET, HEADER_LENGTH, HEADER_LENGTH);
- dissect_m2pa_header(header_tvb, m2pa_tree);
- dissect_m2pa_message_data(message_tvb, pinfo, m2pa_item, m2pa_tree, tree);
+static void
+dissect_v6_message(tvbuff_t *message_tvb, packet_info *pinfo, proto_item *m2pa_item, proto_tree *m2pa_tree, proto_tree *tree)
+{
+ dissect_v6_header(message_tvb, m2pa_tree);
+ dissect_v6_message_data(message_tvb, pinfo, m2pa_item, m2pa_tree, tree);
}
static void
@@ -248,7 +365,14 @@ dissect_m2pa(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
proto_tree *m2pa_tree;
if (check_col(pinfo->cinfo, COL_PROTOCOL))
- col_set_str(pinfo->cinfo, COL_PROTOCOL, "M2PA");
+ switch(m2pa_version) {
+ case M2PA_V2:
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "M2PA (02)");
+ break;
+ case M2PA_V6:
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "M2PA (06)");
+ break;
+ };
if (tree) {
m2pa_item = proto_tree_add_item(tree, proto_m2pa, tvb, 0, -1, FALSE);
@@ -256,28 +380,39 @@ dissect_m2pa(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
} else {
m2pa_item = NULL;
m2pa_tree = NULL;
- };
+ }
- dissect_m2pa_message(tvb, pinfo, m2pa_item, m2pa_tree, tree);
+ switch(m2pa_version) {
+ case M2PA_V2:
+ dissect_v2_message(tvb, pinfo, m2pa_item, m2pa_tree, tree);
+ break;
+ case M2PA_V6:
+ dissect_v6_message(tvb, pinfo, m2pa_item, m2pa_tree, tree);
+ break;
+ };
}
void
proto_register_m2pa(void)
{
- static hf_register_info hf[] = {
- { &hf_version, { "Version", "m2pa.version", FT_UINT8, BASE_DEC, VALS(protocol_version_values), 0x0, "", HFILL} },
- { &hf_spare, { "Spare", "m2pa.spare", FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL} },
- { &hf_type, { "Message Type", "m2pa.type", FT_UINT8, BASE_DEC, VALS(message_type_values), 0x0, "", HFILL} },
- { &hf_class, { "Message Class", "m2pa.class", FT_UINT8, BASE_DEC, VALS(message_class_values), 0x0, "", HFILL} },
- { &hf_length, { "Message length", "m2pa.length", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL} },
- { &hf_unused, { "Unused", "m2pa.unused", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL} },
- { &hf_bsn, { "BSN", "m2pa.bsn", FT_UINT24, BASE_DEC, NULL, 0x0, "", HFILL} },
- { &hf_fsn, { "FSN", "m2pa.fsn", FT_UINT24, BASE_DEC, NULL, 0x0, "", HFILL} },
- { &hf_li_spare, { "Spare", "m2pa.li_spare", FT_UINT8, BASE_HEX, NULL, LI_SPARE_MASK, "", HFILL} },
- { &hf_li_prio, { "Priority", "m2pa.li_priority", FT_UINT8, BASE_HEX, NULL, LI_PRIORITY_MASK, "", HFILL} },
- { &hf_status, { "Link Status", "m2pa.status", FT_UINT32, BASE_DEC, VALS(link_status_values), 0x0, "", HFILL} },
- { &hf_filler, { "Filler", "m2pa.filler", FT_BYTES, BASE_NONE, NULL, 0x0, "", HFILL } },
- { &hf_unknown_data, { "Unknown Data", "m2pa.unknown_data", FT_BYTES, BASE_NONE, NULL, 0x0, "", HFILL } }
+ static hf_register_info hf[] =
+ { { &hf_version, { "Version", "m2pa.version", FT_UINT8, BASE_DEC, VALS(protocol_version_values), 0x0, "", HFILL} },
+ { &hf_spare, { "Spare", "m2pa.spare", FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL} },
+ { &hf_v2_type, { "Message Type", "m2pa.type", FT_UINT16, BASE_HEX, VALS(v2_message_type_values), 0x0, "", HFILL} },
+ { &hf_v6_type, { "Message Type", "m2pa.type", FT_UINT8, BASE_DEC, VALS(v6_message_type_values), 0x0, "", HFILL} },
+ { &hf_class, { "Message Class", "m2pa.class", FT_UINT8, BASE_DEC, VALS(message_class_values), 0x0, "", HFILL} },
+ { &hf_length, { "Message length", "m2pa.length", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL} },
+ { &hf_unused, { "Unused", "m2pa.unused", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL} },
+ { &hf_bsn, { "BSN", "m2pa.bsn", FT_UINT24, BASE_DEC, NULL, 0x0, "", HFILL} },
+ { &hf_fsn, { "FSN", "m2pa.fsn", FT_UINT24, BASE_DEC, NULL, 0x0, "", HFILL} },
+ { &hf_v2_li_spare, { "Spare", "m2pa.li_spare", FT_UINT8, BASE_DEC, NULL, V2_LI_SPARE_MASK, "", HFILL} },
+ { &hf_v6_li_spare, { "Spare", "m2pa.li_spare", FT_UINT8, BASE_HEX, NULL, V6_LI_SPARE_MASK, "", HFILL} },
+ { &hf_v2_li_prio, { "Priority", "m2pa.li_priority", FT_UINT8, BASE_DEC, NULL, V2_LI_PRIORITY_MASK, "", HFILL} },
+ { &hf_v6_li_prio, { "Priority", "m2pa.li_priority", FT_UINT8, BASE_HEX, NULL, V6_LI_PRIORITY_MASK, "", HFILL} },
+ { &hf_v2_status, { "Link Status", "m2pa.status", FT_UINT32, BASE_DEC, VALS(v2_link_status_values), 0x0, "", HFILL} },
+ { &hf_v6_status, { "Link Status", "m2pa.status", FT_UINT32, BASE_DEC, VALS(v6_link_status_values), 0x0, "", HFILL} },
+ { &hf_filler, { "Filler", "m2pa.filler", FT_BYTES, BASE_NONE, NULL, 0x0, "", HFILL} },
+ { &hf_unknown_data, { "Unknown Data", "m2pa.unknown_data", FT_BYTES, BASE_NONE, NULL, 0x0, "", HFILL} }
};
static gint *ett[] = {
@@ -285,20 +420,47 @@ proto_register_m2pa(void)
&ett_m2pa_li
};
+ static enum_val_t m2pa_version_options[] = {
+ { "Internet Draft version 2", M2PA_V2 },
+ { "Internet Draft version 6", M2PA_V6 },
+ { NULL, 0 }
+ };
+
proto_m2pa = proto_register_protocol("MTP2 Peer Adaptation Layer", "M2PA", "m2pa");
proto_register_field_array(proto_m2pa, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
+
+ m2pa_module = prefs_register_protocol(proto_m2pa, proto_reg_handoff_m2pa);
+
+ prefs_register_enum_preference(m2pa_module, "version", "M2PA version", "Version used by Ethereal", (gint *)&m2pa_version, m2pa_version_options, FALSE);
+ prefs_register_uint_preference(m2pa_module, "port", "M2PA SCTP Port", "Set the port for M2PA messages (Default of 3565)", 10, &global_sctp_port);
}
void
proto_reg_handoff_m2pa(void)
{
- dissector_handle_t m2pa_handle;
+ static int prefs_initialized = FALSE;
+ static dissector_handle_t m2pa_handle;
- mtp3_handle = find_dissector("mtp3");
- mtp3_proto_id = proto_get_id_by_filter_name("mtp3");
- m2pa_handle = create_dissector_handle(dissect_m2pa, proto_m2pa);
- dissector_add("sctp.ppi", M2PA_PAYLOAD_PROTOCOL_ID, m2pa_handle);
- dissector_add("sctp.port", SCTP_PORT_M2PA, m2pa_handle);
-}
+ /* Port preferences code shamelessly copied from packet-beep.c */
+ if (!prefs_initialized) {
+ mtp3_handle = find_dissector("mtp3");
+ mtp3_proto_id = proto_get_id_by_filter_name("mtp3");
+ m2pa_handle = create_dissector_handle(dissect_m2pa, proto_m2pa);
+
+ dissector_add("sctp.ppi", M2PA_PAYLOAD_PROTOCOL_ID, m2pa_handle);
+
+ prefs_initialized = TRUE;
+
+ } else {
+
+ dissector_delete("sctp.port", sctp_port, m2pa_handle);
+
+ }
+
+ /* Set our port number for future use */
+ sctp_port = global_sctp_port;
+
+ dissector_add("sctp.port", sctp_port, m2pa_handle);
+} \ No newline at end of file