From Jason Damori via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7002
authorAlexis La Goutte <alexis.lagoutte@gmail.com>
Wed, 28 Mar 2012 08:46:07 +0000 (08:46 -0000)
committerAlexis La Goutte <alexis.lagoutte@gmail.com>
Wed, 28 Mar 2012 08:46:07 +0000 (08:46 -0000)
Add MAC Address Acquisition Protocol Dissector

Add the dissector for MAAP - the MAC address acquisition protocol for 802.3
Ethernet defined in IEEE1722.

svn path=/trunk/; revision=41811

epan/CMakeLists.txt
epan/dissectors/Makefile.common
epan/dissectors/packet-maap.c [new file with mode: 0644]

index 9348b312def91b011a346838caa963d078bef94c..4ce98b0b3b81f1960d1f2ac10f081e41db1ceafd 100644 (file)
@@ -795,6 +795,7 @@ set(DISSECTOR_SRC
        dissectors/packet-m2tp.c
        dissectors/packet-m2ua.c
        dissectors/packet-m3ua.c
+       dissectors/packet-maap.c
        dissectors/packet-mac-lte.c
        dissectors/packet-mac-lte-framed.c
        dissectors/packet-maccontrol.c
index f46ac5a8716e9ac0783ef03a9b48585f38d2cc8c..3e1acb2a94a69d307c02e889b3cfaf22067785c4 100644 (file)
@@ -714,6 +714,7 @@ DISSECTOR_SRC = \
        packet-m2tp.c           \
        packet-m2ua.c           \
        packet-m3ua.c           \
+       packet-maap.c           \
        packet-mac-lte.c        \
        packet-mac-lte-framed.c \
        packet-maccontrol.c     \
diff --git a/epan/dissectors/packet-maap.c b/epan/dissectors/packet-maap.c
new file mode 100644 (file)
index 0000000..c95058b
--- /dev/null
@@ -0,0 +1,222 @@
+/* packet-maap.c
+ * Routines for 802.3 MAC Address Allocation Protocol defined by IEEE1722
+ * Copyright 2012, Jason Damori, Biamp Systems <jdamori at biamp dot 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+/* #include <stdio.h> */
+
+#include <epan/packet.h>
+#include <epan/etypes.h>
+
+/* MAAP starts after common 1722 header */
+#define MAAP_START_OFFSET                   1
+
+/* MAAP Field Offsets */
+#define MAAP_MSG_TYPE_OFFSET                0+MAAP_START_OFFSET
+#define MAAP_VERSION_OFFSET                 1+MAAP_START_OFFSET
+#define MAAP_STREAM_ID_OFFSET               3+MAAP_START_OFFSET
+#define MAAP_REQ_START_ADDR_OFFSET          11+MAAP_START_OFFSET
+#define MAAP_REQ_COUNT_OFFSET               17+MAAP_START_OFFSET
+#define MAAP_CONFLICT_START_ADDR_OFFSET     19+MAAP_START_OFFSET
+#define MAAP_CONFLICT_COUNT_OFFSET          25+MAAP_START_OFFSET
+
+/* Bit Field Masks */
+#define MAAP_MSG_TYPE_MASK                  0x0f
+#define MAAP_VERSION_MASK                   0xf8
+#define MAAP_DATA_LEN_MASK                  0x07ff
+
+/* MAAP message_type */
+#define MAAP_MSG_TYPE_RESERVED_0            0x00
+#define MAAP_MSG_TYPE_PROBE                 0x01
+#define MAAP_MSG_TYPE_DEFEND                0x02
+#define MAAP_MSG_TYPE_ANNOUNCE              0x03
+#define MAAP_MSG_TYPE_RESERVED_4            0x04
+#define MAAP_MSG_TYPE_RESERVED_5            0x05
+
+static const value_string maap_msg_type_vals [] = {
+    {MAAP_MSG_TYPE_PROBE,       "MAAP_PROBE"},
+    {MAAP_MSG_TYPE_DEFEND,      "MAAP_DEFEND"},
+    {MAAP_MSG_TYPE_ANNOUNCE,    "MAAP_ANNOUNCE"},
+    {0,                         NULL}
+};
+
+/**********************************************************/
+/* Initialize the protocol and registered fields          */
+/**********************************************************/
+static int proto_maap = -1;
+
+/* MAAP PDU */
+static int hf_maap_message_type = -1;
+static int hf_maap_version = -1;
+static int hf_maap_data_length = -1;
+static int hf_maap_stream_id = -1;
+static int hf_maap_req_start_addr = -1;
+static int hf_maap_req_count = -1;
+static int hf_maap_conflict_start_addr = -1;
+static int hf_maap_conflict_count = -1;
+
+/* Initialize the subtree pointers */
+static int ett_maap = -1;
+
+static void
+dissect_maap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+{
+    guint8 maap_msg_type = 0;
+    proto_item *maap_item = NULL;
+    proto_tree *maap_tree = NULL;
+   
+    col_set_str(pinfo->cinfo, COL_PROTOCOL, "MAAP");
+
+    /* The maap msg type will be handy in a moment */
+    maap_msg_type = tvb_get_guint8(tvb, MAAP_MSG_TYPE_OFFSET);
+    maap_msg_type &= 0x0f;
+
+    col_clear(pinfo->cinfo,COL_INFO);
+    /* Display the name of the packet type in the info column. */
+    col_add_fstr(pinfo->cinfo, COL_INFO, "%s:",
+                val_to_str(maap_msg_type, maap_msg_type_vals,
+                            "Unknown Type(0x%02x)"));
+
+    /* Now, we'll add the start and conflict addresses and counts to the info column as appropriate */
+    switch (maap_msg_type)
+    {
+    case MAAP_MSG_TYPE_PROBE:
+    case MAAP_MSG_TYPE_ANNOUNCE:
+        col_append_fstr(pinfo->cinfo, COL_INFO, " req_start=%s, cnt=%d",
+                        tvb_ether_to_str(tvb, MAAP_REQ_START_ADDR_OFFSET),
+                        tvb_get_ntohs(tvb, MAAP_REQ_COUNT_OFFSET));
+
+        break;
+    case MAAP_MSG_TYPE_DEFEND:
+        col_append_fstr(pinfo->cinfo, COL_INFO, " conflict_start=%s, cnt=%d",
+                        tvb_ether_to_str(tvb, MAAP_CONFLICT_START_ADDR_OFFSET),
+                        tvb_get_ntohs(tvb, MAAP_CONFLICT_COUNT_OFFSET));
+        break;
+    default:
+        /* no info for reserved or unknown msg types */
+        break;
+    }
+    
+
+    if (tree) {
+        maap_item = proto_tree_add_item(tree, proto_maap, tvb, MAAP_START_OFFSET, -1, ENC_NA);
+        maap_tree = proto_item_add_subtree(maap_item, ett_maap);      
+           
+        proto_tree_add_item(maap_tree, hf_maap_message_type, tvb, MAAP_MSG_TYPE_OFFSET, 1, ENC_BIG_ENDIAN);
+        proto_tree_add_item(maap_tree, hf_maap_version, tvb, MAAP_VERSION_OFFSET, 1, ENC_BIG_ENDIAN);
+        proto_tree_add_item(maap_tree, hf_maap_data_length, tvb, MAAP_VERSION_OFFSET, 2, ENC_BIG_ENDIAN);
+        proto_tree_add_item(maap_tree, hf_maap_stream_id, tvb, MAAP_STREAM_ID_OFFSET, 8, ENC_BIG_ENDIAN);
+        proto_tree_add_item(maap_tree, hf_maap_req_start_addr, tvb, MAAP_REQ_START_ADDR_OFFSET, 6, ENC_NA);
+        proto_tree_add_item(maap_tree, hf_maap_req_count, tvb, MAAP_REQ_COUNT_OFFSET, 2, ENC_BIG_ENDIAN);
+        proto_tree_add_item(maap_tree, hf_maap_conflict_start_addr, tvb, MAAP_CONFLICT_START_ADDR_OFFSET, 6, ENC_NA);
+        proto_tree_add_item(maap_tree, hf_maap_conflict_count, tvb, MAAP_CONFLICT_COUNT_OFFSET, 2, ENC_BIG_ENDIAN);
+    }
+} /* end dissect_maap() */
+
+/* Register the protocol with Wireshark */
+void
+proto_register_maap(void)
+{
+    static hf_register_info hf[] = {
+        { &hf_maap_message_type,
+            { "Message Type", "maap.message_type",
+                FT_UINT8, BASE_HEX,
+                VALS(maap_msg_type_vals), MAAP_MSG_TYPE_MASK,
+                NULL, HFILL }},
+        
+        { &hf_maap_version,
+            { "MAAP Version", "maap.version",
+                FT_UINT8, BASE_HEX,
+                NULL, MAAP_VERSION_MASK,
+                NULL, HFILL }},
+        
+        { &hf_maap_data_length,
+            { "Data Length", "maap.data_length",
+                FT_UINT16, BASE_HEX,
+                NULL, MAAP_DATA_LEN_MASK,
+                NULL, HFILL }},
+        
+        { &hf_maap_stream_id,
+            { "Stream ID", "maap.stream_id",
+                FT_UINT64, BASE_HEX,
+                NULL, 0x00,
+                NULL, HFILL }},
+        
+        { &hf_maap_req_start_addr,
+            { "Requested Start Address", "maap.req_start_addr",
+                FT_ETHER, BASE_NONE,
+                NULL, 0x00,
+                NULL, HFILL }},
+
+        { &hf_maap_req_count,
+            { "Request Count", "maap.req_count",
+                FT_UINT16, BASE_HEX,
+                NULL, 0x00,
+                NULL, HFILL }},
+
+        { &hf_maap_conflict_start_addr,
+            { "Conflict Start Address", "maap.conflict_start_addr",
+                FT_ETHER, BASE_NONE,
+                NULL, 0x00,
+                NULL, HFILL }},
+      
+        { &hf_maap_conflict_count,
+            { "Conflict Count", "maap.conflict_count",
+                FT_UINT16, BASE_HEX,
+                NULL, 0x00,
+                NULL, HFILL }}     
+    }; /* end of static hf_register_info hf[] = */
+
+    /* Setup protocol subtree array */
+    static gint *ett[] = { &ett_maap };
+
+    /* Register the protocol name and description */
+    if (-1 == proto_maap)
+    {
+        proto_maap = proto_register_protocol (
+            "IEEE 1722 MAAP Protocol", /* name */
+            "MAAP", /* short name */
+            "maap" /* abbrev */
+        );
+    }
+
+    /* Required function calls to register the header fields and subtrees used */
+    proto_register_field_array(proto_maap, hf, array_length(hf));
+    proto_register_subtree_array(ett, array_length(ett));
+
+} /* end proto_register_maap() */
+
+void
+proto_reg_handoff_maap(void)
+{
+    dissector_handle_t maap_handle;
+
+    maap_handle = create_dissector_handle(dissect_maap, proto_maap);
+    dissector_add_uint("ieee1722.subtype", 0x7E, maap_handle);
+}