Skip to content

Commit b2b839d

Browse files
ofalkAntonkraj
authored
Release 1.16.4 (#87)
1.16.4 release * Correct path to string.h (from bsd); Fixes #74 * Update RPM spec * Get rid of distutils from Python and use setuptools * Update author information * Add missing aux files * Init cmake with github actions (#81) * configure: Replace use of AC_EGREP_CPP (#85) Many thanks to the supporters!!! Signed-off-by: Oliver Falk <[email protected]> Co-authored-by: Anton <[email protected]> Co-authored-by: Khem Raj <[email protected]> Co-authored-by: Joshua Root
1 parent 0517cc9 commit b2b839d

File tree

21 files changed

+3128
-1925
lines changed

21 files changed

+3128
-1925
lines changed

.github/workflows/cmake.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: cmake
2+
3+
'on':
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
- develop
9+
- feature/**
10+
11+
env:
12+
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
13+
BUILD_TYPE: Release
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-${{ matrix.ubuntu_version }}
18+
name: Ubuntu-${{ matrix.ubuntu_version }}
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
ubuntu_version: [22.04]
23+
shared: [ON, OFF]
24+
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v3
28+
with:
29+
fetch-depth: 0
30+
31+
32+
- name: Install packages
33+
run: |
34+
sudo apt-get install -y gcc g++ cmake wget git
35+
36+
37+
- name: Configure
38+
run: cmake -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DBUILD_SHARED_LIBS=${{ matrix.shared }} -B "${{github.workspace}}/build"
39+
40+
- name: Build
41+
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
42+
43+
MSVC:
44+
name: windows-${{ matrix.win_version }}
45+
runs-on: windows-${{ matrix.win_version }}
46+
strategy:
47+
fail-fast: false
48+
matrix:
49+
win_version: [2019, 2022]
50+
shared: [ON, OFF]
51+
52+
steps:
53+
- name: Checkout
54+
uses: actions/checkout@v3
55+
with:
56+
fetch-depth: 0
57+
58+
- name: Configure CMake
59+
run: cmake -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DBUILD_SHARED_LIBS=${{ matrix.shared }} -B "${{github.workspace}}/build"
60+
61+
- name: Build
62+
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

CMakeLists.txt

Lines changed: 281 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,281 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
3+
project(libdnet VERSION 1.16.4 LANGUAGES C)
4+
5+
find_package(TCL)
6+
7+
include(CheckFunctionExists)
8+
include(CheckIncludeFile)
9+
include(CheckStructHasMember)
10+
include(CheckSymbolExists)
11+
include(CheckTypeSize)
12+
include(CheckCSourceCompiles)
13+
14+
set(WINDOWS_EXPORT_ALL_SYMBOLS True)
15+
option(BUILD_SHARED_LIBS "Build in shared lib mode" OFF)
16+
17+
foreach (header stdio.h stdlib.h string.h inttypes.h)
18+
string(TOUPPER HAVE_${header} var)
19+
string(REGEX REPLACE "\\.|/" "_" var ${var})
20+
check_include_file(${header} ${var})
21+
endforeach ()
22+
23+
if (MSVC)
24+
add_definitions(-DWIN32_LEAN_AND_MEAN)
25+
check_include_file(winsock2.h HAVE_WINSOCK2_H)
26+
set(HAVE_LIBWS2_32 ${HAVE_WINSOCK2_H})
27+
check_c_source_compiles("
28+
#define WIN32_LEAN_AND_MEAN
29+
#include <windows.h>
30+
#include <Iphlpapi.h>
31+
int main() { return 0; }"
32+
HAVE_IPHLPAPI_H)
33+
set(HAVE_LIBIPHLPAPI ${HAVE_IPHLPAPI_H})
34+
set(CMAKE_REQUIRED_LIBRARIES "ws2_32")
35+
check_symbol_exists(inet_pton WS2tcpip.h HAVE_INET_PTON)
36+
set(CMAKE_REQUIRED_LIBRARIES )
37+
endif()
38+
if(UNIX)
39+
foreach (header strings.h
40+
unistd.h sys/bufmod.h sys/dlpi.h sys/dlpihdr.h sys/dlpi_ext.h
41+
sys/ioctl.h sys/mib.h sys/ndd_var.h sys/socket.h sys/sockio.h
42+
sys/sysctl.h sys/time.h sys/stat.h net/bpf.h net/if.h net/if_var.h
43+
net/if_arp.h net/if_dl.h net/pfilt.h
44+
net/pfvar.h net/radix.h net/raw.h net/route.h netinet/in_var.h
45+
net/if_tun.h linux/if_tun.h netinet/ip_fw.h linux/ip_fw.h
46+
linux/ip_fwchains.h linux/netfilter_ipv4/ipchains_core.h
47+
ip_fil_compat.h netinet/ip_fil_compat.h ip_compat.h
48+
netinet/ip_compat.h ip_fil.h netinet/ip_fil.h
49+
hpsecurity.h stropts.h dlfcn.h fcntl.h)
50+
string(TOUPPER HAVE_${header} var)
51+
string(REGEX REPLACE "\\.|/" "_" var ${var})
52+
check_include_file(${header} ${var})
53+
endforeach ()
54+
endif()
55+
56+
set(CMAKE_REQUIRED_LIBRARIES )
57+
foreach (func err strlcat strlcpy strse)
58+
string(TOUPPER HAVE_${func} var)
59+
check_function_exists(${func} ${var})
60+
endforeach ()
61+
62+
if (UNIX)
63+
set(CMAKE_REQUIRED_LIBRARIES "nm")
64+
check_function_exists(open_mib HAVE_OPEN_MIB)
65+
set(CMAKE_REQUIRED_LIBRARIES )
66+
67+
CHECK_STRUCT_HAS_MEMBER("struct arpreq" arp_dev net/if_arp.h HAVE_ARPREQ_ARP_DEV LANGUAGE C)
68+
CHECK_STRUCT_HAS_MEMBER("struct sockaddr" sa_len sys/socket.h HAVE_SOCKADDR_SA_LEN LANGUAGE C)
69+
check_symbol_exists(rt_msghdr net/route.h HAVE_ROUTE_RT_MSGHDR)
70+
71+
set(CMAKE_EXTRA_INCLUDE_FILES "netinet/in.h")
72+
check_type_size("struct sockaddr_in6" HAVE_SOCKADDR_IN6 LANGUAGE C)
73+
set(CMAKE_EXTRA_INCLUDE_FILES )
74+
75+
find_file(HAVE_BSD_BPFH
76+
NAMES /dev/bpf0
77+
DOC "Check for the Berkeley Packet Filter")
78+
79+
80+
file(STRINGS /proc/sys/kernel/ostype PROCFS)
81+
message(STATUS "${PROCFS}")
82+
if (${PROCFS} STREQUAL "Linux")
83+
set(HAVE_LINUX_PROCFS True)
84+
endif()
85+
86+
check_include_file(inet/mib2.h HAVE_STREAMS_MIB2)
87+
88+
check_symbol_exists(ETH_P_ALL linux/if_ether.h HAVE_LINUX_PF_PACKET)
89+
90+
check_symbol_exists(RTSTR_SEND net/route.h HAVE_STREAMS_ROUTE)
91+
92+
check_symbol_exists(SIOCGARP sys/ioctl.h HAVE_IOCTL_ARP)
93+
94+
string(TOLOWER ${CMAKE_SYSTEM_NAME} CMAKE_SYSTEM_NAME_LOWER)
95+
96+
string(REGEX MATCH "bsd" BSD ${CMAKE_SYSTEM_NAME_LOWER})
97+
string(REGEX MATCH "darwin" DARWIN ${CMAKE_SYSTEM_NAME_LOWER})
98+
string(REGEX MATCH "osf" OSF ${CMAKE_SYSTEM_NAME_LOWER})
99+
string(REGEX MATCH "unixware" UNIXWARE ${CMAKE_SYSTEM_NAME_LOWER})
100+
string(REGEX MATCH "openbsd" OPENBSD ${CMAKE_SYSTEM_NAME_LOWER})
101+
string(REGEX MATCH "solaris" SOLARIS ${CMAKE_SYSTEM_NAME_LOWER})
102+
string(REGEX MATCH "irix" IRIX ${CMAKE_SYSTEM_NAME_LOWER})
103+
string(REGEX MATCH "freebsd5" FREEBSD5 ${CMAKE_SYSTEM_NAME_LOWER})
104+
string(REGEX MATCH "kfreebsd" KFREEBSD ${CMAKE_SYSTEM_NAME_LOWER})
105+
106+
if (${BSD} OR ${DARWIN} OR ${OSF} OR ${UNIXWARE})
107+
set(HAVE_RAWIP_HOST_OFFLEN True)
108+
endif()
109+
110+
if (${OPENBSD})
111+
set(HAVE_RAWIP_HOST_OFFLEN False)
112+
endif()
113+
114+
if (${SOLARIS} OR ${IRIX})
115+
set(HAVE_RAWIP_COOKED True)
116+
endif()
117+
118+
set(CMAKE_REQUIRED_LIBRARIES )
119+
foreach (func err strlcat strlcpy strse)
120+
string(TOUPPER HAVE_${func} var)
121+
check_function_exists(${func} ${var})
122+
endforeach ()
123+
124+
125+
126+
set(CMAKE_REQUIRED_LIBRARIES nsl socket)
127+
check_function_exists(gethostbyname HAVE_GETHOSTBYNAME)
128+
if (NOT HAVE_GETHOSTBYNAME)
129+
unset(HAVE_GETHOSTBYNAME CACHE)
130+
set(CMAKE_REQUIRED_LIBRARIES nsl)
131+
check_function_exists(gethostbyname HAVE_GETHOSTBYNAME)
132+
if (NOT HAVE_GETHOSTBYNAME)
133+
unset(HAVE_GETHOSTBYNAME CACHE)
134+
set(CMAKE_REQUIRED_LIBRARIES)
135+
check_function_exists(gethostbyname HAVE_GETHOSTBYNAME)
136+
endif()
137+
endif()
138+
set(CMAKE_REQUIRED_LIBRARIES )
139+
check_function_exists(gethostbyaddr HAVE_GETHOSTBYADDR)
140+
check_function_exists(gethostname HAVE_GETHOSTNAME)
141+
endif (UNIX)
142+
143+
check_function_exists(inet_ntoa HAVE_INET_NTOA)
144+
check_function_exists(memset HAVE_MEMSET)
145+
check_function_exists(select HAVE_SELECT)
146+
check_function_exists(socket HAVE_SOCKET)
147+
check_function_exists(strerror HAVE_STRERROR)
148+
check_function_exists(strsep HAVE_STRSEP)
149+
150+
set(CMAKE_REQUIRED_LIBRARIES str)
151+
check_function_exists(putmsg HAVE_PUTMSG)
152+
set(CMAKE_REQUIRED_LIBRARIES )
153+
154+
set(PACKAGE ${PROJECT_NAME})
155+
set(PACKAGE_BUGREPORT)
156+
set(PACKAGE_NAME ${PROJECT_NAME})
157+
set(PACKAGE_STRING "${PROJECT_NAME} ${CMAKE_PROJECT_VERSION}")
158+
set(PACKAGE_TARNAME ${PROJECT_NAME})
159+
set(PACKAGE_URL)
160+
set(PACKAGE_VERSION ${CMAKE_PROJECT_VERSION})
161+
set(VERSION ${CMAKE_PROJECT_VERSION})
162+
163+
configure_file(config.h.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
164+
165+
set(PLATFORM_SOURCES)
166+
167+
if (NOT HAVE_STRLCAT)
168+
list(APPEND PLATFORM_SOURCES src/strlcat.c)
169+
endif()
170+
if (NOT HAVE_STRLCPY)
171+
list(APPEND PLATFORM_SOURCES src/strlcpy.c)
172+
endif()
173+
if (NOT HAVE_STRSEP)
174+
list(APPEND PLATFORM_SOURCES src/strsep.c)
175+
endif()
176+
177+
178+
if (HAVE_ROUTE_RT_MSGHDR)
179+
list(APPEND PLATFORM_SOURCES src/arp-bsd.c)
180+
elseif (HAVE_IOCTL_ARP)
181+
list(APPEND PLATFORM_SOURCES src/arp-ioctl.c)
182+
elseif (HAVE_IPHLPAPI_H)
183+
list(APPEND PLATFORM_SOURCES src/arp-win32.c)
184+
else()
185+
list(APPEND PLATFORM_SOURCES src/arp-none.c)
186+
endif()
187+
188+
if (HAVE_IPHLPAPI_H)
189+
# no npcap support
190+
# list(APPEND PLATFORM_SOURCES src/eth-win32.c)
191+
elseif(HAVE_NET_PFILT_H)
192+
list(APPEND PLATFORM_SOURCES src/eth-pfilt.c)
193+
elseif(HAVE_BSD_BPF)
194+
list(APPEND PLATFORM_SOURCES src/eth-bsd.c)
195+
elseif(HAVE_LINUX_PF_PACKET)
196+
list(APPEND PLATFORM_SOURCES src/eth-linux.c)
197+
elseif(HAVE_NET_RAW_H)
198+
list(APPEND PLATFORM_SOURCES src/eth-snoop.c)
199+
elseif(HAVE_SYS_NDD_VAR_H)
200+
list(APPEND PLATFORM_SOURCES src/eth-ndd.c)
201+
elseif(HAVE_SYS_DLPI_H OR HAVE_SYS_DLPIHDR_H)
202+
list(APPEND PLATFORM_SOURCES src/eth-dlpi.c)
203+
else()
204+
list(APPEND PLATFORM_SOURCES src/eth-none.c)
205+
endif()
206+
207+
if (HAVE_IPHLPAPI_H)
208+
list(APPEND PLATFORM_SOURCES src/fw-pktfilter.c)
209+
elseif(HAVE_NET_PFVAR_H)
210+
list(APPEND PLATFORM_SOURCES src/fw-pf.c)
211+
elseif(HAVE_NETINET_IP_FW_H)
212+
if (FREEBSD5 OR KFREEBSD)
213+
list(APPEND PLATFORM_SOURCES src/fw-none.c)
214+
else()
215+
list(APPEND PLATFORM_SOURCES src/fw-ipfw.c)
216+
endif()
217+
elseif(HAVE_IP_FIL_H)
218+
list(APPEND PLATFORM_SOURCES src/fw-ipf.c)
219+
elseif(HAVE_LINUX_IP_FW_H OR HAVE_LINUX_IP_FWCHAINS_H OR HAVE_LINUX_NETFILTER_IPV4_IPCHAINS_CORE_H)
220+
list(APPEND PLATFORM_SOURCES src/fw-ipchains.c)
221+
else()
222+
list(APPEND PLATFORM_SOURCES src/fw-none.c)
223+
endif()
224+
225+
if (HAVE_IPHLPAPI_H)
226+
list(APPEND PLATFORM_SOURCES src/intf-win32.c)
227+
else()
228+
list(APPEND PLATFORM_SOURCES src/intf.c)
229+
endif()
230+
231+
if (HAVE_IPHLPAPI_H)
232+
list(APPEND PLATFORM_SOURCES src/ip-win32.c)
233+
elseif(HAVE_RAWIP_COOKED)
234+
list(APPEND PLATFORM_SOURCES src/ip-cooked.c)
235+
else()
236+
list(APPEND PLATFORM_SOURCES src/ip.c)
237+
endif()
238+
239+
if (HAVE_IPHLPAPI_H)
240+
list(APPEND PLATFORM_SOURCES src/route-win32.c)
241+
elseif(HAVE_ROUTE_RT_MSGHDR)
242+
list(APPEND PLATFORM_SOURCES src/route-bsd.c)
243+
elseif(HAVE_LINUX_PROCFS)
244+
list(APPEND PLATFORM_SOURCES src/route-linux.c)
245+
elseif(HAVE_HPSECURITY_H)
246+
list(APPEND PLATFORM_SOURCES src/route-hpux.c)
247+
else()
248+
list(APPEND PLATFORM_SOURCES src/route-none.c)
249+
endif()
250+
251+
if(HAVE_LINUX_PROCFS)
252+
list(APPEND PLATFORM_SOURCES src/ndisc-linux.c)
253+
else()
254+
list(APPEND PLATFORM_SOURCES src/ndisc-none.c)
255+
endif()
256+
257+
find_file(HAVE_DEV_TUN
258+
NAMES /dev/tun0
259+
DOC "Check for tun0")
260+
261+
if(HAVE_LINUX_IF_TUN_H)
262+
list(APPEND PLATFORM_SOURCES src/tun-linux.c)
263+
elseif(HAVE_NET_IF_TUN_H)
264+
if(HAVE_STROPTS_H)
265+
list(APPEND PLATFORM_SOURCES src/tun-solaris.c)
266+
else()
267+
list(APPEND PLATFORM_SOURCES src/tun-bsd.c)
268+
endif()
269+
elseif(HAVE_DEV_TUN)
270+
list(APPEND PLATFORM_SOURCES src/tun-bsd.c)
271+
else()
272+
list(APPEND PLATFORM_SOURCES src/tun-none.c)
273+
endif()
274+
275+
add_library(${PROJECT_NAME} src/addr-util.c src/addr.c src/blob.c src/ip-util.c src/ip6.c src/rand.c ${PLATFORM_SOURCES})
276+
277+
target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/include ${CMAKE_CURRENT_BINARY_DIR} )
278+
279+
if (MSVC)
280+
target_link_libraries(${PROJECT_NAME} PUBLIC Iphlpapi ws2_32)
281+
endif()

Makefile.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ SED = @SED@
317317
SET_MAKE = @SET_MAKE@
318318
SHELL = @SHELL@
319319
STRIP = @STRIP@
320+
STRLCPY_HEADER = @STRLCPY_HEADER@
320321
TCLINC = @TCLINC@
321322
TCLLIB = @TCLLIB@
322323
VERSION = @VERSION@

0 commit comments

Comments
 (0)