From a181ff7acd52decf4c09764e8aa4138dda3cbf97 Mon Sep 17 00:00:00 2001
From: Christophe Baribaud <christophe.baribaud@gmail.com>
Date: Thu, 20 Sep 2012 11:30:32 +0200
Subject: [PATCH 2/3] MSVC Windows and winsock2.h

With Microsoft Visual Studio, winsock2.h shall be included before
ws2tcpip.h

Signed-off-by: Christophe Baribaud <christophe.baribaud@gmail.com>
---
 ConfigureChecks.cmake |    4 ++--
 src/pcap.c            |    1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 77cca0b..f20fac9 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -46,11 +46,11 @@ check_include_file(pty.h HAVE_PTY_H)
 check_include_file(termios.h HAVE_TERMIOS_H)
 
 if (WIN32)
-  check_include_file(wspiapi.h HAVE_WSPIAPI_H)
+  check_include_files("winsock2.h;ws2tcpip.h;wspiapi.h" HAVE_WSPIAPI_H)
   if (NOT HAVE_WSPIAPI_H)
     message(STATUS "WARNING: Without wspiapi.h, this build will only work on Windows XP and newer versions")
   endif (NOT HAVE_WSPIAPI_H)
-  check_include_file(ws2tcpip.h HAVE_WS2TCPIP_H)
+  check_include_files("winsock2.h;ws2tcpip.h" HAVE_WS2TCPIP_H)
   if (HAVE_WSPIAPI_H OR HAVE_WS2TCPIP_H)
     set(HAVE_GETADDRINFO TRUE)
     set(HAVE_GETHOSTBYNAME TRUE)
diff --git a/src/pcap.c b/src/pcap.c
index cc96863..dbaf765 100644
--- a/src/pcap.c
+++ b/src/pcap.c
@@ -25,6 +25,7 @@
 
 #include <stdio.h>
 #ifdef _WIN32
+#include <winsock2.h>
 #include <ws2tcpip.h>
 #else
 #include <netinet/in.h>
-- 
1.7.7

