[PATCH 4/5] wireshark: Replace WIRESHARK_COMPAT with actual version comparison

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

 



In the upcoming patch we will need yet another #ifdef code block
depending on wireshark version. Instead of defining
WIRESHARK_COMPAT2 or something lets just compare the version
right at the place so that we can clearly see what version broke
API.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 tools/wireshark/src/packet-libvirt.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/tools/wireshark/src/packet-libvirt.c b/tools/wireshark/src/packet-libvirt.c
index d0b0852..ac120b5 100644
--- a/tools/wireshark/src/packet-libvirt.c
+++ b/tools/wireshark/src/packet-libvirt.c
@@ -36,16 +36,12 @@
 #include "packet-libvirt.h"
 #include "internal.h"
 
+/* Wireshark 1.12 brings API change */
 #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;
@@ -316,7 +312,7 @@ 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
+#if WIRESHARK_VERSION < 1012000
     payload_data = (caddr_t)tvb_memdup(payload_tvb, 0, payload_length);
 #else
     payload_data = (caddr_t)tvb_memdup(NULL, payload_tvb, 0, payload_length);
@@ -362,7 +358,7 @@ 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
+#if WIRESHARK_VERSION < 1012000
 static void
 dissect_libvirt_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 #else
@@ -430,7 +426,7 @@ dissect_libvirt_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
         dissect_libvirt_payload(tvb, libvirt_tree, prog, proc, type, status);
     }
 
-#ifndef WIRESHARK_COMPAT
+#if WIRESHARK_VERSION >= 1012000
     return 0;
 #endif
 }
@@ -446,7 +442,7 @@ 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. */
-#ifdef WIRESHARK_COMPAT
+#if WIRESHARK_VERSION < 1012000
     tcp_dissect_pdus(tvb, pinfo, tree, TRUE, 4,
                      get_message_len, dissect_libvirt_message);
 #else
-- 
2.4.10

--
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]