aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7>2010-06-23 20:08:11 +0000
committerwmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7>2010-06-23 20:08:11 +0000
commit0896a618c9fd8cf31b7c00a17ff9ab59e84c2b50 (patch)
tree1d02fbb45e8d283a94367ddc052a3ba6f7deb301
parentd6ca35c96b5556f6c9d502081d27fb4a712f266a (diff)
From Haakon Nessjoen: New dissector for Digiums TDMoE protocol
From me: A few minor changes: - col-clear() not req'd; - Use 'gint32 length' rather than 'guint8 length'; - Use ENC_NA instead of FALSE/TRUE in two cases; - Move global tdmoe_handle to be local to proto_reg_handoff... git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@33307 f5534014-38df-0310-8fa8-9805f1628bb7
-rw-r--r--AUTHORS1
-rw-r--r--epan/CMakeLists.txt1
-rw-r--r--epan/dissectors/Makefile.common1
-rw-r--r--epan/dissectors/packet-ethertype.c1
-rw-r--r--epan/dissectors/packet-tdmoe.c172
-rw-r--r--epan/etypes.h4
6 files changed, 180 insertions, 0 deletions
diff --git a/AUTHORS b/AUTHORS
index 0eb78484aa..d86e31b9c1 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -3095,6 +3095,7 @@ David Perez <david [AT] taddong.com> {
Håkon Nessjøen <haakon.nessjoen@gmail.com> {
Mikrotik RouterOS protocol dissector
+ Digium TDMoE protocol dissector
}
and by:
diff --git a/epan/CMakeLists.txt b/epan/CMakeLists.txt
index 50697f42c3..ccb672574c 100644
--- a/epan/CMakeLists.txt
+++ b/epan/CMakeLists.txt
@@ -964,6 +964,7 @@ set(DISSECTOR_SRC
dissectors/packet-tali.c
dissectors/packet-tapa.c
dissectors/packet-tcp.c
+ dissectors/packet-tdmoe.c
dissectors/packet-tds.c
dissectors/packet-teamspeak2.c
dissectors/packet-teimanagement.c
diff --git a/epan/dissectors/Makefile.common b/epan/dissectors/Makefile.common
index d9532117da..dd385b726c 100644
--- a/epan/dissectors/Makefile.common
+++ b/epan/dissectors/Makefile.common
@@ -878,6 +878,7 @@ DISSECTOR_SRC = \
packet-tali.c \
packet-tapa.c \
packet-tcp.c \
+ packet-tdmoe.c \
packet-tds.c \
packet-teamspeak2.c \
packet-teimanagement.c \
diff --git a/epan/dissectors/packet-ethertype.c b/epan/dissectors/packet-ethertype.c
index 033898ba86..662ede997d 100644
--- a/epan/dissectors/packet-ethertype.c
+++ b/epan/dissectors/packet-ethertype.c
@@ -157,6 +157,7 @@ const value_string etype_vals[] = {
{ ETHERTYPE_PTP, "PTPv2 over Ethernet (IEEE1588)" },
{ ETHERTYPE_PRP, "Parallel Redundancy Protocol (IEC62439 Chapter 6)" },
{ ETHERTYPE_FLIP, "Flow Layer Internal Protocol" },
+ { ETHERTYPE_TDMOE, "Digium TDM over Ethernet Protocol" },
{ 0, NULL }
};
diff --git a/epan/dissectors/packet-tdmoe.c b/epan/dissectors/packet-tdmoe.c
new file mode 100644
index 0000000000..f9403331fe
--- /dev/null
+++ b/epan/dissectors/packet-tdmoe.c
@@ -0,0 +1,172 @@
+/* packet-tdmoe.c
+ * Routines for TDM over Ethernet packet disassembly
+ * Copyright 2010, Haakon Nessjoen <haakon.nessjoen@gmail.com>
+ *
+ * $Id$
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <glib.h>
+
+#include <epan/packet.h>
+#include <epan/etypes.h>
+
+/* Bitmasks for the flags in the fourth byte of the packet */
+#define TDMOE_YELLOW_ALARM_BITMASK 0x01
+#define TDMOE_SIGBITS_BITMASK 0x02
+
+/* protocols and header fields */
+static int proto_tdmoe = -1;
+
+static int hf_tdmoe_subaddress = -1;
+static int hf_tdmoe_samples = -1;
+static int hf_tdmoe_flags = -1;
+static int hf_tdmoe_yellow_alarm = -1;
+static int hf_tdmoe_sig_bits_present = -1;
+static int hf_tdmoe_packet_counter = -1;
+static int hf_tdmoe_channels = -1;
+static int hf_tdmoe_sig_bits = -1;
+
+static gint ett_tdmoe = -1;
+static gint ett_tdmoe_flags = -1;
+
+static dissector_handle_t data_handle;
+
+static int
+dissect_tdmoe(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+{
+ proto_item *ti;
+ proto_tree *tdmoe_tree;
+ tvbuff_t *next_client;
+ guint16 channels;
+ guint16 subaddress;
+
+ /* Check that there's enough data */
+ if (tvb_length(tvb) < 8)
+ return 0;
+
+ subaddress = tvb_get_ntohs(tvb, 0);
+ channels = tvb_get_ntohs(tvb, 6);
+
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "TDMoE");
+ col_add_fstr(pinfo->cinfo, COL_INFO, "Subaddress: %d Channels: %d %s",
+ subaddress,
+ channels,
+ (tvb_get_guint8(tvb, 3) & TDMOE_YELLOW_ALARM_BITMASK ? "[YELLOW ALARM]" : "")
+ );
+
+ if (tree) {
+ gint32 offset = 0;
+ static const gint *flags[] = { &hf_tdmoe_yellow_alarm, &hf_tdmoe_sig_bits_present, NULL };
+
+ /* create display subtree for the protocol */
+ ti = proto_tree_add_item(tree, proto_tdmoe, tvb, 0, -1, ENC_NA);
+ tdmoe_tree = proto_item_add_subtree(ti, ett_tdmoe);
+
+ /* Subaddress */
+ proto_tree_add_item(tdmoe_tree, hf_tdmoe_subaddress, tvb, offset, 2, ENC_BIG_ENDIAN);
+ offset+=2;
+
+ /* Samples (1 byte) */
+ proto_tree_add_item(tdmoe_tree, hf_tdmoe_samples, tvb, offset, 1, ENC_NA);
+ offset++;
+
+ /* Yellow alarm & "Sig bits present" bits (1 byte) */
+ proto_tree_add_bitmask(tdmoe_tree, tvb, offset, hf_tdmoe_flags, ett_tdmoe_flags, flags, ENC_NA/*??*/);
+ offset++;
+
+ /* Packet counter (2 bytes) */
+ proto_tree_add_item(tdmoe_tree, hf_tdmoe_packet_counter, tvb, offset, 2, ENC_BIG_ENDIAN);
+ offset+=2;
+
+ /* Number of channels in packet (2 bytes) */
+ proto_tree_add_item(tdmoe_tree, hf_tdmoe_channels, tvb, offset, 2, ENC_BIG_ENDIAN);
+ offset+=2;
+
+ if (tvb_get_guint8(tvb, 3) & TDMOE_SIGBITS_BITMASK) {
+ /* 4 sigbits per channel. Might be different on other sub-protocols? */
+ guint16 length = (channels >> 1) + ((channels & 0x01) ? 1 : 0);
+
+ proto_tree_add_item(tdmoe_tree, hf_tdmoe_sig_bits, tvb, offset, length, ENC_NA);
+ offset += length;
+ }
+
+ /* The rest is SAMPLES * CHANNELS bytes of channel data */
+ next_client = tvb_new_subset(tvb, offset, -1, -1);
+ return call_dissector(data_handle, next_client, pinfo, tdmoe_tree);
+ }
+
+ return tvb_reported_length(tvb);
+}
+
+void
+proto_register_tdmoe(void)
+{
+ static hf_register_info hf[] = {
+
+ { &hf_tdmoe_subaddress,
+ { "Subaddress", "tdmoe.subaddress", FT_UINT8, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }},
+ { &hf_tdmoe_samples,
+ { "Samples", "tdmoe.samples", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "Samples per channel", HFILL }},
+ { &hf_tdmoe_flags,
+ { "Flags", "tdmoe.flags", FT_UINT8, BASE_HEX, NULL, 0x0,
+ NULL, HFILL }},
+ { &hf_tdmoe_yellow_alarm,
+ { "Yellow Alarm", "tdmoe.yellowalarm", FT_BOOLEAN, 8, NULL, TDMOE_YELLOW_ALARM_BITMASK,
+ NULL, HFILL }},
+ { &hf_tdmoe_sig_bits_present,
+ { "Sig bits present", "tdmoe.sig_bits", FT_BOOLEAN, 8, NULL, TDMOE_SIGBITS_BITMASK,
+ NULL, HFILL }},
+ { &hf_tdmoe_packet_counter,
+ { "Counter", "tdmoe.counter", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "Packet number", HFILL }},
+ { &hf_tdmoe_channels,
+ { "Channels", "tdmoe.channels", FT_UINT16, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }},
+ { &hf_tdmoe_sig_bits,
+ { "Sig bits", "tdmoe.sig_bits", FT_BYTES, BASE_NONE, NULL, 0x0,
+ NULL, HFILL }},
+ };
+ static gint *ett[] = {
+ &ett_tdmoe,
+ &ett_tdmoe_flags
+ };
+
+ proto_tdmoe = proto_register_protocol("Digium TDMoE Protocol", "TDMoE", "tdmoe");
+ proto_register_field_array(proto_tdmoe, hf, array_length(hf));
+ proto_register_subtree_array(ett, array_length(ett));
+}
+
+void
+proto_reg_handoff_tdmoe(void)
+{
+ dissector_handle_t tdmoe_handle;
+
+ tdmoe_handle = new_create_dissector_handle(dissect_tdmoe, proto_tdmoe);
+ dissector_add("ethertype", ETHERTYPE_TDMOE, tdmoe_handle);
+
+ data_handle = find_dissector("data");
+}
diff --git a/epan/etypes.h b/epan/etypes.h
index 5fb5590f92..d67be21c60 100644
--- a/epan/etypes.h
+++ b/epan/etypes.h
@@ -451,6 +451,10 @@
#ifndef ETHERTYPE_LLT
#define ETHERTYPE_LLT 0xCAFE /* Veritas Low Latency Transport (not officially registered) */
#endif
+
+#ifndef ETHERTYPE_TDMOE
+#define ETHERTYPE_TDMOE 0xD00D /* Digium TDMoE packets (not officially registered) */
+#endif
#ifndef ETHERTYPE_FCFT
#define ETHERTYPE_FCFT 0xFCFC /* used to transport FC frames+MDS hdr internal to Cisco's MDS switch */