Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ foreach (header stdio.h stdlib.h string.h inttypes.h)
check_include_file(${header} ${var})
endforeach ()

if (MSVC)
if (WIN32)
add_definitions(-DWIN32_LEAN_AND_MEAN)
check_include_file(winsock2.h HAVE_WINSOCK2_H)
set(HAVE_LIBWS2_32 ${HAVE_WINSOCK2_H})
Expand All @@ -36,6 +36,16 @@ if (MSVC)
set(CMAKE_REQUIRED_LIBRARIES "ws2_32")
check_symbol_exists(inet_pton WS2tcpip.h HAVE_INET_PTON)
set(CMAKE_REQUIRED_LIBRARIES )

if (NPCAP_SDK)
get_filename_component(NPCAP_SDK "${NPCAP_SDK}" ABSOLUTE)
set(NPCAP_SDK_INCLUDE "${NPCAP_SDK}/Include")
set(CMAKE_REQUIRED_INCLUDES ${NPCAP_SDK_INCLUDE})
check_include_file(Packet32.h HAVE_PACKET32_H)
set(CMAKE_REQUIRED_INCLUDES )
else()
message(WARNING "NPCAP_SDK not specified; building without Npcap support")
endif()
endif()
if(UNIX)
foreach (header strings.h
Expand Down Expand Up @@ -190,9 +200,8 @@ else()
list(APPEND PLATFORM_SOURCES src/arp-none.c)
endif()

if (HAVE_IPHLPAPI_H)
# no npcap support
# list(APPEND PLATFORM_SOURCES src/eth-win32.c)
if (HAVE_PACKET32_H)
list(APPEND PLATFORM_SOURCES src/eth-win32.c)
elseif(HAVE_NET_PFILT_H)
list(APPEND PLATFORM_SOURCES src/eth-pfilt.c)
elseif(HAVE_LINUX_PF_PACKET)
Expand Down Expand Up @@ -325,8 +334,13 @@ set_target_properties(
PUBLIC_HEADER "${DNET_HEADERS}"
)

if (MSVC)
if (WIN32)
target_link_libraries(${PROJECT_NAME} PUBLIC Iphlpapi ws2_32)
if (HAVE_PACKET32_H)
target_include_directories(${PROJECT_NAME} PUBLIC ${NPCAP_SDK_INCLUDE})
target_link_directories(${PROJECT_NAME} PUBLIC ${NPCAP_SDK}/Libs/)
target_link_libraries(${PROJECT_NAME} PUBLIC Packet)
endif()
endif()

install(TARGETS ${PROJECT_NAME}
Expand Down
2 changes: 1 addition & 1 deletion include/dnet/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
typedef u_char uint8_t;
typedef u_short uint16_t;
typedef u_int uint32_t;
# ifndef __CYGWIN__
# if !defined(__CYGWIN__) && !defined(__MINGW32__)
typedef long ssize_t;
# endif
#else
Expand Down