[PATCH 2/2] wireshark: Honor API change coming with 1.12 release

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At wireshark, they have this promise to change public dissector APIs
only with minor version number change. Which they did when releasing
the version of 1.12.

Firstly, they've changed tvb_memdup() in
a0c53ffaa1bb46d8c9db2ec739401aa411c9790e so now it takes four arguments
instead of three. The new argument is placed at the very beginning of
the list of arguments and basically says the scope where we'd like to
allocate the memory. According to the documentation NULL should be the
default value.

Then, the tcp_dissect_pdus() signature changed too. Well, the function
that actually dissects reassembled packets as tcp_dissect_pdus()
reorder TCP packets into one big chunk and then calls a user function
to dissect the PDU at once. The change is dated back to
8081cf1d90397cbbb4404f9720595e1537ed5e14.

Then, WS_DLL_PUBLIC_NOEXTERN was replaced with WS_DLL_PUBLIC_DEF in
5d87a8c46171f572568db5a47c093423482e342f.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 tools/wireshark/src/packet-libvirt.c    | 32 +++++++++++++++++++++++++++++++-
 tools/wireshark/util/make-dissector-reg |  7 +++++++
 2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/tools/wireshark/src/packet-libvirt.c b/tools/wireshark/src/packet-libvirt.c
index 5138453..0fe5f03 100644
--- a/tools/wireshark/src/packet-libvirt.c
+++ b/tools/wireshark/src/packet-libvirt.c
@@ -36,6 +36,16 @@
 #include "packet-libvirt.h"
 #include "internal.h"
 
+#define WIRESHARK_VERSION               \
+    ((VERSION_MAJOR * 1000 * 1000) +    \
+     (VERSION_MINOR * 1000) +           \
+     (VERSION_MICRO))
+
+/* Wireshark 1.12 brings API change */
+#if WIRESHARK_VERSION < 1012000
+# define WIRESHARK_COMPAT
+#endif
+
 static int proto_libvirt = -1;
 static int hf_libvirt_length = -1;
 static int hf_libvirt_program = -1;
@@ -307,7 +317,11 @@ dissect_libvirt_payload_xdr_data(tvbuff_t *tvb, proto_tree *tree, gint payload_l
     }
 
     payload_tvb = tvb_new_subset(tvb, start, -1, payload_length);
+#ifdef WIRESHARK_COMPAT
     payload_data = (caddr_t)tvb_memdup(payload_tvb, 0, payload_length);
+#else
+    payload_data = (caddr_t)tvb_memdup(NULL, payload_tvb, 0, payload_length);
+#endif
     xdrmem_create(&xdrs, payload_data, payload_length, XDR_DECODE);
 
     dissect(payload_tvb, tree, &xdrs, -1);
@@ -350,8 +364,14 @@ dissect_libvirt_payload(tvbuff_t *tvb, proto_tree *tree,
     proto_tree_add_item(tree, hf_libvirt_unknown, tvb, VIR_HEADER_LEN, -1, ENC_NA);
 }
 
+#ifdef WIRESHARK_COMPAT
 static void
 dissect_libvirt_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+#else
+static int
+dissect_libvirt_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
+                        void *opaque ATTRIBUTE_UNUSED)
+#endif
 {
     goffset offset;
     guint32 prog, proc, type, serial, status;
@@ -411,6 +431,10 @@ dissect_libvirt_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
         /* Dissect payload remaining */
         dissect_libvirt_payload(tvb, libvirt_tree, prog, proc, type, status);
     }
+
+#ifndef WIRESHARK_COMPAT
+    return 0;
+#endif
 }
 
 static guint32
@@ -424,7 +448,13 @@ dissect_libvirt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 {
     /* Another magic const - 4; simply, how much bytes
      * is needed to tell the length of libvirt packet. */
-    tcp_dissect_pdus(tvb, pinfo, tree, TRUE, 4, get_message_len, dissect_libvirt_message);
+#ifdef WIRESHARK_COMPAT
+    tcp_dissect_pdus(tvb, pinfo, tree, TRUE, 4,
+                     get_message_len, dissect_libvirt_message);
+#else
+    tcp_dissect_pdus(tvb, pinfo, tree, TRUE, 4,
+                     get_message_len, dissect_libvirt_message, NULL);
+#endif
 }
 
 void
diff --git a/tools/wireshark/util/make-dissector-reg b/tools/wireshark/util/make-dissector-reg
index 4f8b4f2..6fa25c1 100755
--- a/tools/wireshark/util/make-dissector-reg
+++ b/tools/wireshark/util/make-dissector-reg
@@ -55,6 +55,13 @@ then
 #define WS_BUILD_DLL
 #include "ws_symbol_export.h"
 
+/* In 1.12 wireshark WS_DLL_PUBLIC_NOEXTERN was substitued with
+ * WS_DLL_PUBLIC_DEF. See wireshark's commit
+ * 5d87a8c46171f572568db5a47c093423482e342f for more info. */
+#ifndef WS_DLL_PUBLIC_NOEXTERN
+# define WS_DLL_PUBLIC_NOEXTERN WS_DLL_PUBLIC_DEF
+#endif
+
 #ifndef ENABLE_STATIC
 WS_DLL_PUBLIC_NOEXTERN const gchar version[] = VERSION;
 
-- 
1.8.5.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]