Wireshark-dev: Re: [Wireshark-dev] GUI Change for Wireshark Remote Interfaces

From: Joerg Mayer <jmayer@xxxxxxxxx>
Date: Fri, 28 Oct 2016 01:18:12 +0200
On Thu, Oct 27, 2016 at 12:09:20PM -0700, Guy Harris wrote:
> On Oct 27, 2016, at 11:28 AM, Roland Knall <rknall@xxxxxxxxx> wrote:
> 
> > Guy, is the version on github for libpcap already equipped with pcap_open on Mac?
> 
> The current version on github has pcap_open() in pcap-new.c; *however*:
> 
> 	1) it's not in Makefile.in, so it doesn't show up if you do autotools builds;
> 	
> 	2) it's only in CMake builds if HAVE_REMOTE is defined, which is done by default only on Windows;
> 
> 	3) I have not tested whether it builds and is useful on any UN*X platform - it might not work.

1) SEP ;-)

2) Easy to fix

3) It will neither compile nor link.

The attached patch will make it compile and link - nothing else was tested
mkdir build; cd build; cmake -DHAVE_REMOTE=ON ..; make

Feel free to ignore, modify or apply the patch (the policy 42 stuff fixes
the symptom instead of the root cause).

 Jörg
-- 
Joerg Mayer                                           <jmayer@xxxxxxxxx>
We are stuck with technology when what we really want is just stuff that
works. Some say that should read Microsoft instead of technology.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0ed8b61..d4cdc7d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,8 @@
 cmake_minimum_required( VERSION 2.8.8 )
+# MACOSX_RPATH: Requires at least 2.8.12
+if (POLICY CMP0042)
+        cmake_policy(SET CMP0042 OLD)
+endif()
 
 project( pcap )
 #
@@ -23,13 +27,11 @@ if( WIN32 )
     set(PACKET_DLL_DIR "" CACHE PATH "Path to directory with include and lib subdirectories for packet.dll")
 endif( WIN32 )
 
-#
-# XXX - this should be an option, defaulting to "yes" for Windows and to
-# "no", for now, on UN*X.
-#
 if( WIN32 )
-    set( HAVE_REMOTE 1 )
-endif( WIN32 )
+    option (HAVE_REMOTE "Enable remote capture" ON)
+else()
+    option (HAVE_REMOTE "Enable remote capture" OFF)
+endif()
 
 ######################################
 # Project settings
diff --git a/cmakeconfig.h.in b/cmakeconfig.h.in
index 94edb5f..7a09d73 100644
--- a/cmakeconfig.h.in
+++ b/cmakeconfig.h.in
@@ -166,6 +166,9 @@
 /* Define to 1 if you have the `strlcpy' function. */
 #cmakedefine HAVE_STRLCPY 1
 
+/* Define to 1 if you have the `strtok_r' function. */
+#cmakedefine HAVE_STRTOK_R 1
+
 /* Define to 1 if the system has the type `struct BPF_TIMEVAL'. */
 #cmakedefine HAVE_STRUCT_BPF_TIMEVAL 1
 
diff --git a/pcap/pcap.h b/pcap/pcap.h
index 7f92a37..c15bd1c 100644
--- a/pcap/pcap.h
+++ b/pcap/pcap.h
@@ -172,11 +172,11 @@ struct pcap_stat {
 	u_int ps_recv;		/* number of packets received */
 	u_int ps_drop;		/* number of packets dropped */
 	u_int ps_ifdrop;	/* drops by interface -- only supported on some platforms */
-#if defined(_WIN32) && defined(HAVE_REMOTE)
+#if defined(HAVE_REMOTE)
 	u_int ps_capt;		/* number of packets that reach the application */
 	u_int ps_sent;		/* number of packets sent by the server on the network */
 	u_int ps_netdrop;	/* number of packets lost on the network */
-#endif /* _WIN32 && HAVE_REMOTE */
+#endif /* HAVE_REMOTE */
 };
 
 #ifdef MSDOS