Windows build: #include winsock2.h only when needed.
authorwmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 24 Oct 2008 00:42:09 +0000 (00:42 +0000)
committerwmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 24 Oct 2008 00:42:09 +0000 (00:42 +0000)
#include winsock2.h pulls in about 90 distinct .h files
and about 140 total .h files.
Currently winsock2.h is (mostly unnecessarily) included
for each dissector via packet.h/wtap.h.
This patch removes #include winsock2.h from wtap.h and
then includes winsock2.h (or windows.h) in the
few specific places required.
With this patch, my Windows Wireshark build takes
about 30% less time.

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

15 files changed:
airpcap.h
capture_wpcap_packet.c
editcap.c
epan/dissectors/packet-dcom.c
epan/dissectors/packet-dtls.c
epan/dissectors/packet-frame.c
epan/dissectors/packet-ieee80211.c
epan/dissectors/packet-ssl.c
gtk/capture_if_details_dlg_win32.c
gtk/file_dlg_win32.c
gtk/gui_utils.c
gtk/mcast_stream.c
gtk/sctp_stat.h
wiretap/wtap-int.h
wiretap/wtap.h

index 639a930a70ef25c8aac1e98b0630c969ed73e3b0..7bc4a8820995e09863d6894796ae75488878c771 100644 (file)
--- a/airpcap.h
+++ b/airpcap.h
 #pragma warning( disable : 4996)
 #endif
 
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h>
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
index d26da5f8f4fdfb59f8d89d5186a47be468533db3..6729e0c8389bb563cb4bc6b3ea3b04d88ccc9307 100644 (file)
@@ -34,7 +34,6 @@
 #include <glib.h>
 #include <gmodule.h>
 
-#include <wtap.h>
 #include <pcap.h>
 
 /* XXX - yes, I know, I should move cppmagic.h to a generic location. */
 
 #include <epan/value_string.h>
 
+#include <Packet32.h>
+#include <windows.h>
+#include <windowsx.h>
+#include <Ntddndis.h>
 
+#include "capture_wpcap_packet.h"
 
 /* packet32.h requires sockaddr_storage 
- * wether sockaddr_storage is defined or not depends on the Platform SDK 
+ * whether sockaddr_storage is defined or not depends on the Platform SDK 
  * version installed. The only one not defining it is the SDK that comes
  * with MSVC 6.0 (WINVER 0x0400).
  *
  * copied from RFC2553 (and slightly modified because of datatypes) ...
  * XXX - defined more than once, move this to a header file */
+#ifndef WINVER
+#error WINVER not defined ....
+#endif
 #if (WINVER <= 0x0400) && defined(_MSC_VER)
 typedef unsigned short eth_sa_family_t;
 
@@ -85,13 +92,6 @@ struct sockaddr_storage {
 #endif /* WINVER */
 
 
-#include <Packet32.h>
-#include <windows.h>
-#include <windowsx.h>
-#include <Ntddndis.h>
-
-#include "capture_wpcap_packet.h"
-
 gboolean has_wpacket = FALSE;
 
 
index 84ecd0a727f51b8f2d6cc4097891fd9657845b27..88a5e16ed37a0f55dc2670740c24e17489114cc1 100644 (file)
--- a/editcap.c
+++ b/editcap.c
@@ -48,6 +48,9 @@
 
 #ifdef _WIN32
 #include <process.h>    /* getpid */
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h>
+#endif
 #endif
 
 #ifdef NEED_STRPTIME_H
index fe7597ea0cb29e0592430844c907f25f6f510910..fa70e9443d521bcc327d41c23f7e2a2ac82423de 100644 (file)
 #include <netinet/in.h>
 #endif
 
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h>
+#endif
+
 #include <string.h>
 
 #include <glib.h>
index 8fc671227c8d36ff050325c2733c06eee63e0d0f..0bae8971ccc0d3ecc3220706b5736b48868167b6 100644 (file)
 #include <sys/socket.h>
 #endif
 
+#if HAVE_WINSOCK2_H
+#include <winsock2.h>
+#endif
+
 #include <glib.h>
 
 #include <epan/conversation.h>
index d37d073d62fc4a9d3f19fff53cbfee962e6f1b3a..1077373482a1a6cc989c1f861ffd15039ba35443 100644 (file)
 # include "config.h"
 #endif
 
+#ifdef _MSC_VER
+#include <windows.h>
+#endif
+
+
 #include <glib.h>
 #include <epan/packet.h>
 #include <epan/timestamp.h>
index bf08c4b22991d8b2de74f5a7be3ac3e6eb920189..d20d65fe01ae3bfb0347027e1a229d922142d87c 100644 (file)
 
 #include "packet-wps.h"
 
-#ifdef HAVE_AIRPCAP
-#include <airpcap.h>
-#include <airpcap_loader.h>
-#else
-/* XXX - This is probably a bit much */
-#define MAX_ENCRYPTION_KEYS 64
-#endif
-
 #ifndef roundup2
 #define        roundup2(x, y)  (((x)+((y)-1))&(~((y)-1)))  /* if y is powers of two */
 #endif
index 8e025cba5a8a44e9bfa4ff0d95b35be7c10451e7..5e86372a028cc069e70e8ec22f0f4bbfc1e6ad0f 100644 (file)
 #ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
 #endif
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h>
+#endif
 
 #include <glib.h>
 
index 8577a01767592a3908559616716b9c5ce214294d..d6c3f2318a759c3645115e011bfe445d638fad35 100644 (file)
@@ -40,9 +40,7 @@
 #include "../globals.h"
 #include "../file.h"
 #include "../capture.h"
-#include "../capture_wpcap_packet.h"
 #include "../simple_dialog.h"
-#include <wiretap/wtap.h>
 
 #include "gtk/main.h"
 #include "gtk/dlg_utils.h"
 #include "gtk/gtkvumeter.h"
 #include "gtk/capture_if_details_dlg_win32.h"
 
+#include <Packet32.h>
+#include <windows.h>
+#include <windowsx.h>
+#include <Ntddndis.h>
 
+#include "../capture_wpcap_packet.h"
 
 /* packet32.h requires sockaddr_storage 
- * wether sockaddr_storage is defined or not depends on the Platform SDK 
+ * whether sockaddr_storage is defined or not depends on the Platform SDK 
  * version installed. The only one not defining it is the SDK that comes
  * with MSVC 6.0 (WINVER 0x0400).
  *
  * copied from RFC2553 (and slightly modified because of datatypes) ...
  * XXX - defined more than once, move this to a header file */
+#ifndef WINVER
+#error WINVER not defined ...
+#endif
 #if (WINVER <= 0x0400) && defined(_MSC_VER)
 typedef unsigned short eth_sa_family_t;
 
@@ -93,11 +99,6 @@ struct sockaddr_storage {
 /* ... copied from RFC2553 */
 #endif /* WINVER */
 
-#include <Packet32.h>
-#include <windows.h>
-#include <windowsx.h>
-#include <Ntddndis.h>
-
 #define DETAILS_STR_MAX     1024
 
 
index 5afcafd92f442e026721a93203b4d4d56183163f..2dc1eced57687be3f4caa7d087097f6371c24e58 100644 (file)
 #include <io.h>
 #include <fcntl.h>
 
+#include <windows.h>
+#include <windowsx.h>
+#include <commdlg.h>
+#include <richedit.h>
+
+
 #include <gtk/gtk.h>
 
 #include "epan/filesystem.h"
 #include "gtk/file_dlg_win32.h"
 #include "gtk/help_dlg.h"
 
-#include <windows.h>
-#include <windowsx.h>
-#include <commdlg.h>
-#include <richedit.h>
-
 typedef enum {
     merge_append,
     merge_chrono,
index 0a9415649ca06ac72bebcbbe4bae5bba08997437..6ecea32a45947a8cf8b2b71bb8e6ef6ffd15e8b6 100644 (file)
@@ -45,6 +45,9 @@
 
 #include "image/wsicon16.xpm"
 
+#ifdef _WIN32
+#include <windows.h>
+#endif
 
 #define WINDOW_GEOM_KEY "window_geom"
 
index c4ab0456448c004dcff85437efcbe2c46ba402b7..e6d07b3f2f7dde5e89934c7cc0ff2efed57bec8b 100644 (file)
@@ -59,7 +59,9 @@
 #include "gtk/mcast_stream_dlg.h"
 #include "gtk/main.h"
 
-
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h>
+#endif
 
 gint32 trigger=50; /* limit for triggering the burst alarm (in packets per second) */
 gint32 bufferalarm = 10000; /* limit for triggernig the buffer alarm (in bytes) */
index 60694e852c1cc9be26e31c348c5c652a43cfff17..02aa0f92c5ba3a583e90f6607c3be3356261eada 100644 (file)
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
+#else
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h>
+#endif
 #endif
 
 #define SCTP_DATA_CHUNK_ID               0
index cd63fd937aa8bb887b59d7f749794901b2ecc649..757703c298a2a4f69a84f7b0a873d7012386d4ad 100644 (file)
 #include <stdio.h>
 #include <time.h>
 
-#ifdef HAVE_LIBZ
 #ifdef HAVE_WINSOCK2_H
 #include <winsock2.h>
 #endif
+
+#ifdef HAVE_LIBZ
 #include <zlib.h>
 #define FILE_T gzFile
 #else /* No zLib */
index 5f9678959a66478f1e40a8f9c7ba7ecff86d99a3..9968a7bdc33456e9ca4fb404799c039c4e52d615 100644 (file)
 #include <sys/time.h>
 #endif
 
-#ifdef HAVE_WINSOCK2_H
-# include <winsock2.h>
-#endif
-
 #include <glib.h>
 #include <stdio.h>
 #include <time.h>