Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windivert/60x/v1 #8837

Merged
merged 3 commits into from May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
88 changes: 86 additions & 2 deletions .github/workflows/builds.yml
Expand Up @@ -1430,8 +1430,8 @@ jobs:
- run: suricata-update -V
- run: suricatasc -h

windows-msys2-mingw64:
name: Windows MSYS2 MINGW64
windows-msys2-mingw64-npcap:
name: Windows MSYS2 MINGW64 (NPcap)
runs-on: windows-latest
needs: [prepare-deps]
defaults:
Expand Down Expand Up @@ -1480,3 +1480,87 @@ jobs:
PATH="$PATH:$(pwd)" python3 ./suricata-verify/run.py
- run: make install
- run: suricata-update -V

windows-msys2-mingw64-libpcap:
name: Windows MSYS2 MINGW64 (libpcap)
runs-on: windows-latest
needs: [prepare-deps]
defaults:
run:
shell: msys2 {0}
steps:
- uses: actions/checkout@v2
- uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
install: git mingw-w64-x86_64-toolchain automake1.16 automake-wrapper autoconf libtool libyaml-devel pcre-devel jansson-devel make mingw-w64-x86_64-libyaml mingw-w64-x86_64-pcre mingw-w64-x86_64-rust mingw-w64-x86_64-jansson unzip p7zip python-setuptools mingw-w64-x86_64-python-yaml mingw-w64-x86_64-jq mingw-w64-x86_64-libxml2 libpcap-devel mingw-w64-x86_64-libpcap
# hack: install our own cbindgen system wide as we can't get the
# preinstalled one to be picked up by configure
- name: cbindgen
run: cargo install --root /usr --force --debug --version 0.14.1 cbindgen
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: prep
path: prep
- run: tar xf prep/libhtp.tar.gz
- run: tar xf prep/suricata-update.tar.gz
- run: tar xf prep/suricata-verify.tar.gz
- name: Build
run: |
./autogen.sh
CFLAGS="-ggdb -Werror" ./configure --enable-unittests --enable-gccprotect --disable-gccmarch-native --disable-shared --with-libpcap-includes=/npcap/Include --with-libpcap-libraries=/npcap/Lib/x64
make -j3
- name: Run
run: |
./src/suricata --build-info
./src/suricata -u -l /tmp/
python3 ./suricata-verify/run.py -q

windows-msys2-mingw64-windivert:
name: Windows MSYS2 MINGW64 (WinDivert)
runs-on: windows-latest
needs: [prepare-deps]
defaults:
run:
shell: msys2 {0}
steps:
- name: Cache ~/.cargo
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7
with:
path: ~/.cargo
key: ${{ github.job }}-cargo
- uses: actions/checkout@v3.3.0
- uses: msys2/setup-msys2@fa138fa56e2558760b9f2205135313c7345c5f3f
with:
msystem: MINGW64
update: true
install: git mingw-w64-x86_64-toolchain automake1.16 automake-wrapper autoconf libtool libyaml-devel pcre-devel jansson-devel make mingw-w64-x86_64-libyaml mingw-w64-x86_64-pcre mingw-w64-x86_64-rust mingw-w64-x86_64-jansson unzip p7zip python-setuptools mingw-w64-x86_64-python-yaml mingw-w64-x86_64-jq mingw-w64-x86_64-libxml2 libpcap-devel mingw-w64-x86_64-libpcap
# hack: install our own cbindgen system wide as we can't get the
# preinstalled one to be picked up by configure
- name: cbindgen
run: cargo install --root /usr --force --debug --version 0.24.3 cbindgen
- uses: actions/checkout@v3.3.0
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
with:
name: prep
path: prep
- run: tar xf prep/libhtp.tar.gz
- name: WinDivert
run: |
curl -sL -O https://github.com/basil00/Divert/releases/download/v1.4.3/WinDivert-1.4.3-A.zip
unzip WinDivert-1.4.3-A.zip -d /windivert
cp /windivert/WinDivert-1.4.3-A/x86_64/* /usr/lib/
# hack: place dlls in cwd
cp /windivert/WinDivert-1.4.3-A/x86_64/*.dll .
- name: Build
run: |
./autogen.sh
CFLAGS="-ggdb -Werror" ./configure --enable-gccprotect --disable-gccmarch-native --disable-shared --enable-windivert --with-windivert-include=/windivert/WinDivert-1.4.3-A/include --with-windivert-libraries=/windivert/WinDivert-1.4.3-A/x86_64
make -j3
- name: Run
run: |
# need cwd in path due to dlls (see above)
PATH="$PATH:$(pwd)" ./src/suricata --build-info
- run: make install
62 changes: 29 additions & 33 deletions configure.ac
Expand Up @@ -241,7 +241,6 @@

e_magic_file=""
e_magic_file_comment="#"
PCAP_LIB_NAME="pcap"
case "$host" in
*-*-*freebsd*)
LUA_LIB_NAME="lua-5.1"
Expand All @@ -268,14 +267,14 @@
*-*-mingw32*|*-*-msys)
CFLAGS="${CFLAGS} -DOS_WIN32"
WINDOWS_PATH="yes"
PCAP_LIB_NAME="wpcap"
AC_DEFINE([HAVE_NON_POSIX_MKDIR], [1], [mkdir is not POSIX compliant: single arg])
RUST_LDADD=" -lws2_32 -liphlpapi -lwbemuuid -lOle32 -lOleAut32 -lUuid -luserenv -lshell32 -ladvapi32 -lgcc_eh -lbcrypt"
TRY_WPCAP="yes"
;;
*-*-cygwin)
LUA_LIB_NAME="lua"
WINDOWS_PATH="yes"
PCAP_LIB_NAME="wpcap"
TRY_WPCAP="yes"
;;
*-*-solaris*)
AC_MSG_WARN([support for Solaris/Illumos/SunOS is experimental])
Expand Down Expand Up @@ -1325,46 +1324,43 @@
#define _DEFAULT_SOURCE 1
]])

LIBPCAP=""
PKG_CHECK_MODULES([PCAP],libpcap,[CPPFLAGS="${CPPFLAGS} ${PCAP_CFLAGS}" LIBS="${LIBS} ${PCAP_LIBS}"],[:])
AC_CHECK_LIB(${PCAP_LIB_NAME}, pcap_open_live,, LIBPCAP="no")
if test "$LIBPCAP" = "no"; then
echo
echo " ERROR! libpcap library not found, go get it"
echo " from http://www.tcpdump.org or your distribution:"
echo
echo " Ubuntu: apt-get install libpcap-dev"
echo " Fedora: dnf install libpcap-devel"
echo " CentOS/RHEL: yum install libpcap-devel"
echo
exit 1
have_wpcap=""
if test "$TRY_WPCAP" = "yes"; then
AC_CHECK_LIB(wpcap, pcap_activate, [], have_wpcap="no")
if test "$have_wpcap" = "no"; then
echo ""
echo " Warning: NPCap was not found. Live capture will not be available."
echo ""
else
PCAP_LIB_NAME="wpcap"
have_wpcap="yes"
fi
fi

# pcap_activate and pcap_create only exists in libpcap >= 1.0
LIBPCAPVTEST=""
#To prevent duping the lib link we reset LIBS after this check. Setting action-if-found to NULL doesn't seem to work
#see: http://blog.flameeyes.eu/2008/04/29/i-consider-ac_check_lib-harmful
TMPLIBS="${LIBS}"
AC_CHECK_LIB(${PCAP_LIB_NAME}, pcap_activate,, LPCAPVTEST="no")
if test "$LPCAPVTEST" = "no"; then
echo
echo " ERROR! libpcap library too old, need at least 1+, "
echo " go get it from http://www.tcpdump.org or your distribution:"
echo
echo " Ubuntu: apt-get install libpcap-dev"
echo " Fedora: dnf install libpcap-devel"
echo " CentOS/RHEL: yum install libpcap-devel"
echo
exit 1
if test "$have_wpcap" != "yes"; then
AC_CHECK_LIB(pcap, pcap_open_dead, [], [
echo
echo " ERROR! libpcap library not found, go get it"
echo " from http://www.tcpdump.org or your distribution:"
echo
echo " Ubuntu: apt-get install libpcap-dev"
echo " Fedora: dnf install libpcap-devel"
echo " CentOS/RHEL: yum install libpcap-devel"
echo
exit 1
])
PCAP_LIB_NAME="pcap"
fi

PKG_CHECK_MODULES([PCAP],libpcap,[CPPFLAGS="${CPPFLAGS} ${PCAP_CFLAGS}" LIBS="${LIBS} ${PCAP_LIBS}"],[:])

AC_PATH_PROG(HAVE_PCAP_CONFIG, pcap-config, "no")
if test "$HAVE_PCAP_CONFIG" = "no" -o "$cross_compiling" = "yes"; then
AC_MSG_RESULT(no pcap-config is use)
else
PCAP_CFLAGS="$(pcap-config --defines) $(pcap-config --cflags)"
AC_SUBST(PCAP_CFLAGS)
fi
LIBS="${TMPLIBS}"

#Appears as if pcap_set_buffer_size is linux only?
LIBPCAPSBUFF=""
Expand Down