Add a dissector "mac-lte-framed" that uses the same framing format as
authormartinm <martinm@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 19 Jan 2012 02:58:53 +0000 (02:58 +0000)
committermartinm <martinm@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 19 Jan 2012 02:58:53 +0000 (02:58 +0000)
the existing "mac-lte" UDP heuristic dissector. It is hoped that it will be
possible to register a DLT for use with this format.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@40580 f5534014-38df-0310-8fa8-9805f1628bb7

epan/CMakeLists.txt
epan/dissectors/Makefile.common
epan/dissectors/packet-mac-lte-framed.c [new file with mode: 0644]
epan/dissectors/packet-mac-lte.c
epan/dissectors/packet-mac-lte.h

index 9e544b031040f357862329ab977f33ddceebf9a5..8f37dda3bcbf928482477e16f5e95fdcda354808 100644 (file)
@@ -765,6 +765,7 @@ set(DISSECTOR_SRC
        dissectors/packet-m2ua.c
        dissectors/packet-m3ua.c
        dissectors/packet-mac-lte.c
+       dissectors/packet-mac-lte-framed.c
        dissectors/packet-maccontrol.c
        dissectors/packet-mactelnet.c
        dissectors/packet-manolito.c
index da13a5ca68c78bddd26a522bdcd126f31376cd75..6db4313b5ae253437248ca233dc41c161f91b599 100644 (file)
@@ -683,6 +683,7 @@ DISSECTOR_SRC = \
        packet-m2ua.c           \
        packet-m3ua.c           \
        packet-mac-lte.c        \
+       packet-mac-lte-framed.c \
        packet-maccontrol.c     \
        packet-mactelnet.c      \
        packet-manolito.c       \
diff --git a/epan/dissectors/packet-mac-lte-framed.c b/epan/dissectors/packet-mac-lte-framed.c
new file mode 100644 (file)
index 0000000..f3b8788
--- /dev/null
@@ -0,0 +1,115 @@
+/* Routines for MAC LTE format files with context info as header.
+ *
+ * Martin Mathieson
+ *
+ * $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 <epan/packet.h>
+
+#include "packet-mac-lte.h"
+
+/*
+ * Doesn't do a detailed dissection of the lines of the message, just treat as text.
+ */
+
+
+/* Initialize the protocol and registered fields. */
+static int proto_mac_lte_framed = -1;
+
+extern int proto_mac_lte;
+
+/* Main dissection function. */
+static void dissect_mac_lte_framed(tvbuff_t *tvb, packet_info *pinfo,
+                                   proto_tree *tree)
+{
+    gint                 offset = 0;
+    struct mac_lte_info  *p_mac_lte_info;
+    tvbuff_t             *mac_tvb;
+    gboolean             infoAlreadySet = FALSE;
+    dissector_handle_t   mac_lte_handle = find_dissector("mac-lte");
+    if (!mac_lte_handle) {
+        return;
+    }
+
+    /* Do this again on re-dissection to re-discover offset of actual PDU */
+
+    /* Needs to be at least as long as:
+       - fixed header bytes
+       - tag for data
+       - at least one byte of MAC PDU payload */
+    if ((size_t)tvb_length_remaining(tvb, offset) < (3+2)) {
+        return;
+    }
+
+    /* If redissecting, use previous info struct (if available) */
+    p_mac_lte_info = p_get_proto_data(pinfo->fd, proto_mac_lte);
+    if (p_mac_lte_info == NULL) {
+        /* Allocate new info struct for this frame */
+        p_mac_lte_info = se_alloc0(sizeof(struct mac_lte_info));
+        infoAlreadySet = FALSE;
+    }
+    else {
+        infoAlreadySet = TRUE;
+    }
+
+    /* Dissect the fields to populate p_mac_lte */
+    if (!dissect_mac_lte_context_fields(p_mac_lte_info, tvb, &offset)) {
+        return;
+    }
+
+
+    if (!infoAlreadySet) {
+        /* Store info in packet */
+        p_add_proto_data(pinfo->fd, proto_mac_lte, p_mac_lte_info);
+    }
+
+    /**************************************/
+    /* OK, now dissect as MAC LTE         */
+
+    /* Create tvb that starts at actual MAC PDU */
+    mac_tvb = tvb_new_subset(tvb, offset, -1, tvb_reported_length(tvb)-offset);
+    call_dissector_only(mac_lte_handle, mac_tvb, pinfo, tree);
+}
+
+void proto_register_mac_lte_framed(void)
+{
+    static hf_register_info hf[] =
+    {
+    };
+
+    static gint *ett[] =
+    {
+    };
+
+    /* Register protocol. */
+    proto_mac_lte_framed = proto_register_protocol("mac-lte-framed", "MAC-LTE-FRAMED", "mac-lte-framed");
+    proto_register_field_array(proto_mac_lte_framed, hf, array_length(hf));
+    proto_register_subtree_array(ett, array_length(ett));
+
+    /* Allow other dissectors to find this one by name. */
+    register_dissector("mac-lte-framed", dissect_mac_lte_framed, proto_mac_lte_framed);
+}
+
index 3b57dd87da4ca4edd3b49c5e4412210b02a47c68..5e76e0d86fa49247fbc6aecaced8fc492448372d 100644 (file)
@@ -926,59 +926,19 @@ static void call_with_catch_all(dissector_handle_t handle, tvbuff_t* tvb, packet
     ENDTRY
 }
 
-/* Heuristic dissector looks for supported framing protocol (see wiki page)  */
-static gboolean dissect_mac_lte_heur(tvbuff_t *tvb, packet_info *pinfo,
-                                     proto_tree *tree)
+/* Dissect context fields in the format described in packet-mac-lte.h.
+   Return TRUE if the necessary information was successfully found */
+gboolean dissect_mac_lte_context_fields(struct mac_lte_info  *p_mac_lte_info, tvbuff_t *tvb,
+                                        gint *p_offset)
 {
-    gint                 offset = 0;
-    struct mac_lte_info  *p_mac_lte_info;
-    tvbuff_t             *mac_tvb;
-    guint8               tag = 0;
-    gboolean             infoAlreadySet = FALSE;
-
-    /* This is a heuristic dissector, which means we get all the UDP
-     * traffic not sent to a known dissector and not claimed by
-     * a heuristic dissector called before us!
-     */
-
-    if (!global_mac_lte_heur) {
-        return FALSE;
-    }
-
-    /* Do this again on re-dissection to re-discover offset of actual PDU */
-
-    /* Needs to be at least as long as:
-       - the signature string
-       - fixed header bytes
-       - tag for data
-       - at least one byte of MAC PDU payload */
-    if ((size_t)tvb_length_remaining(tvb, offset) < (strlen(MAC_LTE_START_STRING)+3+2)) {
-        return FALSE;
-    }
-
-    /* OK, compare with signature string */
-    if (tvb_strneql(tvb, offset, MAC_LTE_START_STRING, strlen(MAC_LTE_START_STRING)) != 0) {
-        return FALSE;
-    }
-    offset += (gint)strlen(MAC_LTE_START_STRING);
-
-    /* If redissecting, use previous info struct (if available) */
-    p_mac_lte_info = p_get_proto_data(pinfo->fd, proto_mac_lte);
-    if (p_mac_lte_info == NULL) {
-        /* Allocate new info struct for this frame */
-        p_mac_lte_info = se_alloc0(sizeof(struct mac_lte_info));
-        infoAlreadySet = FALSE;
-    }
-    else {
-        infoAlreadySet = TRUE;
-    }
-
+    gint    offset = *p_offset;
+    guint8  tag = 0;
 
     /* Read fixed fields */
     p_mac_lte_info->radioType = tvb_get_guint8(tvb, offset++);
     p_mac_lte_info->direction = tvb_get_guint8(tvb, offset++);
 
-    /* TODO: add this info to framing protocol */
+    /* TODO: currently no support for detailed PHY info... */
     if (p_mac_lte_info->direction == DIRECTION_UPLINK) {
         p_mac_lte_info->detailed_phy_info.ul_info.present = FALSE;
     }
@@ -1050,6 +1010,64 @@ static gboolean dissect_mac_lte_heur(tvbuff_t *tvb, packet_info *pinfo,
         }
     }
 
+    /* Pass out where offset is now */
+    *p_offset = offset;
+
+    return TRUE;
+}
+
+/* Heuristic dissector looks for supported framing protocol (see wiki page)  */
+static gboolean dissect_mac_lte_heur(tvbuff_t *tvb, packet_info *pinfo,
+                                     proto_tree *tree)
+{
+    gint                 offset = 0;
+    struct mac_lte_info  *p_mac_lte_info;
+    tvbuff_t             *mac_tvb;
+    gboolean             infoAlreadySet = FALSE;
+
+    /* This is a heuristic dissector, which means we get all the UDP
+     * traffic not sent to a known dissector and not claimed by
+     * a heuristic dissector called before us!
+     */
+
+    if (!global_mac_lte_heur) {
+        return FALSE;
+    }
+
+    /* Do this again on re-dissection to re-discover offset of actual PDU */
+
+    /* Needs to be at least as long as:
+       - the signature string
+       - fixed header bytes
+       - tag for data
+       - at least one byte of MAC PDU payload */
+    if ((size_t)tvb_length_remaining(tvb, offset) < (strlen(MAC_LTE_START_STRING)+3+2)) {
+        return FALSE;
+    }
+
+    /* OK, compare with signature string */
+    if (tvb_strneql(tvb, offset, MAC_LTE_START_STRING, strlen(MAC_LTE_START_STRING)) != 0) {
+        return FALSE;
+    }
+    offset += (gint)strlen(MAC_LTE_START_STRING);
+
+    /* If redissecting, use previous info struct (if available) */
+    p_mac_lte_info = p_get_proto_data(pinfo->fd, proto_mac_lte);
+    if (p_mac_lte_info == NULL) {
+        /* Allocate new info struct for this frame */
+        p_mac_lte_info = se_alloc0(sizeof(struct mac_lte_info));
+        infoAlreadySet = FALSE;
+    }
+    else {
+        infoAlreadySet = TRUE;
+    }
+
+    /* Dissect the fields to populate p_mac_lte */
+    if (!dissect_mac_lte_context_fields(p_mac_lte_info, tvb, &offset)) {
+        return FALSE;
+    }
+
+
     if (!infoAlreadySet) {
         /* Store info in packet */
         p_add_proto_data(pinfo->fd, proto_mac_lte, p_mac_lte_info);
index 9c9742d76695b505ddde8a0c7f773f08deb83734..a1cce9ac71a9f9a054043eeacb2de60488558df5 100644 (file)
@@ -263,3 +263,7 @@ void set_mac_lte_channel_mapping(guint16 ueid, guint8 lcid,
 mac_lte_info *get_mac_lte_proto_data(packet_info *pinfo);
 void set_mac_lte_proto_data(packet_info *pinfo, mac_lte_info *p_mac_lte_info);
 
+/* Function to attempt to populate p_mac_lte_info using framing definition above */
+gboolean dissect_mac_lte_context_fields(struct mac_lte_info  *p_mac_lte_info, tvbuff_t *tvb,
+                                        gint *p_offset);
+