aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/build.yml28
-rw-r--r--.gitignore1
-rwxr-xr-xautogen.sh16
-rw-r--r--configure.ac25
-rw-r--r--example/Makefile.in39
-rw-r--r--example/ndpiReader.c86
-rw-r--r--example/ndpiSimpleIntegration.c30
-rw-r--r--example/reader_util.c66
-rw-r--r--influxdb/metric_anomaly.c2
-rw-r--r--rrdtool/rrd_similarity.c2
-rw-r--r--src/include/ndpi_define.h.in4
-rw-r--r--src/include/ndpi_includes_OpenBSD.h4
-rw-r--r--src/include/ndpi_utils.h5
-rw-r--r--src/include/ndpi_win32.h6
-rw-r--r--src/lib/Makefile.in5
-rw-r--r--src/lib/ndpi_analyze.c6
-rw-r--r--src/lib/ndpi_classify.c2
-rw-r--r--src/lib/ndpi_community_id.c6
-rw-r--r--src/lib/ndpi_main.c54
-rw-r--r--src/lib/ndpi_serializer.c98
-rw-r--r--src/lib/ndpi_utils.c43
-rw-r--r--src/lib/protocols/dhcp.c2
-rw-r--r--src/lib/protocols/kerberos.c56
-rw-r--r--src/lib/protocols/mail_imap.c4
-rw-r--r--src/lib/protocols/mining.c10
-rw-r--r--src/lib/protocols/telnet.c14
-rw-r--r--src/lib/protocols/tls.c53
-rw-r--r--src/lib/third_party/include/uthash.h2
-rw-r--r--src/lib/third_party/src/ahocorasick.c6
-rw-r--r--src/lib/third_party/src/gcrypt/gcm.c4
-rw-r--r--src/lib/third_party/src/gcrypt_light.c2
-rw-r--r--src/lib/third_party/src/roaring.cc10
-rw-r--r--tests/dga/Makefile.in23
-rwxr-xr-xtests/do.sh.in44
-rw-r--r--tests/result/kerberos_fuzz.pcapng.out2
-rw-r--r--tests/result/telnet.pcap.out3
-rw-r--r--tests/unit/Makefile.in35
-rw-r--r--tests/unit/unit.c21
-rw-r--r--windows/nDPI.vcxproj390
39 files changed, 468 insertions, 741 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 63f0b0431..548abe2e4 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -102,7 +102,7 @@ jobs:
name: ${{ matrix.os }} ${{ matrix.arch }} ${{ matrix.gcrypt }} ${{ matrix.compiler }} ${{ matrix.pcre }} ${{ matrix.maxminddb }} ${{ matrix.msan }}
runs-on: ${{ matrix.os }}
strategy:
- fail-fast: false # Debugging purposes, switch to true when all issues on Windows is solved
+ fail-fast: true
matrix:
os: ["ubuntu-latest", "ubuntu-18.04", "macOS-latest", "macos-11", "windows-latest"]
arch: ["x86_64"]
@@ -202,7 +202,7 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install autoconf automake libtool pkg-config gettext libjson-c-dev flex bison libpcap-dev
- sudo apt-get install libc6-dev
+ sudo apt-get install gcc-mingw-w64 libc6-dev
sudo apt-get install doxygen python3-sphinx python3-sphinx-rtd-theme python3-breathe python3-pip
sudo apt-get install rrdtool librrd-dev
- name: Install Ubuntu Prerequisites (libgcrypt)
@@ -225,13 +225,13 @@ jobs:
if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.arch, 'x86_64') && startsWith(matrix.compiler, 'clang')
run: |
sudo apt-get install ${{ matrix.compiler }}
- - name: Setup Windows prerequisites
+ - name: Install Windows prerequisites
if: startsWith(matrix.os, 'windows')
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
- install: git mingw-w64-x86_64-toolchain automake1.16 automake-wrapper autoconf libtool make mingw-w64-x86_64-json-c mingw-w64-x86_64-crt-git mingw-w64-x86_64-pcre
+ install: git mingw-w64-x86_64-toolchain automake1.16 automake-wrapper autoconf libtool make mingw-w64-x86_64-json-c mingw-w64-x86_64-crt-git mingw-w64-x86_64-pcre mingw-w64-x86_64-libpcap
- name: Setup Windows prerequisites (libgcrypt)
if: startsWith(matrix.os, 'windows') && startsWith(matrix.gcrypt, '--with-local-libgcrypt')
run: |
@@ -280,11 +280,12 @@ jobs:
- name: Configure nDPI on Windows
if: startsWith(matrix.os, 'windows') && startsWith(matrix.arch, 'x86_64') && startsWith(matrix.compiler, 'default-cc')
run: |
- msys2 -c './autogen.sh --enable-option-checking=fatal --enable-debug-messages --enable-tls-sigs ${{ matrix.gcrypt }}'
+ msys2 -c 'env CFLAGS="-Werror" ./autogen.sh --enable-option-checking=fatal --enable-debug-messages --enable-tls-sigs --disable-npcap ${{ matrix.gcrypt }}'
- name: Build nDPI on Windows
if: startsWith(matrix.os, 'windows') && startsWith(matrix.arch, 'x86_64') && startsWith(matrix.compiler, 'default-cc')
run: |
msys2 -c 'make all'
+ msys2 -c 'ldd ./example/ndpiReader.exe'
- name: Configure nDPI with specified GCC version on Ubuntu
if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.arch, 'x86_64') && startsWith(matrix.compiler, 'gcc')
run: |
@@ -316,6 +317,18 @@ jobs:
if: startsWith(matrix.arch, 'x86_64') && !startsWith(matrix.os, 'windows')
run: |
./tests/do-dga.sh
+ - name: Test nDPI [DIFF] (runs only on windows jobs)
+ if: startsWith(matrix.arch, 'x86_64') && startsWith(matrix.os, 'windows')
+ run: |
+ msys2 -c './tests/do.sh'
+ - name: Test nDPI [UNIT] (runs only on windows jobs)
+ if: startsWith(matrix.arch, 'x86_64') && startsWith(matrix.os, 'windows')
+ run: |
+ msys2 -c './tests/do-unit.sh'
+ - name: Test nDPI [DGA] (runs only on windows jobs)
+ if: startsWith(matrix.arch, 'x86_64') && startsWith(matrix.os, 'windows')
+ run: |
+ msys2 -c './tests/do-dga.sh'
- name: Generate tarball
if: startsWith(matrix.os, 'ubuntu-latest') && startsWith(matrix.arch, 'x86_64')
run: |
@@ -329,6 +342,8 @@ jobs:
- name: Build nDPI [Mingw-w64] (runs only on ubuntu jobs)
if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.arch, 'x86_64')
run: |
+ make distclean
+ env CFLAGS='-Werror' ./autogen.sh --enable-option-checking=fatal --enable-debug-messages --enable-tls-sigs --host=x86_64-w64-mingw32
make all
- name: Display qemu specified architecture (arm64 - little endian)
if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.arch, 'arm64')
@@ -347,6 +362,7 @@ jobs:
bash -c
"apt-get -y update &&
apt-get -y install git autoconf automake libtool pkg-config gettext libjson-c-dev flex bison libpcap-dev libgcrypt20-dev libpcre3-dev libmaxminddb-dev rrdtool librrd-dev &&
+ git config --global --add safe.directory $(realpath .) &&
env CC=gcc CFLAGS='-Werror' ./autogen.sh --enable-option-checking=fatal --enable-debug-messages ${{ matrix.gcrypt }} ${{ matrix.msan }} ${{ matrix.pcre }} ${{ matrix.maxminddb }} --enable-tls-sigs &&
make all &&
make -C example ndpiSimpleIntegration &&
@@ -371,6 +387,7 @@ jobs:
bash -c
"apt-get -y update &&
apt-get -y install git autoconf automake libtool pkg-config gettext libjson-c-dev flex bison libpcap-dev libgcrypt20-dev libpcre3-dev libmaxminddb-dev rrdtool librrd-dev &&
+ git config --global --add safe.directory $(realpath .) &&
env CC=gcc CFLAGS='-Werror' ./autogen.sh --enable-option-checking=fatal --enable-debug-messages ${{ matrix.gcrypt }} ${{ matrix.msan }} ${{ matrix.pcre }} ${{ matrix.maxminddb }} --enable-tls-sigs &&
make all &&
make -C example ndpiSimpleIntegration &&
@@ -395,6 +412,7 @@ jobs:
bash -c
"apt-get -y update &&
apt-get -y install git autoconf automake libtool pkg-config gettext libjson-c-dev flex bison libpcap-dev libgcrypt20-dev libpcre3-dev libmaxminddb-dev rrdtool librrd-dev &&
+ git config --global --add safe.directory $(realpath .) &&
env CC=gcc CFLAGS='-Werror' ./autogen.sh --enable-option-checking=fatal --enable-debug-messages ${{ matrix.gcrypt }} ${{ matrix.msan }} ${{ matrix.pcre }} ${{ matrix.maxminddb }} --enable-tls-sigs &&
make all &&
make -C example ndpiSimpleIntegration &&
diff --git a/.gitignore b/.gitignore
index 96a008778..9c22f92bf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -78,3 +78,4 @@ stamp-h1
/rrdtool/rrd_anomaly
/rrdtool/rrd_similarity
/tests/performance/Makefile
+/influxdb/Makefile
diff --git a/autogen.sh b/autogen.sh
index 0aa75079d..3dec4c03e 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -8,32 +8,38 @@ LIBTOOL=$(command -v libtool)
LIBTOOLIZE=$(command -v libtoolize)
AUTORECONF=$(command -v autoreconf)
PKG_CONFIG=$(command -v pkg-config)
+MAKE=$(command -v make)
-if test -z $AUTOCONF; then
+if test -z "${AUTOCONF}"; then
echo "autoconf is missing: please install it and try again"
exit
fi
-if test -z $AUTOMAKE; then
+if test -z "${AUTOMAKE}"; then
echo "automake is missing: please install it and try again"
exit
fi
-if test -z $LIBTOOL && test -z $LIBTOOLIZE ; then
+if test -z "${LIBTOOL}" && test -z "${LIBTOOLIZE}"; then
echo "libtool and libtoolize is missing: please install it and try again"
exit
fi
-if test -z $AUTORECONF; then
+if test -z "${AUTORECONF}"; then
echo "autoreconf is missing: please install it and try again"
exit
fi
-if test -z $PKG_CONFIG; then
+if test -z "${PKG_CONFIG}"; then
echo "pkg-config is missing: please install it (apt-get install pkg-config) and try again"
exit
fi
+if test -z "${MAKE}"; then
+ echo "make is missing; please install it (apt-get install make) and try again"
+ exit
+fi
+
autoreconf -ivf
echo "./configure $@"
diff --git a/configure.ac b/configure.ac
index ce31803c7..13716e363 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7,7 +7,7 @@ AM_INIT_AUTOMAKE([foreign subdir-objects])
AC_PREFIX_DEFAULT(/usr)
-EXTRA_TARGETS="example tests tests/unit tests/dga"
+EXTRA_TARGETS="example tests tests/dga"
AC_ARG_WITH(only-libndpi, AS_HELP_STRING([--with-only-libndpi], [Build only libndpi (no examples, tests etc)]))
AS_IF([test "${with_only_libndpi+set}" = set],[
EXTRA_TARGETS=""
@@ -18,6 +18,7 @@ AC_ARG_ENABLE(fuzztargets, AS_HELP_STRING([--enable-fuzztargets], [Enable fuzz t
AC_ARG_ENABLE(code-coverage, AS_HELP_STRING([--enable-code-coverage], [Generate Code Coverage report]))
AC_ARG_WITH(local-libgcrypt, AS_HELP_STRING([--with-local-libgcrypt], [Build with libgcrypt (if present) instead of the enclosed gcrypt light]))
AC_ARG_ENABLE(tls-sigs, AS_HELP_STRING([--enable-tls-sigs], [Enable TLS Client signature algorithm dissection. Rarely used, but requires significantly more memory.]))
+AC_ARG_ENABLE(npcap, AS_HELP_STRING([--disable-npcap], [msys2 only: Disable linkage against the wpcap/npcap import library in windows/WpdPack/Lib.]))
AS_IF([test "x$enable_fuzztargets" = "xyes"], [BUILD_FUZZTARGETS=1], [BUILD_FUZZTARGETS=0])
AM_CONDITIONAL([BUILD_FUZZTARGETS], [test "x$enable_fuzztargets" = "xyes"])
@@ -32,6 +33,8 @@ AS_IF([test "x${enable_code_coverage}" = "xyes"],[
LDFLAGS="${LDFLAGS} --coverage"
])
+AS_IF([test "${enable_npcap+set}" = set],[DISABLE_NPCAP=1],[DISABLE_NPCAP=0])
+
LT_INIT
LT_LIB_M
PKG_PROG_PKG_CONFIG
@@ -96,12 +99,12 @@ AC_DEFINE_UNQUOTED(NDPI_GIT_DATE, "${GIT_DATE}", [Last GIT change])
if ! test "${with_only_libndpi+set}" = set; then :
dnl> used by json-c for unit tests
- PKG_CHECK_MODULES([JSONC], [json-c], [JSONC_LIBS="${pkg_cv_JSONC_LIBS}" JSONC_CFLAGS="${pkg_cv_JSONC_CFLAGS}"])
- AC_CHECK_LIB([json-c], [json_object_put], [], [
+ PKG_CHECK_MODULES([JSONC], [json-c], [JSONC_LIBS="${pkg_cv_JSONC_LIBS}" JSONC_CFLAGS="${pkg_cv_JSONC_CFLAGS}"],
+ [AC_MSG_WARN([JSON-C not available. Disabled unit test.])])
+ AC_CHECK_LIB([json-c], [json_object_put], [EXTRA_TARGETS="$EXTRA_TARGETS tests/unit"], [
AC_MSG_WARN([JSON-C not available. Disabled unit test.])
JSONC_LIBS=""
JSONC_CFLAGS=""
- EXTRA_TARGETS="example tests tests/dga"
])
AX_PTHREAD([],[
AC_MSG_WARN([POSIX Threads not available. Building library only.])
@@ -117,7 +120,7 @@ AS_IF([test "x${enable_tls_sigs}" = "xyes"],[
])
LIBS="$LIBS $JSONC_LIBS"
-CFLAGS="-W -Wall -Wno-unused-parameter -Wno-unused-function $CFLAGS $JSONC_CFLAGS"
+CFLAGS="-W -Wall -Wno-unused-parameter -Wno-unused-function -Wno-address-of-packed-member $CFLAGS $JSONC_CFLAGS"
AC_CHECK_HEADERS([netinet/in.h stdint.h stdlib.h string.h unistd.h math.h float.h])
AC_CHECK_LIB([m], [sqrt], [], [LIBM="-lm"])
@@ -170,16 +173,22 @@ case "$host" in
case "$host" in
x86_64-*)
BUILD_MINGW_X64=1
+ LDFLAGS="${LDFLAGS} -L/mingw64/lib"
;;
i686-*)
+ LDFLAGS="${LDFLAGS} -L/mingw32/lib"
;;
*)
AC_MSG_ERROR([Unsupported MingW cross compiler.])
;;
esac
- CFLAGS="${CFLAGS}"
+ CFLAGS="-D__USE_MINGW_ANSI_STDIO -D__STDC_FORMAT_MACROS ${CFLAGS}"
LIBS="${LIBS} -lws2_32"
BUILD_MINGW=1
+ EXE_SUFFIX=".exe"
+ AS_IF([test "${enable_npcap+set}" != set && test "${with_only_libndpi+set}" != set],,
+ [PKG_CHECK_MODULES([PCAP], [libpcap], [PCAP_LIB="" PCAP_INC="${pkg_cv_PCAP_CFLAGS}"])
+ AC_CHECK_LIB([pcap], [pcap_open_live],, [AC_MSG_ERROR([Missing msys2/mingw libpcap library. Install it with `pacman -S mingw-w64-x86_64-libpcap' (msys2).])])])
;;
*)
if test -f $PCAP_HOME/libpcap/libpcap.a; then :
@@ -204,6 +213,8 @@ case "$host" in
AC_MSG_ERROR([Missing libpcap(-dev) library required to compile the example application.])
fi
fi
+ EXE_SUFFIX=""
+ AS_IF([test "${enable_npcap+set}" = set],AC_MSG_ERROR([--disable-npcap does only work with msys2/mingw CCs]))
;;
esac
@@ -310,4 +321,6 @@ AC_SUBST(JSONC_LIBS)
AC_SUBST(USE_HOST_LIBGCRYPT)
AC_SUBST(PCRE_ENABLED)
AC_SUBST(HANDLE_TLS_SIGS)
+AC_SUBST(DISABLE_NPCAP)
+AC_SUBST(EXE_SUFFIX)
AC_OUTPUT
diff --git a/example/Makefile.in b/example/Makefile.in
index bd4353997..a8b2b0a5b 100644
--- a/example/Makefile.in
+++ b/example/Makefile.in
@@ -3,8 +3,13 @@ CC=@CC@
CXX=@CXX@
BUILD_MINGW=@BUILD_MINGW@
BUILD_MINGW_X64=@BUILD_MINGW_X64@
+DISABLE_NPCAP=@DISABLE_NPCAP@
+EXE_SUFFIX=@EXE_SUFFIX@
SRCHOME=../src
-CFLAGS=-g -fPIC -DPIC -I$(SRCHOME)/include @PCAP_INC@ @CFLAGS@
+ifneq ($(OS),Windows_NT)
+CFLAGS+=-fPIC -DPIC
+endif
+CFLAGS+=-g -I$(SRCHOME)/include @PCAP_INC@ @CFLAGS@
LDFLAGS=@LDFLAGS@
LIBNDPI=$(SRCHOME)/lib/libndpi.a
LIBS=$(LIBNDPI) @PCAP_LIB@ @LIBS@ @ADDITIONAL_LIBS@
@@ -14,9 +19,14 @@ OBJS=ndpiReader.o reader_util.o intrusion_detection.o
PREFIX?=@prefix@
ifneq ($(BUILD_MINGW),)
-SUFFIX:=.exe
+
+ifeq ($(DISABLE_NPCAP),0)
CFLAGS+=-I@srcdir@/../windows/WpdPack/Include -I@srcdir@/../windows/WpdPack/Include/pcap
-LIBS+=-Wl,-Bstatic -lpthread -Wl,-Bdynamic
+else
+CFLAGS+=-DDISABLE_NPCAP
+endif
+
+ifeq ($(DISABLE_NPCAP),0)
ifneq ($(BUILD_MINGW_X64),)
LIBS+=@srcdir@/../windows/WpdPack/Lib/x64/wpcap.lib
@@ -24,13 +34,16 @@ else
LIBS+=@srcdir@/../windows/WpdPack/Lib/wpcap.lib
endif
-else
-
-LIBS+=-lpthread
+endif
+LIBS+=-Wl,-Bstatic -lpthread -Wl,-Bdynamic
+else
+LIBS+=-pthread
endif
-all: ndpiReader$(SUFFIX) @DPDK_TARGET@
+CFLAGS+=-pthread
+
+all: ndpiReader$(EXE_SUFFIX) @DPDK_TARGET@
EXECUTABLE_SOURCES := ndpiReader.c ndpiSimpleIntegration.c
COMMON_SOURCES := $(filter-out $(EXECUTABLE_SOURCES),$(wildcard *.c ))
@@ -38,22 +51,22 @@ COMMON_SOURCES := $(filter-out $(EXECUTABLE_SOURCES),$(wildcard *.c ))
libndpiReader.a: $(COMMON_SOURCES:%.c=%.o) $(LIBNDPI)
$(AR) rsv libndpiReader.a $(COMMON_SOURCES:%.c=%.o)
-ndpiReader$(SUFFIX): libndpiReader.a $(LIBNDPI) ndpiReader.o
+ndpiReader$(EXE_SUFFIX): libndpiReader.a $(LIBNDPI) ndpiReader.o
$(CC) $(CFLAGS) $(LDFLAGS) ndpiReader.o libndpiReader.a $(LIBS) -o $@
-ndpiSimpleIntegration$(SUFFIX): ndpiSimpleIntegration.o
+ndpiSimpleIntegration$(EXE_SUFFIX): ndpiSimpleIntegration.o
$(CC) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@
%.o: %.c $(HEADERS) Makefile
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
-install: ndpiReader$(SUFFIX)
+install: ndpiReader$(EXE_SUFFIX)
mkdir -p $(DESTDIR)$(PREFIX)/bin/
mkdir -p $(DESTDIR)$(PREFIX)/share/ndpi
- cp ndpiReader$(SUFFIX) $(DESTDIR)$(PREFIX)/bin/
+ cp ndpiReader$(EXE_SUFFIX) $(DESTDIR)$(PREFIX)/bin/
cp protos.txt $(DESTDIR)$(PREFIX)/share/ndpi/ndpiProtos.txt
cp mining_hosts.txt $(DESTDIR)$(PREFIX)/share/ndpi/ndpiCustomCategory.txt
- [ -f ndpiSimpleIntegration$(SUFFIX) ] && cp ndpiSimpleIntegration$(SUFFIX) $(DESTDIR)$(PREFIX)/bin/ndpiSimpleIntegration$(SUFFIX) || true
+ [ -f ndpiSimpleIntegration$(EXE_SUFFIX) ] && cp ndpiSimpleIntegration$(EXE_SUFFIX) $(DESTDIR)$(PREFIX)/bin/ndpiSimpleIntegration$(EXE_SUFFIX) || true
[ -f build/app/ndpiReader.dpdk ] && cp build/app/ndpiReader.dpdk $(DESTDIR)$(PREFIX)/bin/ || true
[ -f ndpiReader.dpdk ] && cp ndpiReader.dpdk $(DESTDIR)$(PREFIX)/bin/ || true
@@ -64,7 +77,7 @@ check:
cppcheck --template='{file}:{line}:{severity}:{message}' --quiet --enable=all --force -I$(SRCHOME)/include *.c
clean:
- /bin/rm -f *.o ndpiReader ndpiSimpleIntegration ndpiReader$(SUFFIX) ndpiSimpleIntegration$(SUFFIX) ndpiReader.dpdk
+ /bin/rm -f *.o ndpiReader ndpiSimpleIntegration ndpiReader$(EXE_SUFFIX) ndpiSimpleIntegration$(EXE_SUFFIX) ndpiReader.dpdk
/bin/rm -f .*.dpdk.cmd .*.o.cmd *.dpdk.map .*.o.d
/bin/rm -f _install _postbuild _postinstall _preinstall
/bin/rm -rf build
diff --git a/example/ndpiReader.c b/example/ndpiReader.c
index 2b02a75db..cd56feae7 100644
--- a/example/ndpiReader.c
+++ b/example/ndpiReader.c
@@ -26,11 +26,18 @@
#endif
#include <sched.h>
#endif
+
+#include "ndpi_api.h"
+#include "../src/lib/third_party/include/uthash.h"
+#include "../src/lib/third_party/include/ahocorasick.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#ifdef WIN32
#include <winsock2.h> /* winsock.h is included automatically */
+#include <windows.h>
+#include <ws2tcpip.h>
#include <process.h>
#include <io.h>
#define getopt getopt____
@@ -45,12 +52,10 @@
#include <search.h>
#include <pcap.h>
#include <signal.h>
+#include <time.h>
#include <pthread.h>
#include <assert.h>
#include <math.h>
-#include "ndpi_api.h"
-#include "../src/lib/third_party/include/uthash.h"
-#include "../src/lib/third_party/include/ahocorasick.h"
#include <sys/stat.h>
#include <fcntl.h>
#include <libgen.h>
@@ -667,7 +672,7 @@ void extcap_config() {
for(i=0; i<(int) ndpi_num_supported_protocols; i++) {
protos[i].id = i;
- snprintf(protos[i].name, sizeof(protos[i].name), "%s", proto_defaults[i].protoName);
+ ndpi_snprintf(protos[i].name, sizeof(protos[i].name), "%s", proto_defaults[i].protoName);
}
qsort(protos, ndpi_num_supported_protocols, sizeof(struct ndpi_proto_sorter), cmpProto);
@@ -1099,7 +1104,7 @@ static char* ipProto2Name(u_int16_t proto_id) {
break;
}
- snprintf(proto, sizeof(proto), "%u", proto_id);
+ ndpi_snprintf(proto, sizeof(proto), "%u", proto_id);
return(proto);
}
@@ -1533,7 +1538,7 @@ static void printFlow(u_int32_t id, struct ndpi_flow_info *flow, u_int16_t threa
if(flow->detected_protocol.master_protocol) {
char tmp[256];
- snprintf(tmp, sizeof(tmp), "%s.%s",
+ ndpi_snprintf(tmp, sizeof(tmp), "%s.%s",
ndpi_get_proto_name(ndpi_thread_info[thread_id].workflow->ndpi_struct,
flow->detected_protocol.master_protocol),
ndpi_get_proto_name(ndpi_thread_info[thread_id].workflow->ndpi_struct,
@@ -2155,9 +2160,9 @@ static void debug_printf(u_int32_t protocol, void *id_struct,
memset(buf, 0, sizeof(buf));
strftime(theDate, 32, "%d/%b/%Y %H:%M:%S", localtime_r(&theTime,&result));
- vsnprintf(buf, sizeof(buf)-1, format, va_ap);
+ ndpi_snprintf(buf, sizeof(buf)-1, format, va_ap);
- snprintf(out_buf, sizeof(out_buf), "%s %s%s", theDate, extra_msg, buf);
+ ndpi_snprintf(out_buf, sizeof(out_buf), "%s %s%s", theDate, extra_msg, buf);
printf("%s", out_buf);
fflush(stdout);
}
@@ -2248,21 +2253,21 @@ char* formatTraffic(float numBits, int bits, char *buf) {
unit = 'B';
if(numBits < 1024) {
- snprintf(buf, 32, "%lu %c", (unsigned long)numBits, unit);
+ ndpi_snprintf(buf, 32, "%lu %c", (unsigned long)numBits, unit);
} else if(numBits < (1024*1024)) {
- snprintf(buf, 32, "%.2f K%c", (float)(numBits)/1024, unit);
+ ndpi_snprintf(buf, 32, "%.2f K%c", (float)(numBits)/1024, unit);
} else {
float tmpMBits = ((float)numBits)/(1024*1024);
if(tmpMBits < 1024) {
- snprintf(buf, 32, "%.2f M%c", tmpMBits, unit);
+ ndpi_snprintf(buf, 32, "%.2f M%c", tmpMBits, unit);
} else {
tmpMBits /= 1024;
if(tmpMBits < 1024) {
- snprintf(buf, 32, "%.2f G%c", tmpMBits, unit);
+ ndpi_snprintf(buf, 32, "%.2f G%c", tmpMBits, unit);
} else {
- snprintf(buf, 32, "%.2f T%c", (float)(tmpMBits)/1024, unit);
+ ndpi_snprintf(buf, 32, "%.2f T%c", (float)(tmpMBits)/1024, unit);
}
}
}
@@ -2278,12 +2283,12 @@ char* formatTraffic(float numBits, int bits, char *buf) {
char* formatPackets(float numPkts, char *buf) {
if(numPkts < 1000) {
- snprintf(buf, 32, "%.2f", numPkts);
+ ndpi_snprintf(buf, 32, "%.2f", numPkts);
} else if(numPkts < (1000*1000)) {
- snprintf(buf, 32, "%.2f K", numPkts/1000);
+ ndpi_snprintf(buf, 32, "%.2f K", numPkts/1000);
} else {
numPkts /= (1000*1000);
- snprintf(buf, 32, "%.2f M", numPkts);
+ ndpi_snprintf(buf, 32, "%.2f M", numPkts);
}
return(buf);
@@ -2360,18 +2365,18 @@ char* formatBytes(u_int32_t howMuch, char *buf, u_int buf_len) {
char unit = 'B';
if(howMuch < 1024) {
- snprintf(buf, buf_len, "%lu %c", (unsigned long)howMuch, unit);
+ ndpi_snprintf(buf, buf_len, "%lu %c", (unsigned long)howMuch, unit);
} else if(howMuch < (1024*1024)) {
- snprintf(buf, buf_len, "%.2f K%c", (float)(howMuch)/1024, unit);
+ ndpi_snprintf(buf, buf_len, "%.2f K%c", (float)(howMuch)/1024, unit);
} else {
float tmpGB = ((float)howMuch)/(1024*1024);
if(tmpGB < 1024) {
- snprintf(buf, buf_len, "%.2f M%c", tmpGB, unit);
+ ndpi_snprintf(buf, buf_len, "%.2f M%c", tmpGB, unit);
} else {
tmpGB /= 1024;
- snprintf(buf, buf_len, "%.2f G%c", tmpGB, unit);
+ ndpi_snprintf(buf, buf_len, "%.2f G%c", tmpGB, unit);
}
}
@@ -3946,7 +3951,7 @@ void * processing_thread(void *_thread_id) {
}
} else
#endif
- if((!json_flag) && (!quiet_mode)) {
+ if((!quiet_mode)) {
#ifdef WIN64
printf("Running thread %lld...\n", thread_id);
#else
@@ -4019,11 +4024,6 @@ void test_lib() {
long thread_id;
#endif
-#ifdef HAVE_LIBJSON_C
- json_init();
- if(stats_flag) json_open_stats_file();
-#endif
-
#ifdef DEBUG_TRACE
if(trace) fprintf(trace, "Num threads: %d\n", num_threads);
#endif
@@ -4370,57 +4370,57 @@ void bpf_filter_pkt_peak_filter(json_object **jObj_bpfFilter,
while(i < p_size && port_array[i] != INIT_VAL) {
if(i+1 == p_size || port_array[i+1] == INIT_VAL)
- snprintf(&filter[l], sizeof(filter)-l, "%d", port_array[i]);
+ ndpi_snprintf(&filter[l], sizeof(filter)-l, "%d", port_array[i]);
else
- snprintf(&filter[l], sizeof(filter)-l, "%d or ", port_array[i]);
+ ndpi_snprintf(&filter[l], sizeof(filter)-l, "%d or ", port_array[i]);
i++;
}
- l += snprintf(&filter[l], sizeof(filter)-l, "%s", ")");
+ l += ndpi_snprintf(&filter[l], sizeof(filter)-l, "%s", ")");
produced = 1;
}
if(src_host_array[0] != NULL) {
if(port_array[0] != INIT_VAL)
- l += snprintf(&filter[l], sizeof(filter)-l, " and not (src ");
+ l += ndpi_snprintf(&filter[l], sizeof(filter)-l, " and not (src ");
else
- l += snprintf(&filter[l], sizeof(filter)-l, "not (src ");
+ l += ndpi_snprintf(&filter[l], sizeof(filter)-l, "not (src ");
i = 0;
while(i < sh_size && src_host_array[i] != NULL) {
if(i+1 == sh_size || src_host_array[i+1] == NULL)
- l += snprintf(&filter[l], sizeof(filter)-l, "%s", src_host_array[i]);
+ l += ndpi_snprintf(&filter[l], sizeof(filter)-l, "%s", src_host_array[i]);
else
- l += snprintf(&filter[l], sizeof(filter)-l, "%s or ", src_host_array[i]);
+ l += ndpi_snprintf(&filter[l], sizeof(filter)-l, "%s or ", src_host_array[i]);
i++;
}
- l += snprintf(&filter[l], sizeof(filter)-l, "%s", ")");
+ l += ndpi_snprintf(&filter[l], sizeof(filter)-l, "%s", ")");
produced = 1;
}
if(dst_host_array[0] != NULL) {
if(port_array[0] != INIT_VAL || src_host_array[0] != NULL)
- l += snprintf(&filter[l], sizeof(filter)-l, " and not (dst ");
+ l += ndpi_snprintf(&filter[l], sizeof(filter)-l, " and not (dst ");
else
- l += snprintf(&filter[l], sizeof(filter)-l, "not (dst ");
+ l += ndpi_snprintf(&filter[l], sizeof(filter)-l, "not (dst ");
i=0;
while(i < dh_size && dst_host_array[i] != NULL) {
if(i+1 == dh_size || dst_host_array[i+1] == NULL)
- l += snprintf(&filter[l], sizeof(filter)-l, "%s", dst_host_array[i]);
+ l += ndpi_snprintf(&filter[l], sizeof(filter)-l, "%s", dst_host_array[i]);
else
- l += snprintf(&filter[l], sizeof(filter)-l, "%s or ", dst_host_array[i]);
+ l += ndpi_snprintf(&filter[l], sizeof(filter)-l, "%s or ", dst_host_array[i]);
i++;
}
- l += snprintf(&filter[l], sizeof(filter)-l, "%s", ")");
+ l += ndpi_snprintf(&filter[l], sizeof(filter)-l, "%s", ")");
produced = 1;
}
@@ -4455,15 +4455,15 @@ void bpf_filter_host_peak_filter(json_object **jObj_bpfFilter,
l = strlen(filter);
if(i+1 == h_size || host_array[i+1] == NULL)
- snprintf(&filter[l], sizeof(filter)-l, "%s", host_array[i]);
+ ndpi_snprintf(&filter[l], sizeof(filter)-l, "%s", host_array[i]);
else
- snprintf(&filter[l], sizeof(filter)-l, "%s or ", host_array[i]);
+ ndpi_snprintf(&filter[l], sizeof(filter)-l, "%s or ", host_array[i]);
i++;
}
l = strlen(filter);
- snprintf(&filter[l], sizeof(filter)-l, "%s", ")");
+ ndpi_snprintf(&filter[l], sizeof(filter)-l, "%s", ")");
produced = 1;
}
@@ -4879,7 +4879,7 @@ static void produceBpfFilter(char *filePath) {
}
- snprintf(_filterFilePath, sizeof(_filterFilePath), "%s.bpf", filePath);
+ ndpi_snprintf(_filterFilePath, sizeof(_filterFilePath), "%s.bpf", filePath);
if((fp = fopen(_filterFilePath,"w")) == NULL) {
printf("Error creating .json file %s\n", _filterFilePath);
diff --git a/example/ndpiSimpleIntegration.c b/example/ndpiSimpleIntegration.c
index 303917a1b..4eac10707 100644
--- a/example/ndpiSimpleIntegration.c
+++ b/example/ndpiSimpleIntegration.c
@@ -1,8 +1,6 @@
#ifndef WIN32
#include <arpa/inet.h>
#include <netinet/in.h>
-#else
-#include <windows.h>
#endif
#include <errno.h>
#include <ndpi_api.h>
@@ -16,6 +14,10 @@
#include <string.h>
#include <unistd.h>
+#ifdef WIN32
+#include <windows.h>
+#endif
+
//#define VERBOSE 1
#define MAX_FLOW_ROOTS_PER_THREAD 2048
#define MAX_IDLE_FLOWS_PER_THREAD 64
@@ -90,7 +92,7 @@ struct nDPI_flow_info {
struct nDPI_workflow {
pcap_t * pcap_handle;
- uint8_t error_or_eof;
+ volatile long int error_or_eof;
unsigned long long int packets_captured;
unsigned long long int packets_processed;
@@ -121,8 +123,8 @@ struct nDPI_reader_thread {
static struct nDPI_reader_thread reader_threads[MAX_READER_THREADS] = {};
static int reader_thread_count = MAX_READER_THREADS;
-static int main_thread_shutdown = 0;
-static uint32_t flow_id = 0;
+static volatile long int main_thread_shutdown = 0;
+static volatile long int flow_id = 0;
static void free_workflow(struct nDPI_workflow ** const workflow);
@@ -300,7 +302,7 @@ static void print_packet_info(struct nDPI_reader_thread const * const reader_thr
char buf[256];
int used = 0, ret;
- ret = snprintf(buf, sizeof(buf), "[%8llu, %d, %4u] %4u bytes: ",
+ ret = ndpi_snprintf(buf, sizeof(buf), "[%8llu, %d, %4u] %4u bytes: ",
workflow->packets_captured, reader_thread->array_index,
flow->flow_id, header->caplen);
if (ret > 0) {
@@ -308,9 +310,9 @@ static void print_packet_info(struct nDPI_reader_thread const * const reader_thr
}
if (ip_tuple_to_string(flow, src_addr_str, sizeof(src_addr_str), dst_addr_str, sizeof(dst_addr_str)) != 0) {
- ret = snprintf(buf + used, sizeof(buf) - used, "IP[%s -> %s]", src_addr_str, dst_addr_str);
+ ret = ndpi_snprintf(buf + used, sizeof(buf) - used, "IP[%s -> %s]", src_addr_str, dst_addr_str);
} else {
- ret = snprintf(buf + used, sizeof(buf) - used, "IP[ERROR]");
+ ret = ndpi_snprintf(buf + used, sizeof(buf) - used, "IP[ERROR]");
}
if (ret > 0) {
used += ret;
@@ -318,24 +320,24 @@ static void print_packet_info(struct nDPI_reader_thread const * const reader_thr
switch (flow->l4_protocol) {
case IPPROTO_UDP:
- ret = snprintf(buf + used, sizeof(buf) - used, " -> UDP[%u -> %u, %u bytes]",
+ ret = ndpi_snprintf(buf + used, sizeof(buf) - used, " -> UDP[%u -> %u, %u bytes]",
flow->src_port, flow->dst_port, l4_data_len);
break;
case IPPROTO_TCP:
- ret = snprintf(buf + used, sizeof(buf) - used, " -> TCP[%u -> %u, %u bytes]",
+ ret = ndpi_snprintf(buf + used, sizeof(buf) - used, " -> TCP[%u -> %u, %u bytes]",
flow->src_port, flow->dst_port, l4_data_len);
break;
case IPPROTO_ICMP:
- ret = snprintf(buf + used, sizeof(buf) - used, " -> ICMP");
+ ret = ndpi_snprintf(buf + used, sizeof(buf) - used, " -> ICMP");
break;
case IPPROTO_ICMPV6:
- ret = snprintf(buf + used, sizeof(buf) - used, " -> ICMP6");
+ ret = ndpi_snprintf(buf + used, sizeof(buf) - used, " -> ICMP6");
break;
case IPPROTO_HOPOPTS:
- ret = snprintf(buf + used, sizeof(buf) - used, " -> ICMP6 Hop-By-Hop");
+ ret = ndpi_snprintf(buf + used, sizeof(buf) - used, " -> ICMP6 Hop-By-Hop");
break;
default:
- ret = snprintf(buf + used, sizeof(buf) - used, " -> Unknown[0x%X]", flow->l4_protocol);
+ ret = ndpi_snprintf(buf + used, sizeof(buf) - used, " -> Unknown[0x%X]", flow->l4_protocol);
break;
}
if (ret > 0) {
diff --git a/example/reader_util.c b/example/reader_util.c
index 7bf2a681d..0a9b435f1 100644
--- a/example/reader_util.c
+++ b/example/reader_util.c
@@ -25,15 +25,21 @@
#include "ndpi_config.h"
#endif
+#include "ndpi_api.h"
+
#include <stdlib.h>
#include <math.h>
#include <float.h>
#ifdef WIN32
#include <winsock2.h> /* winsock.h is included automatically */
+#include <windows.h>
+#include <ws2tcpip.h>
#include <process.h>
#include <io.h>
+#ifndef DISABLE_NPCAP
#include <ip6_misc.h>
+#endif
#else
#include <unistd.h>
#include <netinet/in.h>
@@ -854,8 +860,10 @@ static struct ndpi_flow_info *get_ndpi_flow_info(struct ndpi_workflow * workflow
inet_ntop(AF_INET, &newflow->src_ip, newflow->src_name, sizeof(newflow->src_name));
inet_ntop(AF_INET, &newflow->dst_ip, newflow->dst_name, sizeof(newflow->dst_name));
} else {
- inet_ntop(AF_INET6, &iph6->ip6_src, newflow->src_name, sizeof(newflow->src_name));
- inet_ntop(AF_INET6, &iph6->ip6_dst, newflow->dst_name, sizeof(newflow->dst_name));
+ struct in6_addr addr = *(struct in6_addr *)&iph6->ip6_src;
+ inet_ntop(AF_INET6, &addr, newflow->src_name, sizeof(newflow->src_name));
+ addr = *(struct in6_addr *)&iph6->ip6_dst;
+ inet_ntop(AF_INET6, &addr, newflow->dst_name, sizeof(newflow->dst_name));
/* For consistency across platforms replace :0: with :: */
ndpi_patchIPv6Address(newflow->src_name), ndpi_patchIPv6Address(newflow->dst_name);
}
@@ -1023,10 +1031,10 @@ void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_fl
flow->confidence = flow->ndpi_flow->confidence;
- snprintf(flow->host_server_name, sizeof(flow->host_server_name), "%s",
+ ndpi_snprintf(flow->host_server_name, sizeof(flow->host_server_name), "%s",
flow->ndpi_flow->host_server_name);
- snprintf(flow->flow_extra_info, sizeof(flow->flow_extra_info), "%s",
+ ndpi_snprintf(flow->flow_extra_info, sizeof(flow->flow_extra_info), "%s",
flow->ndpi_flow->flow_extra_info);
flow->risk = flow->ndpi_flow->risk;
@@ -1064,11 +1072,11 @@ void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_fl
}
/* MDNS */
else if(is_ndpi_proto(flow, NDPI_PROTOCOL_MDNS)) {
- snprintf(flow->info, sizeof(flow->info), "%s", flow->ndpi_flow->host_server_name);
+ ndpi_snprintf(flow->info, sizeof(flow->info), "%s", flow->ndpi_flow->host_server_name);
}
/* UBNTAC2 */
else if(is_ndpi_proto(flow, NDPI_PROTOCOL_UBNTAC2)) {
- snprintf(flow->info, sizeof(flow->info), "%s", flow->ndpi_flow->protos.ubntac2.version);
+ ndpi_snprintf(flow->info, sizeof(flow->info), "%s", flow->ndpi_flow->protos.ubntac2.version);
}
/* FTP */
else if((is_ndpi_proto(flow, NDPI_PROTOCOL_FTP_CONTROL))
@@ -1076,7 +1084,7 @@ void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_fl
|| /* POP */ is_ndpi_proto(flow, NDPI_PROTOCOL_MAIL_POP)
|| /* SMTP */ is_ndpi_proto(flow, NDPI_PROTOCOL_MAIL_SMTP)) {
if(flow->ndpi_flow->l4.tcp.ftp_imap_pop_smtp.username[0] != '\0')
- snprintf(flow->info, sizeof(flow->info), "User: %s][Pwd: %s%s",
+ ndpi_snprintf(flow->info, sizeof(flow->info), "User: %s][Pwd: %s%s",
flow->ndpi_flow->l4.tcp.ftp_imap_pop_smtp.username,
flow->ndpi_flow->l4.tcp.ftp_imap_pop_smtp.password,
flow->ndpi_flow->l4.tcp.ftp_imap_pop_smtp.auth_failed ? "][Auth Failed" : "");
@@ -1085,13 +1093,13 @@ void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_fl
else if(is_ndpi_proto(flow, NDPI_PROTOCOL_KERBEROS)) {
if((flow->ndpi_flow->protos.kerberos.hostname[0] != '\0')
|| (flow->ndpi_flow->protos.kerberos.username[0] != '\0')) {
- snprintf(flow->info, sizeof(flow->info), "%s%s%s%s",
+ ndpi_snprintf(flow->info, sizeof(flow->info), "%s%s%s%s",
flow->ndpi_flow->protos.kerberos.domain /* = realm */,
flow->ndpi_flow->protos.kerberos.domain[0] != '\0' ? "\\" : "",
flow->ndpi_flow->protos.kerberos.hostname,
flow->ndpi_flow->protos.kerberos.username);
} else if(flow->ndpi_flow->protos.kerberos.domain[0] != '\0')
- snprintf(flow->info, sizeof(flow->info), "%s",
+ ndpi_snprintf(flow->info, sizeof(flow->info), "%s",
flow->ndpi_flow->protos.kerberos.domain);
#if 0
@@ -1107,28 +1115,28 @@ void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_fl
else if((flow->detected_protocol.master_protocol == NDPI_PROTOCOL_HTTP)
|| is_ndpi_proto(flow, NDPI_PROTOCOL_HTTP)) {
if(flow->ndpi_flow->http.url != NULL) {
- snprintf(flow->http.url, sizeof(flow->http.url), "%s", flow->ndpi_flow->http.url);
+ ndpi_snprintf(flow->http.url, sizeof(flow->http.url), "%s", flow->ndpi_flow->http.url);
flow->http.response_status_code = flow->ndpi_flow->http.response_status_code;
- snprintf(flow->http.content_type, sizeof(flow->http.content_type), "%s", flow->ndpi_flow->http.content_type ? flow->ndpi_flow->http.content_type : "");
- snprintf(flow->http.request_content_type, sizeof(flow->http.request_content_type), "%s", flow->ndpi_flow->http.request_content_type ? flow->ndpi_flow->http.request_content_type : "");
- snprintf(flow->http.user_agent, sizeof(flow->http.user_agent), "%s", flow->ndpi_flow->http.user_agent ? flow->ndpi_flow->http.user_agent : "");
+ ndpi_snprintf(flow->http.content_type, sizeof(flow->http.content_type), "%s", flow->ndpi_flow->http.content_type ? flow->ndpi_flow->http.content_type : "");
+ ndpi_snprintf(flow->http.request_content_type, sizeof(flow->http.request_content_type), "%s", flow->ndpi_flow->http.request_content_type ? flow->ndpi_flow->http.request_content_type : "");
+ ndpi_snprintf(flow->http.user_agent, sizeof(flow->http.user_agent), "%s", flow->ndpi_flow->http.user_agent ? flow->ndpi_flow->http.user_agent : "");
}
} else if(is_ndpi_proto(flow, NDPI_PROTOCOL_SSDP)) {
- snprintf(flow->http.user_agent, sizeof(flow->http.user_agent), "%s", flow->ndpi_flow->http.user_agent ? flow->ndpi_flow->http.user_agent : "");
+ ndpi_snprintf(flow->http.user_agent, sizeof(flow->http.user_agent), "%s", flow->ndpi_flow->http.user_agent ? flow->ndpi_flow->http.user_agent : "");
} else if(is_ndpi_proto(flow, NDPI_PROTOCOL_TELNET)) {
if(flow->ndpi_flow->protos.telnet.username[0] != '\0')
flow->telnet.username = ndpi_strdup(flow->ndpi_flow->protos.telnet.username);
if(flow->ndpi_flow->protos.telnet.password[0] != '\0')
flow->telnet.password = ndpi_strdup(flow->ndpi_flow->protos.telnet.password);
} else if(is_ndpi_proto(flow, NDPI_PROTOCOL_SSH)) {
- snprintf(flow->host_server_name,
+ ndpi_snprintf(flow->host_server_name,
sizeof(flow->host_server_name), "%s",
flow->ndpi_flow->protos.ssh.client_signature);
- snprintf(flow->ssh_tls.server_info, sizeof(flow->ssh_tls.server_info), "%s",
+ ndpi_snprintf(flow->ssh_tls.server_info, sizeof(flow->ssh_tls.server_info), "%s",
flow->ndpi_flow->protos.ssh.server_signature);
- snprintf(flow->ssh_tls.client_hassh, sizeof(flow->ssh_tls.client_hassh), "%s",
+ ndpi_snprintf(flow->ssh_tls.client_hassh, sizeof(flow->ssh_tls.client_hassh), "%s",
flow->ndpi_flow->protos.ssh.hassh_client);
- snprintf(flow->ssh_tls.server_hassh, sizeof(flow->ssh_tls.server_hassh), "%s",
+ ndpi_snprintf(flow->ssh_tls.server_hassh, sizeof(flow->ssh_tls.server_hassh), "%s",
flow->ndpi_flow->protos.ssh.hassh_server);
}
/* TLS */
@@ -1139,16 +1147,16 @@ void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_fl
) {
flow->ssh_tls.ssl_version = flow->ndpi_flow->protos.tls_quic.ssl_version;
- snprintf(flow->http.user_agent, sizeof(flow->http.user_agent), "%s", flow->ndpi_flow->http.user_agent ? flow->ndpi_flow->http.user_agent : "");
+ ndpi_snprintf(flow->http.user_agent, sizeof(flow->http.user_agent), "%s", flow->ndpi_flow->http.user_agent ? flow->ndpi_flow->http.user_agent : "");
if(flow->ndpi_flow->protos.tls_quic.server_names_len > 0 && flow->ndpi_flow->protos.tls_quic.server_names)
flow->ssh_tls.server_names = ndpi_strdup(flow->ndpi_flow->protos.tls_quic.server_names);
flow->ssh_tls.notBefore = flow->ndpi_flow->protos.tls_quic.notBefore;
flow->ssh_tls.notAfter = flow->ndpi_flow->protos.tls_quic.notAfter;
- snprintf(flow->ssh_tls.ja3_client, sizeof(flow->ssh_tls.ja3_client), "%s",
+ ndpi_snprintf(flow->ssh_tls.ja3_client, sizeof(flow->ssh_tls.ja3_client), "%s",
flow->ndpi_flow->protos.tls_quic.ja3_client);
- snprintf(flow->ssh_tls.ja3_server, sizeof(flow->ssh_tls.ja3_server), "%s",
+ ndpi_snprintf(flow->ssh_tls.ja3_server, sizeof(flow->ssh_tls.ja3_server), "%s",
flow->ndpi_flow->protos.tls_quic.ja3_server);
flow->ssh_tls.server_unsafe_cipher = flow->ndpi_flow->protos.tls_quic.server_unsafe_cipher;
flow->ssh_tls.server_cipher = flow->ndpi_flow->protos.tls_quic.server_cipher;
@@ -1188,20 +1196,20 @@ void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_fl
correct_csv_data_field(flow->ndpi_flow->protos.tls_quic.tls_supported_versions);
if(csv_fp)
- snprintf(flow->info, sizeof(flow->info), "%s",
+ ndpi_snprintf(flow->info, sizeof(flow->info), "%s",
flow->ndpi_flow->protos.tls_quic.alpn);
else
- snprintf(flow->info, sizeof(flow->info), "ALPN: %s][TLS Supported Versions: %s",
+ ndpi_snprintf(flow->info, sizeof(flow->info), "ALPN: %s][TLS Supported Versions: %s",
flow->ndpi_flow->protos.tls_quic.alpn,
flow->ndpi_flow->protos.tls_quic.tls_supported_versions);
} else if(flow->ndpi_flow->protos.tls_quic.alpn) {
correct_csv_data_field(flow->ndpi_flow->protos.tls_quic.alpn);
if(csv_fp)
- snprintf(flow->info, sizeof(flow->info), "%s,",
+ ndpi_snprintf(flow->info, sizeof(flow->info), "%s,",
flow->ndpi_flow->protos.tls_quic.alpn);
else
- snprintf(flow->info, sizeof(flow->info), "ALPN: %s",
+ ndpi_snprintf(flow->info, sizeof(flow->info), "ALPN: %s",
flow->ndpi_flow->protos.tls_quic.alpn);
}
@@ -1892,9 +1900,7 @@ struct ndpi_proto ndpi_workflow_process_packet(struct ndpi_workflow * workflow,
iph6 = NULL;
if(iph->protocol == IPPROTO_IPV6
-#ifdef IPPROTO_IPIP
- || iph->protocol == IPPROTO_IPIP
-#endif
+ || iph->protocol == NDPI_IPIP_PROTOCOL_TYPE
) {
ip_offset += ip_len;
if(ip_len > 0)
@@ -1933,9 +1939,7 @@ struct ndpi_proto ndpi_workflow_process_packet(struct ndpi_workflow * workflow,
}
if(proto == IPPROTO_IPV6
-#ifdef IPPROTO_IPIP
- || proto == IPPROTO_IPIP
-#endif
+ || proto == NDPI_IPIP_PROTOCOL_TYPE
) {
if(l4ptr > packet) { /* Better safe than sorry */
ip_offset = (l4ptr - packet);
diff --git a/influxdb/metric_anomaly.c b/influxdb/metric_anomaly.c
index 49f204163..873dbfbc9 100644
--- a/influxdb/metric_anomaly.c
+++ b/influxdb/metric_anomaly.c
@@ -104,7 +104,7 @@ int main(int argc, char *argv[]) {
if((database == NULL) || (query == NULL))
help();
- snprintf(cmd, sizeof(cmd), "influx -database '%s' -precision s -execute '%s'", database, query);
+ ndpi_snprintf(cmd, sizeof(cmd), "influx -database '%s' -precision s -execute '%s'", database, query);
if(verbose) printf("%s\n", cmd);
diff --git a/rrdtool/rrd_similarity.c b/rrdtool/rrd_similarity.c
index 8ee2ed757..f70dd332a 100644
--- a/rrdtool/rrd_similarity.c
+++ b/rrdtool/rrd_similarity.c
@@ -180,7 +180,7 @@ void find_rrds(char *basedir, char *filename, rrd_file_stats *rrds, u_int *num_r
char path[PATH_MAX];
struct stat s;
- snprintf(path, sizeof(path), "%s/%s", basedir, namelist[n]->d_name);
+ ndpi_snprintf(path, sizeof(path), "%s/%s", basedir, namelist[n]->d_name);
if(stat(path, &s) == 0) {
if(S_ISDIR(s.st_mode))
diff --git a/src/include/ndpi_define.h.in b/src/include/ndpi_define.h.in
index 13e9962da..d34f8672d 100644
--- a/src/include/ndpi_define.h.in
+++ b/src/include/ndpi_define.h.in
@@ -330,10 +330,6 @@ static inline u_int64_t get_u_int64_t(const u_int8_t* X, int O)
/* define memory callback function */
#define match_first_bytes(payload,st) (memcmp((payload),(st),(sizeof(st)-1))==0)
-#if defined(WIN32) && !defined(snprintf)
-#define snprintf _snprintf
-#endif
-
#if defined(WIN32)
#undef strtok_r
#define strtok_r strtok_s
diff --git a/src/include/ndpi_includes_OpenBSD.h b/src/include/ndpi_includes_OpenBSD.h
index 65716c8f3..80c3e65cc 100644
--- a/src/include/ndpi_includes_OpenBSD.h
+++ b/src/include/ndpi_includes_OpenBSD.h
@@ -24,10 +24,6 @@
#ifndef __NDPI_INCLUDES_OPENBSD_H__
#define __NDPI_INCLUDES_OPENBSD_H__
-#ifndef IPPROTO_SCTP
-#define IPPROTO_SCTP 132
-#endif /* IPPROTO_SCTP */
-
#include <net/bpf.h>
typedef struct bpf_timeval pkt_timeval;
diff --git a/src/include/ndpi_utils.h b/src/include/ndpi_utils.h
index d6596ae1f..c6605528b 100644
--- a/src/include/ndpi_utils.h
+++ b/src/include/ndpi_utils.h
@@ -32,4 +32,9 @@ extern u_int8_t ndpi_ends_with(char *str, char *ends);
((ch) >= '[' && (ch) <= '`') || \
((ch) >= '{' && (ch) <= '~'))
+#ifndef NDPI_CFFI_PREPROCESSING
+int ndpi_vsnprintf(char * str, size_t size, char const * format, va_list va_args);
+int ndpi_snprintf(char * str, size_t size, char const * format, ...);
+#endif
+
#endif
diff --git a/src/include/ndpi_win32.h b/src/include/ndpi_win32.h
index 00bebe6ca..7885b13ef 100644
--- a/src/include/ndpi_win32.h
+++ b/src/include/ndpi_win32.h
@@ -47,18 +47,12 @@
#define _CRT_SECURE_NO_WARNINGS
#endif
-#define _WS2TCPIP_H_ /* Avoid compilation problems */
-
#define IPVERSION 4 /* on *nix it is defined in netinet/ip.h */
#ifndef MIN
#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
#endif
-#ifndef IPPROTO_SCTP
-#define IPPROTO_SCTP 132
-#endif
-
#if defined(__MINGW32__) || defined(__MINGW64__)
#undef gettimeofday
#define gettimeofday mingw_gettimeofday
diff --git a/src/lib/Makefile.in b/src/lib/Makefile.in
index 67ed0c758..00464286d 100644
--- a/src/lib/Makefile.in
+++ b/src/lib/Makefile.in
@@ -14,7 +14,10 @@ RANLIB = @RANLIB@
prefix = @prefix@
libdir = ${prefix}/lib
includedir = ${prefix}/include/ndpi
-CFLAGS += -fPIC -DPIC -I../include -Ithird_party/include -DNDPI_LIB_COMPILATION @CFLAGS@ @CUSTOM_NDPI@
+ifneq ($(OS),Windows_NT)
+CFLAGS += -fPIC -DPIC
+endif
+CFLAGS += -I../include -Ithird_party/include -DNDPI_LIB_COMPILATION @CFLAGS@ @CUSTOM_NDPI@
LDFLAGS = @LDFLAGS@
LIBS = @ADDITIONAL_LIBS@ @LIBS@
diff --git a/src/lib/ndpi_analyze.c b/src/lib/ndpi_analyze.c
index ebb5617ef..3dbcceced 100644
--- a/src/lib/ndpi_analyze.c
+++ b/src/lib/ndpi_analyze.c
@@ -516,7 +516,7 @@ char* ndpi_print_bin(struct ndpi_bin *b, u_int8_t normalize_first, char *out_buf
switch(b->family) {
case ndpi_bin_family8:
for(i=0; i<b->num_bins; i++) {
- int rc = snprintf(&out_buf[len], out_buf_len-len, "%s%u", (i > 0) ? "," : "", b->u.bins8[i]);
+ int rc = ndpi_snprintf(&out_buf[len], out_buf_len-len, "%s%u", (i > 0) ? "," : "", b->u.bins8[i]);
if(rc < 0) break;
len += rc;
@@ -525,7 +525,7 @@ char* ndpi_print_bin(struct ndpi_bin *b, u_int8_t normalize_first, char *out_buf
case ndpi_bin_family16:
for(i=0; i<b->num_bins; i++) {
- int rc = snprintf(&out_buf[len], out_buf_len-len, "%s%u", (i > 0) ? "," : "", b->u.bins16[i]);
+ int rc = ndpi_snprintf(&out_buf[len], out_buf_len-len, "%s%u", (i > 0) ? "," : "", b->u.bins16[i]);
if(rc < 0) break;
len += rc;
@@ -534,7 +534,7 @@ char* ndpi_print_bin(struct ndpi_bin *b, u_int8_t normalize_first, char *out_buf
case ndpi_bin_family32:
for(i=0; i<b->num_bins; i++) {
- int rc = snprintf(&out_buf[len], out_buf_len-len, "%s%u", (i > 0) ? "," : "", b->u.bins32[i]);
+ int rc = ndpi_snprintf(&out_buf[len], out_buf_len-len, "%s%u", (i > 0) ? "," : "", b->u.bins32[i]);
if(rc < 0) break;
len += rc;
diff --git a/src/lib/ndpi_classify.c b/src/lib/ndpi_classify.c
index bea56afef..61756cc16 100644
--- a/src/lib/ndpi_classify.c
+++ b/src/lib/ndpi_classify.c
@@ -696,5 +696,5 @@ ndpi_log_timestamp(char *log_ts, uint32_t log_ts_len)
localtime_r(&nowtime, &nowtm_r);
#endif
strftime(tmbuf, NDPI_TIMESTAMP_LEN, "%H:%M:%S", &nowtm_r);
- snprintf(log_ts, log_ts_len, "%s.%06ld", tmbuf, (long)tv.tv_usec);
+ ndpi_snprintf(log_ts, log_ts_len, "%s.%06ld", tmbuf, (long)tv.tv_usec);
}
diff --git a/src/lib/ndpi_community_id.c b/src/lib/ndpi_community_id.c
index b27ad38d2..80f43e0ea 100644
--- a/src/lib/ndpi_community_id.c
+++ b/src/lib/ndpi_community_id.c
@@ -204,7 +204,7 @@ static int ndpi_community_id_finalize_and_compute_hash(u_int8_t *comm_buf, u_int
switch(l4_proto) {
case IPPROTO_ICMP:
case IPPROTO_ICMPV6:
- case IPPROTO_SCTP:
+ case NDPI_SCTP_PROTOCOL_TYPE:
case IPPROTO_UDP:
case IPPROTO_TCP:
off += ndpi_community_id_buf_copy(&comm_buf[off], &src_port, sizeof(src_port));
@@ -285,7 +285,7 @@ int ndpi_flowv4_flow_hash(u_int8_t l4_proto, u_int32_t src_ip, u_int32_t dst_ip,
src_port = icmp_type;
dst_port = ndpi_community_id_icmp_type_to_code_v4(icmp_type, icmp_code, &icmp_one_way);
break;
- case IPPROTO_SCTP:
+ case NDPI_SCTP_PROTOCOL_TYPE:
case IPPROTO_UDP:
case IPPROTO_TCP:
/* src/dst port ok */
@@ -344,7 +344,7 @@ int ndpi_flowv6_flow_hash(u_int8_t l4_proto, struct ndpi_in6_addr *src_ip, struc
src_port = icmp_type;
dst_port = ndpi_community_id_icmp_type_to_code_v6(icmp_type, icmp_code, &icmp_one_way);
break;
- case IPPROTO_SCTP:
+ case NDPI_SCTP_PROTOCOL_TYPE:
case IPPROTO_UDP:
case IPPROTO_TCP:
/* src/dst port ok */
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c
index 005f215d2..fec0e4c63 100644
--- a/src/lib/ndpi_main.c
+++ b/src/lib/ndpi_main.c
@@ -173,7 +173,7 @@ static inline uint8_t flow_is_proto(struct ndpi_flow_struct *flow, u_int16_t p)
/* ****************************************** */
-static u_int32_t ndpi_tot_allocated_memory;
+static volatile long int ndpi_tot_allocated_memory;
/* ****************************************** */
@@ -2258,7 +2258,7 @@ void ndpi_debug_printf(unsigned int proto, struct ndpi_detection_module_struct *
!NDPI_ISSET(&ndpi_str->debug_bitmask, proto))
return;
va_start(args, format);
- vsnprintf(str, sizeof(str) - 1, format, args);
+ ndpi_vsnprintf(str, sizeof(str) - 1, format, args);
va_end(args);
if(ndpi_str != NULL) {
@@ -2576,7 +2576,7 @@ struct ndpi_detection_module_struct *ndpi_init_detection_module(ndpi_init_prefs
}
for(i = 0; i < NUM_CUSTOM_CATEGORIES; i++)
- snprintf(ndpi_str->custom_category_labels[i], CUSTOM_CATEGORY_LABEL_LEN, "User custom category %u",
+ ndpi_snprintf(ndpi_str->custom_category_labels[i], CUSTOM_CATEGORY_LABEL_LEN, "User custom category %u",
(unsigned int) (i + 1));
return(ndpi_str);
@@ -3250,7 +3250,7 @@ int ndpi_add_trusted_issuer_dn(struct ndpi_detection_module_struct *ndpi_str, ch
if(dn[0] == '"') {
char buf[128], *quote;
- snprintf(buf, sizeof(buf), "%s", &dn[1]);
+ ndpi_snprintf(buf, sizeof(buf), "%s", &dn[1]);
if((quote = strchr(buf, '"')) != NULL)
quote[0] = '\0';
@@ -3281,7 +3281,7 @@ int ndpi_handle_rule(struct ndpi_detection_module_struct *ndpi_str, char *rule,
/* This looks like a mask rule or an invalid rule */
char _rule[256], *rule_type, *key;
- snprintf(_rule, sizeof(_rule), "%s", rule);
+ ndpi_snprintf(_rule, sizeof(_rule), "%s", rule);
rule_type = strtok(rule, ":");
if(!rule_type) {
@@ -6854,13 +6854,15 @@ char *ndpi_get_ip_string(const ndpi_ip_addr_t *ip, char *buf, u_int buf_len) {
const u_int8_t *a = (const u_int8_t *) &ip->ipv4;
if(ndpi_is_ipv6(ip)) {
- if(inet_ntop(AF_INET6, &ip->ipv6.u6_addr, buf, buf_len) == NULL)
+ struct in6_addr addr = *(struct in6_addr *)&ip->ipv6.u6_addr;
+
+ if(inet_ntop(AF_INET6, &addr, buf, buf_len) == NULL)
buf[0] = '\0';
return(buf);
}
- snprintf(buf, buf_len, "%u.%u.%u.%u", a[0], a[1], a[2], a[3]);
+ ndpi_snprintf(buf, buf_len, "%u.%u.%u.%u", a[0], a[1], a[2], a[3]);
return(buf);
}
@@ -7010,11 +7012,11 @@ char *ndpi_protocol2id(struct ndpi_detection_module_struct *ndpi_str,
ndpi_protocol proto, char *buf, u_int buf_len) {
if((proto.master_protocol != NDPI_PROTOCOL_UNKNOWN) && (proto.master_protocol != proto.app_protocol)) {
if(proto.app_protocol != NDPI_PROTOCOL_UNKNOWN)
- snprintf(buf, buf_len, "%u.%u", proto.master_protocol, proto.app_protocol);
+ ndpi_snprintf(buf, buf_len, "%u.%u", proto.master_protocol, proto.app_protocol);
else
- snprintf(buf, buf_len, "%u", proto.master_protocol);
+ ndpi_snprintf(buf, buf_len, "%u", proto.master_protocol);
} else
- snprintf(buf, buf_len, "%u", proto.app_protocol);
+ ndpi_snprintf(buf, buf_len, "%u", proto.app_protocol);
return(buf);
}
@@ -7025,12 +7027,12 @@ char *ndpi_protocol2name(struct ndpi_detection_module_struct *ndpi_str,
ndpi_protocol proto, char *buf, u_int buf_len) {
if((proto.master_protocol != NDPI_PROTOCOL_UNKNOWN) && (proto.master_protocol != proto.app_protocol)) {
if(proto.app_protocol != NDPI_PROTOCOL_UNKNOWN)
- snprintf(buf, buf_len, "%s.%s", ndpi_get_proto_name(ndpi_str, proto.master_protocol),
+ ndpi_snprintf(buf, buf_len, "%s.%s", ndpi_get_proto_name(ndpi_str, proto.master_protocol),
ndpi_get_proto_name(ndpi_str, proto.app_protocol));
else
- snprintf(buf, buf_len, "%s", ndpi_get_proto_name(ndpi_str, proto.master_protocol));
+ ndpi_snprintf(buf, buf_len, "%s", ndpi_get_proto_name(ndpi_str, proto.master_protocol));
} else
- snprintf(buf, buf_len, "%s", ndpi_get_proto_name(ndpi_str, proto.app_protocol));
+ ndpi_snprintf(buf, buf_len, "%s", ndpi_get_proto_name(ndpi_str, proto.app_protocol));
return(buf);
}
@@ -7063,23 +7065,23 @@ void ndpi_category_set_name(struct ndpi_detection_module_struct *ndpi_str,
switch(category) {
case NDPI_PROTOCOL_CATEGORY_CUSTOM_1:
- snprintf(ndpi_str->custom_category_labels[0], CUSTOM_CATEGORY_LABEL_LEN, "%s", name);
+ ndpi_snprintf(ndpi_str->custom_category_labels[0], CUSTOM_CATEGORY_LABEL_LEN, "%s", name);
break;
case NDPI_PROTOCOL_CATEGORY_CUSTOM_2:
- snprintf(ndpi_str->custom_category_labels[1], CUSTOM_CATEGORY_LABEL_LEN, "%s", name);
+ ndpi_snprintf(ndpi_str->custom_category_labels[1], CUSTOM_CATEGORY_LABEL_LEN, "%s", name);
break;
case NDPI_PROTOCOL_CATEGORY_CUSTOM_3:
- snprintf(ndpi_str->custom_category_labels[2], CUSTOM_CATEGORY_LABEL_LEN, "%s", name);
+ ndpi_snprintf(ndpi_str->custom_category_labels[2], CUSTOM_CATEGORY_LABEL_LEN, "%s", name);
break;
case NDPI_PROTOCOL_CATEGORY_CUSTOM_4:
- snprintf(ndpi_str->custom_category_labels[3], CUSTOM_CATEGORY_LABEL_LEN, "%s", name);
+ ndpi_snprintf(ndpi_str->custom_category_labels[3], CUSTOM_CATEGORY_LABEL_LEN, "%s", name);
break;
case NDPI_PROTOCOL_CATEGORY_CUSTOM_5:
- snprintf(ndpi_str->custom_category_labels[4], CUSTOM_CATEGORY_LABEL_LEN, "%s", name);
+ ndpi_snprintf(ndpi_str->custom_category_labels[4], CUSTOM_CATEGORY_LABEL_LEN, "%s", name);
break;
default:
@@ -7115,9 +7117,9 @@ const char *ndpi_category_get_name(struct ndpi_detection_module_struct *ndpi_str
static char b[24];
if(!ndpi_str)
- snprintf(b, sizeof(b), "NULL nDPI");
+ ndpi_snprintf(b, sizeof(b), "NULL nDPI");
else
- snprintf(b, sizeof(b), "Invalid category %d", (int) category);
+ ndpi_snprintf(b, sizeof(b), "Invalid category %d", (int) category);
return(b);
}
@@ -8064,7 +8066,7 @@ int ndpi_check_dga_name(struct ndpi_detection_module_struct *ndpi_str,
if(ndpi_match_string_subprotocol(ndpi_str, name, strlen(name), &ret_match) > 0)
return(0); /* Ignore DGA for known domain names */
- if(isdigit(name[0])) {
+ if(isdigit((int)name[0])) {
struct in_addr ip_addr;
ip_addr.s_addr = inet_addr(name);
@@ -8087,7 +8089,7 @@ int ndpi_check_dga_name(struct ndpi_detection_module_struct *ndpi_str,
char tmp[128], *word, *tok_tmp;
u_int i, j, max_tmp_len = sizeof(tmp)-1;
- len = snprintf(tmp, max_tmp_len, "%s", name);
+ len = ndpi_snprintf(tmp, max_tmp_len, "%s", name);
if(len < 0) {
if(ndpi_verbose_dga_detection)
@@ -8103,7 +8105,7 @@ int ndpi_check_dga_name(struct ndpi_detection_module_struct *ndpi_str,
if(tmp[j] == '.') {
num_dots++;
} else if(num_dots == 0) {
- if(!isdigit(tmp[j]))
+ if(!isdigit((int)tmp[j]))
first_element_is_numeric = 0;
}
@@ -8116,10 +8118,10 @@ int ndpi_check_dga_name(struct ndpi_detection_module_struct *ndpi_str,
} else
num_char_repetitions = 1, last_char = tmp[j];
- if(isdigit(tmp[j])) {
+ if(isdigit((int)tmp[j])) {
num_digits++;
- if(((j+2)<(u_int)len) && isdigit(tmp[j+1]) && (tmp[j+2] == '.')) {
+ if(((j+2)<(u_int)len) && isdigit((int)tmp[j+1]) && (tmp[j+2] == '.')) {
/* Check if there are too many digits */
if(num_digits < 4)
return(0); /* Double digits */
@@ -8218,7 +8220,7 @@ int ndpi_check_dga_name(struct ndpi_detection_module_struct *ndpi_str,
trigram_char_skip = 0;
for(i = 0; word[i+1] != '\0'; i++) {
- if(isdigit(word[i]))
+ if(isdigit((int)word[i]))
num_consecutive_digits++;
else {
if((num_word == 1) && (num_consecutive_digits > max_num_consecutive_digits_first_word))
diff --git a/src/lib/ndpi_serializer.c b/src/lib/ndpi_serializer.c
index 76c764405..23b328c63 100644
--- a/src/lib/ndpi_serializer.c
+++ b/src/lib/ndpi_serializer.c
@@ -40,8 +40,8 @@
#endif
#ifdef WIN32
-#define NDPI_I64_FORMAT "%" PRId64
-#define NDPI_U64_FORMAT "%" PRIu64
+#define NDPI_I64_FORMAT "%I64d"
+#define NDPI_U64_FORMAT "%I64u"
#else
#define NDPI_I64_FORMAT "%lld"
#define NDPI_U64_FORMAT "%llu"
@@ -78,7 +78,7 @@ static int ndpi_is_number(const char *str, u_int32_t str_len) {
unsigned int i;
for(i = 0; i < str_len; i++)
- if(!isdigit(str[i])) return(0);
+ if(!isdigit((int)str[i])) return(0);
return(1);
}
@@ -146,8 +146,8 @@ static int ndpi_json_string_escape(const char *src, int src_len, char *dst, int
#if UNUSED
/*
- * Similar to snprintf, this returns the number of bytes actually written
- * in any case (unlike snprintf which returns, if the output is truncated,
+ * Similar to ndpi_snprintf, this returns the number of bytes actually written
+ * in any case (unlike ndpi_snprintf which returns, if the output is truncated,
* the number of bytes which *would have been* written, and a negative
* value on failures)
*/
@@ -156,7 +156,7 @@ static inline int ndpi_snappend(char *buf, size_t size, const char *fmt, ...) {
va_list va;
va_start(va, fmt);
- wlen = snprintf(buf, size, fmt, va);
+ wlen = ndpi_snprintf(buf, size, fmt, va);
va_end(va);
if (wlen < 0)
@@ -182,7 +182,7 @@ void ndpi_reset_serializer(ndpi_serializer *_serializer) {
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
/* Note: please keep a space at the beginning as it is used for arrays when an end-of-record is used */
- serializer->status.buffer.size_used += snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, " {}");
+ serializer->status.buffer.size_used += ndpi_snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, " {}");
} else if(serializer->fmt == ndpi_serialization_format_csv) {
serializer->status.header.size_used = 0;
serializer->status.buffer.size_used = 0;
@@ -307,7 +307,7 @@ static inline int ndpi_serializer_header_uint32(ndpi_private_serializer *seriali
if (room < 0)
return(-1);
- serializer->status.header.size_used += snprintf((char *) &serializer->header.data[serializer->status.header.size_used],
+ serializer->status.header.size_used += ndpi_snprintf((char *) &serializer->header.data[serializer->status.header.size_used],
room, "%s%u", (serializer->status.header.size_used > 0) ? serializer->csv_separator : "", key);
return(0);
@@ -657,7 +657,7 @@ int ndpi_serialize_end_of_record(ndpi_serializer *_serializer) {
} else if(serializer->fmt == ndpi_serialization_format_json) {
if(!(serializer->status.flags & NDPI_SERIALIZER_STATUS_ARRAY)) {
serializer->buffer.data[0] = '[';
- serializer->status.buffer.size_used += snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used],
+ serializer->status.buffer.size_used += ndpi_snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used],
buff_diff, "]");
}
@@ -777,13 +777,13 @@ int ndpi_serialize_uint32_uint32(ndpi_serializer *_serializer,
ndpi_serialize_json_pre(_serializer);
if (!(serializer->status.flags & NDPI_SERIALIZER_STATUS_LIST)) {
- serializer->status.buffer.size_used += snprintf((char *)
+ serializer->status.buffer.size_used += ndpi_snprintf((char *)
&serializer->buffer.data[serializer->status.buffer.size_used],
buff_diff, "\"%u\":", key);
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
}
- serializer->status.buffer.size_used += snprintf((char *)
+ serializer->status.buffer.size_used += ndpi_snprintf((char *)
&serializer->buffer.data[serializer->status.buffer.size_used],
buff_diff, "%u", value);
@@ -792,7 +792,7 @@ int ndpi_serialize_uint32_uint32(ndpi_serializer *_serializer,
if (ndpi_serializer_header_uint32(serializer, key) < 0) return(-1);
ndpi_serialize_csv_pre(serializer);
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
- serializer->status.buffer.size_used += snprintf((char *)
+ serializer->status.buffer.size_used += ndpi_snprintf((char *)
&serializer->buffer.data[serializer->status.buffer.size_used], buff_diff,
"%u", value);
} else {
@@ -845,13 +845,13 @@ int ndpi_serialize_uint32_uint64(ndpi_serializer *_serializer,
ndpi_serialize_json_pre(_serializer);
if (!(serializer->status.flags & NDPI_SERIALIZER_STATUS_LIST)) {
- serializer->status.buffer.size_used += snprintf((char *)
+ serializer->status.buffer.size_used += ndpi_snprintf((char *)
&serializer->buffer.data[serializer->status.buffer.size_used], buff_diff,
"\"%u\":", key);
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
}
- serializer->status.buffer.size_used += snprintf((char *)
+ serializer->status.buffer.size_used += ndpi_snprintf((char *)
&serializer->buffer.data[serializer->status.buffer.size_used], buff_diff,
NDPI_U64_FORMAT, (unsigned long long)value);
@@ -860,7 +860,7 @@ int ndpi_serialize_uint32_uint64(ndpi_serializer *_serializer,
if (ndpi_serializer_header_uint32(serializer, key) < 0) return(-1);
ndpi_serialize_csv_pre(serializer);
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
- serializer->status.buffer.size_used += snprintf((char *)
+ serializer->status.buffer.size_used += ndpi_snprintf((char *)
&serializer->buffer.data[serializer->status.buffer.size_used], buff_diff,
NDPI_U64_FORMAT, (unsigned long long)value);
} else {
@@ -909,13 +909,13 @@ int ndpi_serialize_uint32_int32(ndpi_serializer *_serializer,
ndpi_serialize_json_pre(_serializer);
if (!(serializer->status.flags & NDPI_SERIALIZER_STATUS_LIST)) {
- serializer->status.buffer.size_used += snprintf((char *)
+ serializer->status.buffer.size_used += ndpi_snprintf((char *)
&serializer->buffer.data[serializer->status.buffer.size_used],
buff_diff, "\"%u\":", key);
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
}
- serializer->status.buffer.size_used += snprintf((char *)
+ serializer->status.buffer.size_used += ndpi_snprintf((char *)
&serializer->buffer.data[serializer->status.buffer.size_used],
buff_diff, "%d", value);
@@ -924,7 +924,7 @@ int ndpi_serialize_uint32_int32(ndpi_serializer *_serializer,
if (ndpi_serializer_header_uint32(serializer, key) < 0) return(-1);
ndpi_serialize_csv_pre(serializer);
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
- serializer->status.buffer.size_used += snprintf((char *)
+ serializer->status.buffer.size_used += ndpi_snprintf((char *)
&serializer->buffer.data[serializer->status.buffer.size_used], buff_diff,
"%d", value);
} else {
@@ -977,13 +977,13 @@ int ndpi_serialize_uint32_int64(ndpi_serializer *_serializer,
ndpi_serialize_json_pre(_serializer);
if (!(serializer->status.flags & NDPI_SERIALIZER_STATUS_LIST)) {
- serializer->status.buffer.size_used += snprintf((char *)
+ serializer->status.buffer.size_used += ndpi_snprintf((char *)
&serializer->buffer.data[serializer->status.buffer.size_used],
buff_diff, "\"%u\":", key);
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
}
- serializer->status.buffer.size_used += snprintf((char *)
+ serializer->status.buffer.size_used += ndpi_snprintf((char *)
&serializer->buffer.data[serializer->status.buffer.size_used],
buff_diff, NDPI_I64_FORMAT, (long long int)value);
@@ -992,7 +992,7 @@ int ndpi_serialize_uint32_int64(ndpi_serializer *_serializer,
if (ndpi_serializer_header_uint32(serializer, key) < 0) return(-1);
ndpi_serialize_csv_pre(serializer);
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
- serializer->status.buffer.size_used += snprintf((char *)
+ serializer->status.buffer.size_used += ndpi_snprintf((char *)
&serializer->buffer.data[serializer->status.buffer.size_used], buff_diff,
NDPI_I64_FORMAT, (long long int)value);
}
@@ -1043,18 +1043,18 @@ int ndpi_serialize_uint32_float(ndpi_serializer *_serializer,
ndpi_serialize_json_pre(_serializer);
if (!(serializer->status.flags & NDPI_SERIALIZER_STATUS_LIST)) {
- serializer->status.buffer.size_used += snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, "\"%u\":", key);
+ serializer->status.buffer.size_used += ndpi_snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, "\"%u\":", key);
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
}
- serializer->status.buffer.size_used += snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, format, value);
+ serializer->status.buffer.size_used += ndpi_snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, format, value);
ndpi_serialize_json_post(_serializer);
} else if(serializer->fmt == ndpi_serialization_format_csv) {
if (ndpi_serializer_header_uint32(serializer, key) < 0) return(-1);
ndpi_serialize_csv_pre(serializer);
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
- serializer->status.buffer.size_used += snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, format, value);
+ serializer->status.buffer.size_used += ndpi_snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, format, value);
} else {
ndpi_serialization_type kt;
@@ -1099,7 +1099,7 @@ static int ndpi_serialize_uint32_binary(ndpi_serializer *_serializer,
ndpi_serialize_json_pre(_serializer);
if (!(serializer->status.flags & NDPI_SERIALIZER_STATUS_LIST)) {
- serializer->status.buffer.size_used += snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used],
+ serializer->status.buffer.size_used += ndpi_snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used],
buff_diff, "\"%u\":", key);
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
}
@@ -1111,7 +1111,7 @@ static int ndpi_serialize_uint32_binary(ndpi_serializer *_serializer,
if (ndpi_serializer_header_uint32(serializer, key) < 0) return(-1);
ndpi_serialize_csv_pre(serializer);
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
- serializer->status.buffer.size_used += snprintf((char *)
+ serializer->status.buffer.size_used += ndpi_snprintf((char *)
&serializer->buffer.data[serializer->status.buffer.size_used], buff_diff,
"%s", value);
} else {
@@ -1162,13 +1162,13 @@ int ndpi_serialize_uint32_boolean(ndpi_serializer *_serializer,
ndpi_serialize_json_pre(_serializer);
if (!(serializer->status.flags & NDPI_SERIALIZER_STATUS_LIST)) {
- serializer->status.buffer.size_used += snprintf((char *)
+ serializer->status.buffer.size_used += ndpi_snprintf((char *)
&serializer->buffer.data[serializer->status.buffer.size_used],
buff_diff, "\"%u\":", key);
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
}
- serializer->status.buffer.size_used += snprintf((char *)
+ serializer->status.buffer.size_used += ndpi_snprintf((char *)
&serializer->buffer.data[serializer->status.buffer.size_used],
buff_diff, "%s", value ? "true" : "false");
@@ -1177,7 +1177,7 @@ int ndpi_serialize_uint32_boolean(ndpi_serializer *_serializer,
if (ndpi_serializer_header_uint32(serializer, key) < 0) return(-1);
ndpi_serialize_csv_pre(serializer);
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
- serializer->status.buffer.size_used += snprintf((char *)
+ serializer->status.buffer.size_used += ndpi_snprintf((char *)
&serializer->buffer.data[serializer->status.buffer.size_used], buff_diff,
"%s", value ? "true" : "false");
}
@@ -1226,7 +1226,7 @@ int ndpi_serialize_binary_int32(ndpi_serializer *_serializer,
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
}
- serializer->status.buffer.size_used += snprintf((char *)
+ serializer->status.buffer.size_used += ndpi_snprintf((char *)
&serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, "%d", value);
ndpi_serialize_json_post(_serializer);
@@ -1234,7 +1234,7 @@ int ndpi_serialize_binary_int32(ndpi_serializer *_serializer,
if (ndpi_serializer_header_string(serializer, key, klen) < 0) return(-1);
ndpi_serialize_csv_pre(serializer);
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
- serializer->status.buffer.size_used += snprintf((char *)
+ serializer->status.buffer.size_used += ndpi_snprintf((char *)
&serializer->buffer.data[serializer->status.buffer.size_used], buff_diff,
"%d", value);
} else {
@@ -1286,7 +1286,7 @@ int ndpi_serialize_string_int32(ndpi_serializer *_serializer,
ndpi_serialize_csv_pre(serializer);
needed--;
- rc = snprintf((char*)&serializer->buffer.data[serializer->status.buffer.size_used],
+ rc = ndpi_snprintf((char*)&serializer->buffer.data[serializer->status.buffer.size_used],
needed, "%u", value);
if(rc > 0)
@@ -1338,7 +1338,7 @@ int ndpi_serialize_binary_int64(ndpi_serializer *_serializer,
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
}
- serializer->status.buffer.size_used += snprintf((char *)
+ serializer->status.buffer.size_used += ndpi_snprintf((char *)
&serializer->buffer.data[serializer->status.buffer.size_used], buff_diff,
NDPI_I64_FORMAT, (long long int)value);
@@ -1347,7 +1347,7 @@ int ndpi_serialize_binary_int64(ndpi_serializer *_serializer,
if (ndpi_serializer_header_string(serializer, key, klen) < 0) return(-1);
ndpi_serialize_csv_pre(serializer);
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
- serializer->status.buffer.size_used += snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff,
+ serializer->status.buffer.size_used += ndpi_snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff,
NDPI_I64_FORMAT, (long long int)value);
} else {
if ((value & 0xFFFFFFFF) == value) {
@@ -1385,7 +1385,7 @@ int ndpi_serialize_binary_uint32(ndpi_serializer *_serializer,
u_int16_t needed;
char _value[16];
- snprintf(_value, sizeof(_value), "%u", value);
+ ndpi_snprintf(_value, sizeof(_value), "%u", value);
needed = strlen(_value) + 1 /* CVS separator */;
if(buff_diff < needed) {
@@ -1439,7 +1439,7 @@ int ndpi_serialize_binary_uint32(ndpi_serializer *_serializer,
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
}
- serializer->status.buffer.size_used += snprintf((char *)
+ serializer->status.buffer.size_used += ndpi_snprintf((char *)
&serializer->buffer.data[serializer->status.buffer.size_used],
buff_diff, "%u", value);
@@ -1448,7 +1448,7 @@ int ndpi_serialize_binary_uint32(ndpi_serializer *_serializer,
if (ndpi_serializer_header_string(serializer, key, klen) < 0) return(-1);
ndpi_serialize_csv_pre(serializer);
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
- serializer->status.buffer.size_used += snprintf((char *)
+ serializer->status.buffer.size_used += ndpi_snprintf((char *)
&serializer->buffer.data[serializer->status.buffer.size_used], buff_diff,
"%u", value);
} else {
@@ -1495,7 +1495,7 @@ int ndpi_serialize_string_uint32_format(ndpi_serializer *_serializer,
} else {
char buf[16];
- snprintf(buf, sizeof(buf), format, value);
+ ndpi_snprintf(buf, sizeof(buf), format, value);
return(ndpi_serialize_string_string(_serializer, key, buf));
}
}
@@ -1541,7 +1541,7 @@ int ndpi_serialize_binary_uint64(ndpi_serializer *_serializer,
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
}
- serializer->status.buffer.size_used += snprintf((char *)
+ serializer->status.buffer.size_used += ndpi_snprintf((char *)
&serializer->buffer.data[serializer->status.buffer.size_used], buff_diff,
NDPI_U64_FORMAT, (unsigned long long)value);
@@ -1550,7 +1550,7 @@ int ndpi_serialize_binary_uint64(ndpi_serializer *_serializer,
if (ndpi_serializer_header_string(serializer, key, klen) < 0) return(-1);
ndpi_serialize_csv_pre(serializer);
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
- serializer->status.buffer.size_used += snprintf((char *)
+ serializer->status.buffer.size_used += ndpi_snprintf((char *)
&serializer->buffer.data[serializer->status.buffer.size_used], buff_diff,
NDPI_U64_FORMAT, (unsigned long long)value);
} else {
@@ -1616,14 +1616,14 @@ int ndpi_serialize_binary_float(ndpi_serializer *_serializer,
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
}
- serializer->status.buffer.size_used += snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, format, value);
+ serializer->status.buffer.size_used += ndpi_snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, format, value);
ndpi_serialize_json_post(_serializer);
} else if(serializer->fmt == ndpi_serialization_format_csv) {
if (ndpi_serializer_header_string(serializer, key, klen) < 0) return(-1);
ndpi_serialize_csv_pre(serializer);
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
- serializer->status.buffer.size_used += snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, format, value);
+ serializer->status.buffer.size_used += ndpi_snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, format, value);
} else {
serializer->buffer.data[serializer->status.buffer.size_used++] = (ndpi_serialization_string << 4) | ndpi_serialization_float;
@@ -1688,7 +1688,7 @@ static int ndpi_serialize_binary_raw(ndpi_serializer *_serializer,
serializer->status.buffer.size_used += ndpi_json_string_escape(value, vlen,
(char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff);
else {
- //serializer->status.buffer.size_used += snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, value, vlen);
+ //serializer->status.buffer.size_used += ndpi_snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, value, vlen);
memcpy(&serializer->buffer.data[serializer->status.buffer.size_used], value, vlen);
serializer->status.buffer.size_used += vlen;
}
@@ -1699,7 +1699,7 @@ static int ndpi_serialize_binary_raw(ndpi_serializer *_serializer,
ndpi_serialize_csv_pre(serializer);
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
- //serializer->status.buffer.size_used += snprintf((char *)
+ //serializer->status.buffer.size_used += ndpi_snprintf((char *)
// &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, "%s", value);
memcpy(&serializer->buffer.data[serializer->status.buffer.size_used], value, vlen);
serializer->status.buffer.size_used += vlen;
@@ -1833,7 +1833,7 @@ int ndpi_serialize_binary_boolean(ndpi_serializer *_serializer,
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
}
- serializer->status.buffer.size_used += snprintf((char *)
+ serializer->status.buffer.size_used += ndpi_snprintf((char *)
&serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, "%s",
value ? "true" : "false");
@@ -1842,7 +1842,7 @@ int ndpi_serialize_binary_boolean(ndpi_serializer *_serializer,
if (ndpi_serializer_header_string(serializer, key, strlen(key)) < 0) return(-1);
ndpi_serialize_csv_pre(serializer);
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
- serializer->status.buffer.size_used += snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff,
+ serializer->status.buffer.size_used += ndpi_snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff,
"%s", value ? "true" : "false");
}
@@ -1885,7 +1885,7 @@ int ndpi_serialize_start_of_list_binary(ndpi_serializer *_serializer,
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
- serializer->status.buffer.size_used += snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, ": [");
+ serializer->status.buffer.size_used += ndpi_snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, ": [");
serializer->status.flags |= NDPI_SERIALIZER_STATUS_LIST | NDPI_SERIALIZER_STATUS_SOL;
@@ -1957,7 +1957,7 @@ int ndpi_serialize_start_of_block_binary(ndpi_serializer *_serializer,
serializer->status.buffer.size_used += ndpi_json_string_escape(key, klen,
(char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff);
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
- serializer->status.buffer.size_used += snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, ": {");
+ serializer->status.buffer.size_used += ndpi_snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, ": {");
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
ndpi_serialize_json_post(_serializer);
@@ -1986,7 +1986,7 @@ int ndpi_serialize_start_of_block(ndpi_serializer *_serializer,
/* Serialize start of nested block with a numeric key */
int ndpi_serialize_start_of_block_uint32(ndpi_serializer *_serializer, u_int32_t key) {
char buf[11];
- int written = snprintf(buf, sizeof(buf), "%u", key);
+ int written = ndpi_snprintf(buf, sizeof(buf), "%u", key);
if (written <= 0 || written == sizeof(buf))
{
diff --git a/src/lib/ndpi_utils.c b/src/lib/ndpi_utils.c
index efb7d26f2..878f40d88 100644
--- a/src/lib/ndpi_utils.c
+++ b/src/lib/ndpi_utils.c
@@ -733,7 +733,7 @@ const char* ndpi_cipher2str(u_int32_t cipher) {
{
static char buf[8];
- snprintf(buf, sizeof(buf), "0X%04X", cipher);
+ ndpi_snprintf(buf, sizeof(buf), "0X%04X", cipher);
return(buf);
}
}
@@ -778,7 +778,7 @@ static int ndpi_find_non_eng_bigrams(struct ndpi_detection_module_struct *ndpi_s
char *str) {
char s[3];
- if((isdigit(str[0]) && isdigit(str[1]))
+ if((isdigit((int)str[0]) && isdigit((int)str[1]))
|| ndpi_is_other_char(str[0])
|| ndpi_is_other_char(str[1])
)
@@ -935,7 +935,7 @@ char* ndpi_ssl_version2str(char *buf, int buf_len,
if(unknown_tls_version)
*unknown_tls_version = 1;
- snprintf(buf, buf_len, "TLS (%04X)", version);
+ ndpi_snprintf(buf, buf_len, "TLS (%04X)", version);
return buf;
}
@@ -1415,7 +1415,7 @@ int ndpi_dpi2json(struct ndpi_detection_module_struct *ndpi_struct,
if(flow->protos.tls_quic.sha1_certificate_fingerprint[0] != '\0') {
for(i=0, off=0; i<20; i++) {
- int rc = snprintf(&buf[off], sizeof(buf)-off,"%s%02X", (i > 0) ? ":" : "",
+ int rc = ndpi_snprintf(&buf[off], sizeof(buf)-off,"%s%02X", (i > 0) ? ":" : "",
flow->protos.tls_quic.sha1_certificate_fingerprint[i] & 0xFF);
if(rc <= 0) break; else off += rc;
@@ -1905,7 +1905,7 @@ const char* ndpi_risk2str(ndpi_risk_enum risk) {
break;
default:
- snprintf(buf, sizeof(buf), "%d", (int)risk);
+ ndpi_snprintf(buf, sizeof(buf), "%d", (int)risk);
return(buf);
}
}
@@ -2433,3 +2433,36 @@ void ndpi_set_tls_cert_expire_days(struct ndpi_detection_module_struct *ndpi_str
u_int8_t num_days) {
ndpi_str->tls_certificate_expire_in_x_days = num_days;
}
+
+/* ******************************************* */
+
+int ndpi_vsnprintf(char * str, size_t size, char const * format, va_list va_args)
+{
+#ifdef WIN32
+ if (str == NULL || size == 0 || format == NULL)
+ {
+ return -1;
+ }
+
+ int ret = vsnprintf_s(str, size, _TRUNCATE, format, va_args);
+
+ if (ret < 0)
+ {
+ return size;
+ } else {
+ return ret;
+ }
+#else
+ return vsnprintf(str, size, format, va_args);
+#endif
+}
+
+int ndpi_snprintf(char * str, size_t size, char const * format, ...)
+{
+ va_list va_args;
+
+ va_start(va_args, format);
+ int ret = ndpi_vsnprintf(str, size, format, va_args);
+ va_end(va_args);
+ return ret;
+}
diff --git a/src/lib/protocols/dhcp.c b/src/lib/protocols/dhcp.c
index 46f64759b..494513f18 100644
--- a/src/lib/protocols/dhcp.c
+++ b/src/lib/protocols/dhcp.c
@@ -142,7 +142,7 @@ void ndpi_search_dhcp_udp(struct ndpi_detection_module_struct *ndpi_struct, stru
u_int idx, offset = 0;
for(idx = 0; idx < len && offset < sizeof(flow->protos.dhcp.fingerprint) - 2; idx++) {
- int rc = snprintf((char*)&flow->protos.dhcp.fingerprint[offset],
+ int rc = ndpi_snprintf((char*)&flow->protos.dhcp.fingerprint[offset],
sizeof(flow->protos.dhcp.fingerprint) - offset,
"%s%u", (idx > 0) ? "," : "",
(unsigned int)dhcp->options[i+2+idx] & 0xFF);
diff --git a/src/lib/protocols/kerberos.c b/src/lib/protocols/kerberos.c
index e22dd9a94..4c1deda90 100644
--- a/src/lib/protocols/kerberos.c
+++ b/src/lib/protocols/kerberos.c
@@ -200,17 +200,21 @@ static int krb_decode_asn1_blocks_skip(struct ndpi_detection_module_struct *ndpi
return length;
}
-static void strncpy_lower(char * const dst, size_t dst_siz,
- char const * const src, size_t src_siz)
+static void krb_strncpy_lower(char * const dst, size_t dst_siz,
+ char const * const src, size_t src_siz)
{
int dst_len = ndpi_min(src_siz, dst_siz - 1);
- strncpy(dst, src, dst_len);
dst[dst_len] = '\0';
for(int i = 0; i < dst_len; ++i)
{
- dst[i] = tolower(dst[i]);
+ if (ndpi_isprint(src[i]) == 0)
+ {
+ dst[i] = '?';
+ } else {
+ dst[i] = tolower(src[i]);
+ }
}
}
@@ -272,8 +276,8 @@ static int krb_parse(struct ndpi_detection_module_struct * const ndpi_struct,
length -= 2;
if (flow->protos.kerberos.domain[0] == '\0')
{
- strncpy_lower(flow->protos.kerberos.domain, sizeof(flow->protos.kerberos.domain),
- text, length);
+ krb_strncpy_lower(flow->protos.kerberos.domain, sizeof(flow->protos.kerberos.domain),
+ text, length);
}
length = krb_decode_asn1_string_type(ndpi_struct, &kasn1_offset, NULL);
@@ -312,11 +316,11 @@ static int krb_parse(struct ndpi_detection_module_struct * const ndpi_struct,
length -= 2;
if (flow->protos.kerberos.hostname[0] == '\0' && text[length - 1] != '$')
{
- strncpy_lower(flow->protos.kerberos.hostname, sizeof(flow->protos.kerberos.hostname),
- text, length);
+ krb_strncpy_lower(flow->protos.kerberos.hostname, sizeof(flow->protos.kerberos.hostname),
+ text, length);
} else if (flow->protos.kerberos.username[0] == '\0') {
- strncpy_lower(flow->protos.kerberos.username, sizeof(flow->protos.kerberos.username),
- text, length - 1);
+ krb_strncpy_lower(flow->protos.kerberos.username, sizeof(flow->protos.kerberos.username),
+ text, length - 1);
}
return 0;
@@ -532,15 +536,9 @@ void ndpi_search_kerberos(struct ndpi_detection_module_struct *ndpi_struct,
cname_str[0] = '\0'; // required, because cname_len
while(++num_cname <= 2) {
- if(cname_len > sizeof(cname_str)-1)
- cname_len = sizeof(cname_str)-1;
-
if (name_offset + cname_len + 1 >= packet->payload_packet_len)
cname_len = 0;
- else
- strncpy(cname_str, (char*)&packet->payload[name_offset+1], cname_len);
- cname_str[cname_len] = '\0';
- for(i=0; i<cname_len; i++) cname_str[i] = tolower(cname_str[i]);
+ krb_strncpy_lower(cname_str, sizeof(cname_str), (char*)&packet->payload[name_offset+1], cname_len);
#ifdef KERBEROS_DEBUG
printf("[AS-REQ][s/dport: %u/%u][Kerberos Cname][len: %u][%s]\n", sport, dport, cname_len, cname_str);
@@ -562,9 +560,9 @@ void ndpi_search_kerberos(struct ndpi_detection_module_struct *ndpi_struct,
&& (cname_len < sizeof(cname_str))
&& (cname_str[cname_len-1] == '$')) {
cname_str[cname_len-1] = '\0';
- snprintf(flow->protos.kerberos.hostname, sizeof(flow->protos.kerberos.hostname), "%s", cname_str);
+ ndpi_snprintf(flow->protos.kerberos.hostname, sizeof(flow->protos.kerberos.hostname), "%s", cname_str);
} else
- snprintf(flow->protos.kerberos.username, sizeof(flow->protos.kerberos.username), "%s", cname_str);
+ ndpi_snprintf(flow->protos.kerberos.username, sizeof(flow->protos.kerberos.username), "%s", cname_str);
for(i=0; (i < 14) && (realm_offset < packet->payload_packet_len); i++) {
if(packet->payload[realm_offset] != 0x1b)
@@ -584,19 +582,13 @@ void ndpi_search_kerberos(struct ndpi_detection_module_struct *ndpi_struct,
if((realm_offset+realm_len) < packet->payload_packet_len) {
char realm_str[48];
- if(realm_len > sizeof(realm_str)-1)
- realm_len = sizeof(realm_str)-1;
-
realm_offset += 1;
-
- strncpy(realm_str, (char*)&packet->payload[realm_offset], realm_len);
- realm_str[realm_len] = '\0';
- for(i=0; i<realm_len; i++) realm_str[i] = tolower(realm_str[i]);
+ krb_strncpy_lower(realm_str, sizeof(realm_str), (char*)&packet->payload[realm_offset], realm_len);
#ifdef KERBEROS_DEBUG
printf("[AS-REQ][Kerberos Realm][len: %u][%s]\n", realm_len, realm_str);
#endif
- snprintf(flow->protos.kerberos.domain, sizeof(flow->protos.kerberos.domain), "%s", realm_str);
+ ndpi_snprintf(flow->protos.kerberos.domain, sizeof(flow->protos.kerberos.domain), "%s", realm_str);
}
}
}
@@ -639,19 +631,13 @@ void ndpi_search_kerberos(struct ndpi_detection_module_struct *ndpi_struct,
if((realm_len+name_offset) < packet->payload_packet_len) {
char realm_str[48];
- if(realm_len > sizeof(realm_str)-1)
- realm_len = sizeof(realm_str)-1;
-
name_offset += 1;
-
- strncpy(realm_str, (char*)&packet->payload[name_offset], realm_len);
- realm_str[realm_len] = '\0';
- for(i=0; i<realm_len; i++) realm_str[i] = tolower(realm_str[i]);
+ krb_strncpy_lower(realm_str, sizeof(realm_str), (char*)&packet->payload[name_offset], realm_len);
#ifdef KERBEROS_DEBUG
printf("[TGS-REQ][s/dport: %u/%u][Kerberos Realm][len: %u][%s]\n", sport, dport, realm_len, realm_str);
#endif
- snprintf(flow->protos.kerberos.domain, sizeof(flow->protos.kerberos.domain), "%s", realm_str);
+ ndpi_snprintf(flow->protos.kerberos.domain, sizeof(flow->protos.kerberos.domain), "%s", realm_str);
/* If necessary we can decode sname */
if(flow->kerberos_buf.pktbuf) {
diff --git a/src/lib/protocols/mail_imap.c b/src/lib/protocols/mail_imap.c
index 12d652ecb..6877a61cf 100644
--- a/src/lib/protocols/mail_imap.c
+++ b/src/lib/protocols/mail_imap.c
@@ -178,7 +178,7 @@ void ndpi_search_mail_imap_tcp(struct ndpi_detection_module_struct *ndpi_struct,
if(user) {
char *pwd;
- snprintf(flow->l4.tcp.ftp_imap_pop_smtp.username,
+ ndpi_snprintf(flow->l4.tcp.ftp_imap_pop_smtp.username,
sizeof(flow->l4.tcp.ftp_imap_pop_smtp.username),
"%s", user);
@@ -186,7 +186,7 @@ void ndpi_search_mail_imap_tcp(struct ndpi_detection_module_struct *ndpi_struct,
pwd = strtok_r(NULL, " \"\r\n", &saveptr);
if(pwd) {
- snprintf(flow->l4.tcp.ftp_imap_pop_smtp.password,
+ ndpi_snprintf(flow->l4.tcp.ftp_imap_pop_smtp.password,
sizeof(flow->l4.tcp.ftp_imap_pop_smtp.password),
"%s", pwd);
}
diff --git a/src/lib/protocols/mining.c b/src/lib/protocols/mining.c
index 82e4038db..c12203adb 100644
--- a/src/lib/protocols/mining.c
+++ b/src/lib/protocols/mining.c
@@ -59,7 +59,7 @@ static void ndpi_search_mining_udp(struct ndpi_detection_module_struct *ndpi_str
else if(packet->iphv6 && ntohl(packet->iphv6->ip6_dst.u6_addr.u6_addr32[0]) == 0xFF020000)
;
else {
- snprintf(flow->flow_extra_info, sizeof(flow->flow_extra_info), "%s", "ETH");
+ ndpi_snprintf(flow->flow_extra_info, sizeof(flow->flow_extra_info), "%s", "ETH");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_MINING, NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI);
if(packet->iph) /* TODO: ipv6 */
cacheMiningHostTwins(ndpi_struct, packet->iph->saddr + packet->iph->daddr);
@@ -96,7 +96,7 @@ static void ndpi_search_mining_tcp(struct ndpi_detection_module_struct *ndpi_str
u_int32_t magic = htonl(0xf9beb4d9), magic1 = htonl(0xfabfb5da), *to_match = (u_int32_t*)packet->payload;
if((*to_match == magic) || (*to_match == magic1)) {
- snprintf(flow->flow_extra_info, sizeof(flow->flow_extra_info), "%s", "ETH");
+ ndpi_snprintf(flow->flow_extra_info, sizeof(flow->flow_extra_info), "%s", "ETH");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_MINING, NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI);
if(packet->iph) /* TODO: ipv6 */
cacheMiningHostTwins(ndpi_struct, packet->iph->saddr + packet->iph->daddr);
@@ -108,7 +108,7 @@ static void ndpi_search_mining_tcp(struct ndpi_detection_module_struct *ndpi_str
&& (packet->payload_packet_len < 600)
&& (packet->payload[2] == 0x04)) {
if(isEthPort(ntohs(packet->tcp->dest)) /* Ethereum port */) {
- snprintf(flow->flow_extra_info, sizeof(flow->flow_extra_info), "%s", "ETH");
+ ndpi_snprintf(flow->flow_extra_info, sizeof(flow->flow_extra_info), "%s", "ETH");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_MINING, NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI);
if(packet->iph) /* TODO: ipv6 */
cacheMiningHostTwins(ndpi_struct, packet->iph->saddr + packet->iph->daddr);
@@ -127,7 +127,7 @@ static void ndpi_search_mining_tcp(struct ndpi_detection_module_struct *ndpi_str
{ "id": 2, "jsonrpc":"2.0","result":true}
{"worker": "", "jsonrpc": "2.0", "params": [], "id": 3, "method": "eth_getWork"}
*/
- snprintf(flow->flow_extra_info, sizeof(flow->flow_extra_info), "%s", "ETH");
+ ndpi_snprintf(flow->flow_extra_info, sizeof(flow->flow_extra_info), "%s", "ETH");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_MINING, NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI);
if(packet->iph) /* TODO: ipv6 */
cacheMiningHostTwins(ndpi_struct, packet->iph->saddr + packet->iph->daddr);
@@ -151,7 +151,7 @@ static void ndpi_search_mining_tcp(struct ndpi_detection_module_struct *ndpi_str
{"id":1,"jsonrpc":"2.0","error":null,"result":{"id":"479059546883218","job":{"blob":"0606e89883d205a65d8ee78991838a1cf3ec2ebbc5fb1fa43dec5fa1cd2bee4069212a549cd731000000005a88235653097aa3e97ef2ceef4aee610751a828f9be1a0758a78365fb0a4c8c05","job_id":"722134174127131","target":"dc460300"},"status":"OK"}}
{"method":"submit","params":{"id":"479059546883218","job_id":"722134174127131","nonce":"98024001","result":"c9be9381a68d533c059d614d961e0534d7d8785dd5c339c2f9596eb95f320100"},"id":1}
*/
- snprintf(flow->flow_extra_info, sizeof(flow->flow_extra_info), "%s", "ZCash/Monero");
+ ndpi_snprintf(flow->flow_extra_info, sizeof(flow->flow_extra_info), "%s", "ZCash/Monero");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_MINING, NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI);
if(packet->iph) /* TODO: ipv6 */
cacheMiningHostTwins(ndpi_struct, packet->iph->saddr + packet->iph->daddr);
diff --git a/src/lib/protocols/telnet.c b/src/lib/protocols/telnet.c
index 4eec7d0b3..bfc8c3d86 100644
--- a/src/lib/protocols/telnet.c
+++ b/src/lib/protocols/telnet.c
@@ -99,7 +99,19 @@ static int search_telnet_again(struct ndpi_detection_module_struct *ndpi_struct,
for(i=0; i<packet->payload_packet_len; i++) {
if(packet->packet_direction == 0) /* client -> server */ {
if(flow->protos.telnet.character_id < (sizeof(flow->protos.telnet.username)-1))
- flow->protos.telnet.username[flow->protos.telnet.character_id++] = packet->payload[i];
+ {
+ if (i>=packet->payload_packet_len-2 &&
+ (packet->payload[i] == '\r' || packet->payload[i] == '\n'))
+ {
+ continue;
+ }
+ else if (ndpi_isprint(packet->payload[i]) == 0)
+ {
+ flow->protos.telnet.username[flow->protos.telnet.character_id++] = '?';
+ } else {
+ flow->protos.telnet.username[flow->protos.telnet.character_id++] = packet->payload[i];
+ }
+ }
}
}
diff --git a/src/lib/protocols/tls.c b/src/lib/protocols/tls.c
index 8214ede04..c5142abde 100644
--- a/src/lib/protocols/tls.c
+++ b/src/lib/protocols/tls.c
@@ -268,7 +268,7 @@ static int extractRDNSequence(struct ndpi_packet_struct *packet,
}
if(is_printable) {
- int rc = snprintf(&rdnSeqBuf[*rdnSeqBuf_offset],
+ int rc = ndpi_snprintf(&rdnSeqBuf[*rdnSeqBuf_offset],
rdnSeqBuf_len-(*rdnSeqBuf_offset),
"%s%s=%s", (*rdnSeqBuf_offset > 0) ? ", " : "",
label, buffer);
@@ -530,13 +530,14 @@ static void processCertificateElements(struct ndpi_detection_module_struct *ndpi
if(general_name_type == 0x87) {
if(len == 4 /* IPv4 */) {
- snprintf(dNSName, sizeof(dNSName), "%u.%u.%u.%u",
+ ndpi_snprintf(dNSName, sizeof(dNSName), "%u.%u.%u.%u",
packet->payload[i] & 0xFF,
packet->payload[i+1] & 0xFF,
packet->payload[i+2] & 0xFF,
packet->payload[i+3] & 0xFF);
- } else if(len == 16 /* IPv6 */){
- inet_ntop(AF_INET6, &packet->payload[i], dNSName, sizeof(dNSName));
+ } else if(len == 16 /* IPv6 */) {
+ struct in6_addr addr = *(struct in6_addr *)&packet->payload[i];
+ inet_ntop(AF_INET6, &addr, dNSName, sizeof(dNSName));
} else {
/* Is that possibile? Better safe than sorry */
dNSName[0] = '\0';
@@ -1461,7 +1462,7 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
if(flow->protos.tls_quic.alpn != NULL)
tlsCheckUncommonALPN(ndpi_struct, flow);
- snprintf(ja3.server.alpn, sizeof(ja3.server.alpn), "%s", alpn_str);
+ ndpi_snprintf(ja3.server.alpn, sizeof(ja3.server.alpn), "%s", alpn_str);
/* Replace , with - as in JA3 */
for(i=0; ja3.server.alpn[i] != '\0'; i++)
@@ -1500,36 +1501,36 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
i += 4 + extension_len, offset += 4 + extension_len;
} /* for */
- ja3_str_len = snprintf(ja3_str, JA3_STR_LEN, "%u,", ja3.server.tls_handshake_version);
+ ja3_str_len = ndpi_snprintf(ja3_str, JA3_STR_LEN, "%u,", ja3.server.tls_handshake_version);
for(i=0; (i<ja3.server.num_cipher) && (JA3_STR_LEN > ja3_str_len); i++) {
- rc = snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, "%s%u", (i > 0) ? "-" : "", ja3.server.cipher[i]);
+ rc = ndpi_snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, "%s%u", (i > 0) ? "-" : "", ja3.server.cipher[i]);
if(rc <= 0) break; else ja3_str_len += rc;
}
if(JA3_STR_LEN > ja3_str_len) {
- rc = snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, ",");
+ rc = ndpi_snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, ",");
if(rc > 0 && ja3_str_len + rc < JA3_STR_LEN) ja3_str_len += rc;
}
/* ********** */
for(i=0; (i<ja3.server.num_tls_extension) && (JA3_STR_LEN > ja3_str_len); i++) {
- int rc = snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, "%s%u", (i > 0) ? "-" : "", ja3.server.tls_extension[i]);
+ int rc = ndpi_snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, "%s%u", (i > 0) ? "-" : "", ja3.server.tls_extension[i]);
if(rc <= 0) break; else ja3_str_len += rc;
}
if(ndpi_struct->enable_ja3_plus) {
for(i=0; (i<ja3.server.num_elliptic_curve_point_format) && (JA3_STR_LEN > ja3_str_len); i++) {
- rc = snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, "%s%u",
+ rc = ndpi_snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, "%s%u",
(i > 0) ? "-" : "", ja3.server.elliptic_curve_point_format[i]);
if((rc > 0) && (ja3_str_len + rc < JA3_STR_LEN)) ja3_str_len += rc; else break;
}
if((ja3.server.alpn[0] != '\0') && (JA3_STR_LEN > ja3_str_len)) {
- rc = snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, ",%s", ja3.server.alpn);
+ rc = ndpi_snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, ",%s", ja3.server.alpn);
if((rc > 0) && (ja3_str_len + rc < JA3_STR_LEN)) ja3_str_len += rc;
}
@@ -1547,7 +1548,7 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
ndpi_MD5Final(md5_hash, &ctx);
for(i=0, j=0; i<16; i++) {
- int rc = snprintf(&flow->protos.tls_quic.ja3_server[j],
+ int rc = ndpi_snprintf(&flow->protos.tls_quic.ja3_server[j],
sizeof(flow->protos.tls_quic.ja3_server)-j, "%02x", md5_hash[i]);
if(rc <= 0) break; else j += rc;
}
@@ -1898,7 +1899,7 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
#endif
for(i=0; i<tot_signature_algorithms_len && s_offset+i<total_len; i++) {
- int rc = snprintf(&ja3.client.signature_algorithms[i*2], sizeof(ja3.client.signature_algorithms)-i*2, "%02X", packet->payload[s_offset+i]);
+ int rc = ndpi_snprintf(&ja3.client.signature_algorithms[i*2], sizeof(ja3.client.signature_algorithms)-i*2, "%02X", packet->payload[s_offset+i]);
if(rc < 0) break;
}
@@ -2048,7 +2049,7 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
if(flow->protos.tls_quic.alpn == NULL)
flow->protos.tls_quic.alpn = ndpi_strdup(alpn_str);
- snprintf(ja3.client.alpn, sizeof(ja3.client.alpn), "%s", alpn_str);
+ ndpi_snprintf(ja3.client.alpn, sizeof(ja3.client.alpn), "%s", alpn_str);
/* Replace , with - as in JA3 */
for(i=0; ja3.client.alpn[i] != '\0'; i++)
@@ -2083,7 +2084,7 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
#endif
if((version_str_len+8) < sizeof(version_str)) {
- int rc = snprintf(&version_str[version_str_len],
+ int rc = ndpi_snprintf(&version_str[version_str_len],
sizeof(version_str) - version_str_len, "%s%s",
(version_str_len > 0) ? "," : "",
ndpi_ssl_version2str(buf_ver_tmp, sizeof(buf_ver_tmp), tls_version, &unknown_tls_version));
@@ -2092,7 +2093,7 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
else
version_str_len += rc;
- rc = snprintf(&ja3.client.supported_versions[supported_versions_offset],
+ rc = ndpi_snprintf(&ja3.client.supported_versions[supported_versions_offset],
sizeof(ja3.client.supported_versions)-supported_versions_offset,
"%s%04X", (j > 0) ? "-" : "", tls_version);
@@ -2232,47 +2233,47 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
int rc;
compute_ja3c:
- ja3_str_len = snprintf(ja3_str, JA3_STR_LEN, "%u,", ja3.client.tls_handshake_version);
+ ja3_str_len = ndpi_snprintf(ja3_str, JA3_STR_LEN, "%u,", ja3.client.tls_handshake_version);
for(i=0; i<ja3.client.num_cipher; i++) {
- rc = snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, "%s%u",
+ rc = ndpi_snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, "%s%u",
(i > 0) ? "-" : "", ja3.client.cipher[i]);
if((rc > 0) && (ja3_str_len + rc < JA3_STR_LEN)) ja3_str_len += rc; else break;
}
- rc = snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, ",");
+ rc = ndpi_snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, ",");
if((rc > 0) && (ja3_str_len + rc < JA3_STR_LEN)) ja3_str_len += rc;
/* ********** */
for(i=0; i<ja3.client.num_tls_extension; i++) {
- rc = snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, "%s%u",
+ rc = ndpi_snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, "%s%u",
(i > 0) ? "-" : "", ja3.client.tls_extension[i]);
if((rc > 0) && (ja3_str_len + rc < JA3_STR_LEN)) ja3_str_len += rc; else break;
}
- rc = snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, ",");
+ rc = ndpi_snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, ",");
if((rc > 0) && (ja3_str_len + rc < JA3_STR_LEN)) ja3_str_len += rc;
/* ********** */
for(i=0; i<ja3.client.num_elliptic_curve; i++) {
- rc = snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, "%s%u",
+ rc = ndpi_snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, "%s%u",
(i > 0) ? "-" : "", ja3.client.elliptic_curve[i]);
if((rc > 0) && (ja3_str_len + rc < JA3_STR_LEN)) ja3_str_len += rc; else break;
}
- rc = snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, ",");
+ rc = ndpi_snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, ",");
if((rc > 0) && (ja3_str_len + rc < JA3_STR_LEN)) ja3_str_len += rc;
for(i=0; i<ja3.client.num_elliptic_curve_point_format; i++) {
- rc = snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, "%s%u",
+ rc = ndpi_snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, "%s%u",
(i > 0) ? "-" : "", ja3.client.elliptic_curve_point_format[i]);
if((rc > 0) && (ja3_str_len + rc < JA3_STR_LEN)) ja3_str_len += rc; else break;
}
if(ndpi_struct->enable_ja3_plus) {
- rc = snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len,
+ rc = ndpi_snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len,
",%s,%s,%s", ja3.client.signature_algorithms, ja3.client.supported_versions, ja3.client.alpn);
if((rc > 0) && (ja3_str_len + rc < JA3_STR_LEN)) ja3_str_len += rc;
}
@@ -2286,7 +2287,7 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
ndpi_MD5Final(md5_hash, &ctx);
for(i=0, j=0; i<16; i++) {
- rc = snprintf(&flow->protos.tls_quic.ja3_client[j],
+ rc = ndpi_snprintf(&flow->protos.tls_quic.ja3_client[j],
sizeof(flow->protos.tls_quic.ja3_client)-j, "%02x",
md5_hash[i]);
if(rc > 0) j += rc; else break;
diff --git a/src/lib/third_party/include/uthash.h b/src/lib/third_party/include/uthash.h
index f78a73b86..c9b7812f3 100644
--- a/src/lib/third_party/include/uthash.h
+++ b/src/lib/third_party/include/uthash.h
@@ -63,7 +63,7 @@ do {
#endif
/* a number of the hash function use uint32_t which isn't defined on Pre VS2010 */
-#if defined(_WIN32)
+#if defined(WIN32)
#if defined(_MSC_VER) && _MSC_VER >= 1600
#include <stdint.h>
#elif defined(__WATCOMC__) || defined(__MINGW32__) || defined(__CYGWIN__)
diff --git a/src/lib/third_party/src/ahocorasick.c b/src/lib/third_party/src/ahocorasick.c
index aefd7ae03..1508a0f6c 100644
--- a/src/lib/third_party/src/ahocorasick.c
+++ b/src/lib/third_party/src/ahocorasick.c
@@ -629,11 +629,11 @@ static AC_ERROR_t dump_node_common(AC_AUTOMATA_t * thiz,
char lbuf[512];
int nl = 0,j;
- nl = snprintf(lbuf,sizeof(lbuf),"'%.100s' N:%d{",rstr,n->matched_patterns->num);
+ nl = ndpi_snprintf(lbuf,sizeof(lbuf),"'%.100s' N:%d{",rstr,n->matched_patterns->num);
for (j=0; j<n->matched_patterns->num; j++) {
AC_PATTERN_t *sid = &n->matched_patterns->patterns[j];
- if(j) nl += snprintf(&lbuf[nl],sizeof(lbuf)-nl-1,", ");
- nl += snprintf(&lbuf[nl],sizeof(lbuf)-nl-1,"%d %c%.100s%c",
+ if(j) nl += ndpi_snprintf(&lbuf[nl],sizeof(lbuf)-nl-1,", ");
+ nl += ndpi_snprintf(&lbuf[nl],sizeof(lbuf)-nl-1,"%d %c%.100s%c",
sid->rep.number & 0x3fff,
sid->rep.number & 0x8000 ? '^':' ',
sid->astring,
diff --git a/src/lib/third_party/src/gcrypt/gcm.c b/src/lib/third_party/src/gcrypt/gcm.c
index 9b3ed1848..e793465f5 100644
--- a/src/lib/third_party/src/gcrypt/gcm.c
+++ b/src/lib/third_party/src/gcrypt/gcm.c
@@ -34,7 +34,7 @@
#define GCM_VALIDATE( cond ) \
MBEDTLS_INTERNAL_VALIDATE( cond )
-#ifdef _WIN32
+#ifdef WIN32
#define LBLOCKSIZE 4
#else
#define LBLOCKSIZE __SIZEOF_LONG__
@@ -295,7 +295,7 @@ int mbedtls_gcm_starts( mbedtls_gcm_context *ctx,
if( iv_len == 0)
return( MBEDTLS_ERR_GCM_BAD_INPUT );
#if __SIZE_WIDTH__ == 64
- if( iv_len >= (1UL << 32 ))
+ if( iv_len >= (1ULL << 32 ))
return( MBEDTLS_ERR_GCM_BAD_INPUT );
#endif
diff --git a/src/lib/third_party/src/gcrypt_light.c b/src/lib/third_party/src/gcrypt_light.c
index c048e8704..8ad142576 100644
--- a/src/lib/third_party/src/gcrypt_light.c
+++ b/src/lib/third_party/src/gcrypt_light.c
@@ -1,6 +1,6 @@
#include <stdint.h>
-#ifndef _WIN32
+#ifndef WIN32
#include <unistd.h>
#endif
#include <string.h>
diff --git a/src/lib/third_party/src/roaring.cc b/src/lib/third_party/src/roaring.cc
index e3fd63096..2fccfb129 100644
--- a/src/lib/third_party/src/roaring.cc
+++ b/src/lib/third_party/src/roaring.cc
@@ -300,7 +300,7 @@ static inline uint32_t croaring_detect_supported_architectures() {
extern "C" { // portability definitions are in global scope, not a namespace
#endif
-#if defined(_MSC_VER) && !defined(__clang__) && !defined(_WIN64) && !defined(ROARING_ACK_32BIT)
+#if defined(_MSC_VER) && !defined(__clang__) && !defined(WIN64) && !defined(ROARING_ACK_32BIT)
#pragma message( \
"You appear to be attempting a 32-bit build under Visual Studio. We recommend a 64-bit build instead.")
#endif
@@ -373,7 +373,7 @@ extern "C" { // portability definitions are in global scope, not a namespace
/* result might be undefined when input_num is zero */
static inline int __builtin_ctzll(unsigned long long input_num) {
unsigned long index;
-#ifdef _WIN64 // highly recommended!!!
+#ifdef WIN64 // highly recommended!!!
_BitScanForward64(&index, input_num);
#else // if we must support 32-bit Windows
if ((uint32_t)input_num != 0) {
@@ -389,7 +389,7 @@ static inline int __builtin_ctzll(unsigned long long input_num) {
/* result might be undefined when input_num is zero */
static inline int __builtin_clzll(unsigned long long input_num) {
unsigned long index;
-#ifdef _WIN64 // highly recommended!!!
+#ifdef WIN64 // highly recommended!!!
_BitScanReverse64(&index, input_num);
#else // if we must support 32-bit Windows
if (input_num > 0xFFFFFFFF) {
@@ -479,14 +479,14 @@ static inline int hammingbackup(uint64_t x) {
}
static inline int hamming(uint64_t x) {
-#if defined(_WIN64) && defined(_MSC_VER) && !defined(__clang__)
+#if defined(WIN64) && defined(_MSC_VER) && !defined(__clang__)
#ifdef _M_ARM64
return hammingbackup(x);
// (int) _CountOneBits64(x); is unavailable
#else // _M_ARM64
return (int) __popcnt64(x);
#endif // _M_ARM64
-#elif defined(_WIN32) && defined(_MSC_VER) && !defined(__clang__)
+#elif defined(WIN32) && defined(_MSC_VER) && !defined(__clang__)
#ifdef _M_ARM
return hammingbackup(x);
// _CountOneBits is unavailable
diff --git a/tests/dga/Makefile.in b/tests/dga/Makefile.in
index e2846830e..efa8b188b 100644
--- a/tests/dga/Makefile.in
+++ b/tests/dga/Makefile.in
@@ -1,36 +1,33 @@
CC=@CC@
CXX=@CXX@
-BUILD_MINGW=@BUILD_MINGW@
+EXE_SUFFIX=@EXE_SUFFIX@
SRCHOME=../../src
-CFLAGS=-g -fPIC -DPIC -I$(SRCHOME)/include @JSONC_CFLAGS@ @PCAP_INC@ @CFLAGS@
+ifneq ($(OS),Windows_NT)
+CFLAGS+=-fPIC -DPIC
+endif
+CFLAGS+=-g -I$(SRCHOME)/include @CFLAGS@
LIBNDPI=$(SRCHOME)/lib/libndpi.a
-LIBS=$(LIBNDPI) @PCAP_LIB@ @LIBS@ @ADDITIONAL_LIBS@ @JSONC_LIBS@ -lpthread
+LIBS=$(LIBNDPI) @LIBS@ @ADDITIONAL_LIBS@ -lpthread
LDFLAGS=@LDFLAGS@
HEADERS=$(SRCHOME)/include/ndpi_api.h $(SRCHOME)/include/ndpi_typedefs.h $(SRCHOME)/include/ndpi_protocol_ids.h
OBJS=dga_evaluate
PREFIX?=@prefix@
-ifneq ($(BUILD_MINGW),)
-all:
- @echo 'DGA test disabled due to mingw build.'
-
-else
-
-all: dga_evaluate
+all: dga_evaluate$(EXE_SUFFIX)
EXECUTABLE_SOURCES := dga_evaluate.c
COMMON_SOURCES := $(filter-out $(EXECUTABLE_SOURCES),$(wildcard *.c ))
-dga_evaluate: $(LIBNDPI) dga_evaluate.o
+dga_evaluate$(EXE_SUFFIX): $(LIBNDPI) dga_evaluate.o
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) dga_evaluate.o $(LIBS) -o $@
%.o: %.c $(HEADERS) Makefile
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
clean:
- /bin/rm -f *.o dga_evaluate
+ /bin/rm -f *.o dga_evaluate$(EXE_SUFFIX)
/bin/rm -f .*.o.cmd .*.o.d
/bin/rm -rf build
@@ -42,5 +39,3 @@ distdir:
distclean: clean
/bin/rm -f Makefile
-
-endif
diff --git a/tests/do.sh.in b/tests/do.sh.in
index dc4ed6a92..120b66b28 100755
--- a/tests/do.sh.in
+++ b/tests/do.sh.in
@@ -3,26 +3,29 @@
cd "$(dirname "${0}")"
FUZZY_TESTING_ENABLED=@BUILD_FUZZTARGETS@
-if [ "$NDPI_DISABLE_FUZZY" = "1" ]; then
+if [ "${NDPI_DISABLE_FUZZY}" = "1" ]; then
FUZZY_TESTING_ENABLED=0
fi
#Remember: valgrind and *SAN are incompatible!
-VALGRIND=""
-if [ "$NDPI_TESTS_VALGRIND" = "1" ]; then
- VALGRIND="valgrind -q --leak-check=full"
+CMD_PREFIX="${CMD_PREFIX}"
+if [ "${NDPI_TESTS_WINE}" = "1" ]; then
+ CMD_PREFIX="wine"
+elif [ "${NDPI_TESTS_VALGRIND}" = "1" ]; then
+ CMD_PREFIX="valgrind -q --leak-check=full"
fi
+EXE_SUFFIX=@EXE_SUFFIX@
PCRE_ENABLED=@PCRE_ENABLED@
PCRE_PCAPS="WebattackRCE.pcap"
GCRYPT_PCAPS="gquic.pcap quic-23.pcap quic-24.pcap quic-27.pcap quic-28.pcap quic-29.pcap quic-mvfst-22.pcap quic-mvfst-27.pcapng quic-mvfst-exp.pcap quic_q50.pcap quic_t50.pcap quic_t51.pcap quic_0RTT.pcap quic_interop_V.pcapng quic-33.pcapng doq.pcapng doq_adguard.pcapng dlt_ppp.pcap os_detected.pcapng quic_frags_ch_out_of_order_same_packet_craziness.pcapng quic_frags_ch_in_multiple_packets.pcapng quic-v2-00.pcapng"
-READER="$VALGRIND ../example/ndpiReader -p ../example/protos.txt -c ../example/categories.txt -r ../example/risky_domains.txt -j ../example/ja3_fingerprints.csv -S ../example/sha1_fingerprints.csv"
+READER="${CMD_PREFIX} ../example/ndpiReader${EXE_SUFFIX} -p ../example/protos.txt -c ../example/categories.txt -r ../example/risky_domains.txt -j ../example/ja3_fingerprints.csv -S ../example/sha1_fingerprints.csv"
RC=0
PCAPS=`cd pcap; /bin/ls *.pcap *.pcapng *.cap`
-if [ ! -x "../example/ndpiReader" ]; then
- echo "$0: Missing $(realpath ../example/ndpiReader)"
+if [ ! -x "../example/ndpiReader${EXE_SUFFIX}" ]; then
+ echo "$0: Missing $(realpath ../example/ndpiReader${EXE_SUFFIX})"
echo "$0: Run ./configure and make first"
exit 1
fi
@@ -68,18 +71,25 @@ check_results() {
if [ -f result/$f.out ]; then
CMD="$READER -q -t -i pcap/$f -w /tmp/reader.out -v 2"
$CMD
- NUM_DIFF=`diff result/$f.out /tmp/reader.out | wc -l`
-
- if [ $NUM_DIFF -eq 0 ]; then
- printf "%-48s\tOK\n" "$f"
+ CMD_RET=$?
+ if [ $CMD_RET -eq 0 ]; then
+ NUM_DIFF=`diff result/$f.out /tmp/reader.out | wc -l`
else
- printf "%-48s\tERROR\n" "$f"
- echo "$CMD [old vs new]"
- diff result/$f.out /tmp/reader.out
- RC=1
+ printf "%-48s\tERROR (ndpiReader${EXE_SUFFIX} exit code: ${CMD_RET})\n" "$f"
+ RC=1
+ continue
+ fi
+
+ if [ $NUM_DIFF -eq 0 ]; then
+ printf "%-48s\tOK\n" "$f"
+ else
+ printf "%-48s\tERROR\n" "$f"
+ echo "$CMD [old vs new]"
+ diff result/$f.out /tmp/reader.out
+ RC=1
fi
- /bin/rm /tmp/reader.out
+ /bin/rm -f /tmp/reader.out
fi
done
}
@@ -90,4 +100,4 @@ fi
build_results
check_results $*
-exit $RC \ No newline at end of file
+exit $RC
diff --git a/tests/result/kerberos_fuzz.pcapng.out b/tests/result/kerberos_fuzz.pcapng.out
index 3602d654e..5b20c3456 100644
--- a/tests/result/kerberos_fuzz.pcapng.out
+++ b/tests/result/kerberos_fuzz.pcapng.out
@@ -5,4 +5,4 @@ Confidence DPI : 1 (flows)
Kerberos 1 288 1
- 1 TCP 126.4.1.0:88 -> 19.0.0.0:53646 [proto: 111/Kerberos][ClearText][Confidence: DPI][cat: Network/14][1 pkts/288 bytes -> 0 pkts/0 bytes][Goodput ratio: 90/0][< 1 sec][r1ióóóca\][PLAIN TEXT (/S.2T )][Plen Bins: 0,0,0,0,0,0,0,0,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
+ 1 TCP 126.4.1.0:88 -> 19.0.0.0:53646 [proto: 111/Kerberos][ClearText][Confidence: DPI][cat: Network/14][1 pkts/288 bytes -> 0 pkts/0 bytes][Goodput ratio: 90/0][< 1 sec][r1i???ca???????]*??0p??????_???????ea?id;?????o\??????][PLAIN TEXT (/S.2T )][Plen Bins: 0,0,0,0,0,0,0,0,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
diff --git a/tests/result/telnet.pcap.out b/tests/result/telnet.pcap.out
index 4159118ec..a091b3500 100644
--- a/tests/result/telnet.pcap.out
+++ b/tests/result/telnet.pcap.out
@@ -5,5 +5,4 @@ Confidence DPI : 1 (flows)
Telnet 87 7418 1
- 1 TCP 192.168.0.2:1550 <-> 192.168.0.1:23 [proto: 77/Telnet][ClearText][Confidence: DPI][cat: RemoteAccess/12][43 pkts/3135 bytes <-> 44 pkts/4283 bytes][Goodput ratio: 9/32][39.57 sec][Username: fake
-][bytes ratio: -0.155 (Mixed)][IAT c2s/s2c min/avg/max/stddev: 0/0 1130/544 14699/8799 2838/1502][Pkt Len c2s/s2c min/avg/max/stddev: 66/66 73/97 151/554 17/76][Risk: ** Unsafe Protocol **][Risk Score: 10][PLAIN TEXT (bam.zing.org)][Plen Bins: 70,6,19,0,2,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
+ 1 TCP 192.168.0.2:1550 <-> 192.168.0.1:23 [proto: 77/Telnet][ClearText][Confidence: DPI][cat: RemoteAccess/12][43 pkts/3135 bytes <-> 44 pkts/4283 bytes][Goodput ratio: 9/32][39.57 sec][Username: fake][bytes ratio: -0.155 (Mixed)][IAT c2s/s2c min/avg/max/stddev: 0/0 1130/544 14699/8799 2838/1502][Pkt Len c2s/s2c min/avg/max/stddev: 66/66 73/97 151/554 17/76][Risk: ** Unsafe Protocol **][Risk Score: 10][PLAIN TEXT (bam.zing.org)][Plen Bins: 70,6,19,0,2,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
diff --git a/tests/unit/Makefile.in b/tests/unit/Makefile.in
index b2f779fd3..e1d13328e 100644
--- a/tests/unit/Makefile.in
+++ b/tests/unit/Makefile.in
@@ -1,10 +1,14 @@
CC=@CC@
CXX=@CXX@
BUILD_MINGW=@BUILD_MINGW@
+EXE_SUFFIX=@EXE_SUFFIX@
SRCHOME=../../src
-CFLAGS=-g -fPIC -DPIC -I$(SRCHOME)/include @JSONC_CFLAGS@ @PCAP_INC@ @CFLAGS@
+ifneq ($(OS),Windows_NT)
+CFLAGS+=-fPIC -DPIC
+endif
+CFLAGS+=-g -I$(SRCHOME)/include @JSONC_CFLAGS@ @PCAP_INC@ @CFLAGS@
LIBNDPI=$(SRCHOME)/lib/libndpi.a
LIBS=$(LIBNDPI) @PCAP_LIB@ @LIBS@ @ADDITIONAL_LIBS@ @JSONC_LIBS@ -lpthread
LDFLAGS=@LDFLAGS@
@@ -13,24 +17,41 @@ OBJS=unit
PREFIX?=@prefix@
ifneq ($(BUILD_MINGW),)
-all:
- @echo 'Unit tests disabled due to mingw build.'
+ifeq ($(DISABLE_NPCAP),0)
+CFLAGS+=-I@srcdir@/../windows/WpdPack/Include -I@srcdir@/../windows/WpdPack/Include/pcap
else
+CFLAGS+=-DDISABLE_NPCAP
+endif
-all: unit
+ifeq ($(DISABLE_NPCAP),0)
+
+ifneq ($(BUILD_MINGW_X64),)
+LIBS+=@srcdir@/../windows/WpdPack/Lib/x64/wpcap.lib
+else
+LIBS+=@srcdir@/../windows/WpdPack/Lib/wpcap.lib
+endif
+
+endif
+
+LIBS+=-Wl,-Bstatic -lpthread -Wl,-Bdynamic
+else
+LIBS+=-pthread
+endif
+
+all: unit$(EXE_SUFFIX)
EXECUTABLE_SOURCES := unit.c
COMMON_SOURCES := $(filter-out $(EXECUTABLE_SOURCES),$(wildcard *.c ))
-unit: $(LIBNDPI) unit.o
+unit$(EXE_SUFFIX): $(LIBNDPI) unit.o
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) unit.o $(LIBS) -o $@
%.o: %.c $(HEADERS) Makefile
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
clean:
- /bin/rm -f *.o unit
+ /bin/rm -f *.o unit$(EXE_SUFFIX)
/bin/rm -f .*.o.cmd .*.o.d
/bin/rm -rf build
@@ -42,5 +63,3 @@ distdir:
distclean: clean
/bin/rm -f Makefile
-
-endif
diff --git a/tests/unit/unit.c b/tests/unit/unit.c
index 69d44f3c2..bf08d7ed0 100644
--- a/tests/unit/unit.c
+++ b/tests/unit/unit.c
@@ -29,8 +29,8 @@
#include <winsock2.h>
#include <process.h>
#include <io.h>
-#define getopt getopt____
#else
+#include <getopt.h>
#include <unistd.h>
#include <netinet/in.h>
#include <sys/socket.h>
@@ -39,7 +39,6 @@
#include <stdio.h>
#include <stdlib.h>
-#include <getopt.h>
#include <string.h>
#include <stdarg.h>
#include <search.h>
@@ -96,8 +95,8 @@ int serializerUnitTest() {
for(i=0; i<16; i++) {
char kbuf[32], vbuf[32];
- snprintf(kbuf, sizeof(kbuf), "Key %d", i);
- snprintf(vbuf, sizeof(vbuf), "Value %d", i);
+ ndpi_snprintf(kbuf, sizeof(kbuf), "Key %d", i);
+ ndpi_snprintf(vbuf, sizeof(vbuf), "Value %d", i);
assert(ndpi_serialize_uint32_uint32(&serializer, i, i*i) != -1);
assert(ndpi_serialize_uint32_string(&serializer, i, "Data") != -1);
assert(ndpi_serialize_string_string(&serializer, kbuf, vbuf) != -1);
@@ -112,8 +111,8 @@ int serializerUnitTest() {
for(i=0; i<4; i++) {
char kbuf[32], vbuf[32];
- snprintf(kbuf, sizeof(kbuf), "Ignored");
- snprintf(vbuf, sizeof(vbuf), "Item %d", i);
+ ndpi_snprintf(kbuf, sizeof(kbuf), "Ignored");
+ ndpi_snprintf(vbuf, sizeof(vbuf), "Item %d", i);
assert(ndpi_serialize_uint32_uint32(&serializer, i, i*i) != -1);
assert(ndpi_serialize_string_string(&serializer, kbuf, vbuf) != -1);
assert(ndpi_serialize_string_float(&serializer, kbuf, (float)(i*i), "%f") != -1);
@@ -325,7 +324,9 @@ int serializeProtoUnitTest(void)
/* *********************************************** */
int main(int argc, char **argv) {
+#ifndef WIN32
int c;
+#endif
if (ndpi_get_api_version() != NDPI_API_VERSION) {
printf("nDPI Library version mismatch: please make sure this code and the nDPI library are in sync\n");
@@ -337,6 +338,11 @@ int main(int argc, char **argv) {
if (ndpi_info_mod == NULL)
return -1;
+/*
+ * If we want argument parsing on Windows,
+ * we need to re-implement it as Windows has no such function.
+ */
+#ifndef WIN32
while((c = getopt(argc, argv, "vh")) != -1) {
switch(c) {
case 'v':
@@ -348,6 +354,9 @@ int main(int argc, char **argv) {
return(0);
}
}
+#else
+ verbose = 0;
+#endif
/* Tests */
if (serializerUnitTest() != 0) return -1;
diff --git a/windows/nDPI.vcxproj b/windows/nDPI.vcxproj
deleted file mode 100644
index 59f82c122..000000000
--- a/windows/nDPI.vcxproj
+++ /dev/null
@@ -1,390 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{7331961B-A2B5-45B1-B144-AFDEFBB0EB01}</ProjectGuid>
- <RootNamespace>nDPIdev</RootNamespace>
- <Keyword>Win32Proj</Keyword>
- <ProjectName>nDPI</ProjectName>
- <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <PlatformToolset>v140</PlatformToolset>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <PlatformToolset>v140</PlatformToolset>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <PlatformToolset>v140</PlatformToolset>
- <CharacterSet>MultiByte</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <PlatformToolset>v140</PlatformToolset>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>11.0.50727.1</_ProjectFileVersion>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <OutDir>$(ProjectDir)bin\$(Platform)_$(Configuration)\</OutDir>
- <IntDir>$(SolutionDir)obj\$(ProjectName)_$(Configuration)_$(Platform)\</IntDir>
- <LinkIncremental>true</LinkIncremental>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <LinkIncremental>true</LinkIncremental>
- <IntDir>$(SolutionDir)obj\$(ProjectName)_$(Configuration)_$(Platform)\</IntDir>
- <OutDir>$(ProjectDir)bin\$(Platform)_$(Configuration)\</OutDir>
- <IncludePath>$(ProjectDir);$(ProjectDir)dummy\folder\;$(IncludePath)</IncludePath>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <OutDir>$(ProjectDir)bin\$(Platform)_$(Configuration)\</OutDir>
- <IntDir>$(SolutionDir)obj\$(ProjectName)_$(Configuration)_$(Platform)\</IntDir>
- <LinkIncremental>false</LinkIncremental>
- <IncludePath>$(ProjectDir);$(ProjectDir)dummy\folder\;$(IncludePath)</IncludePath>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <LinkIncremental>false</LinkIncremental>
- <IntDir>$(SolutionDir)obj\$(ProjectName)_$(Configuration)_$(Platform)\</IntDir>
- <OutDir>$(ProjectDir)bin\$(Platform)_$(Configuration)\</OutDir>
- <IncludePath>$(ProjectDir);$(ProjectDir)dummy\folder\;$(IncludePath)</IncludePath>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>$(ProjectDir)..\..\..\..\submodules\nDPI\src\lib\protocols\;$(ProjectDir)..\..\..\..\submodules\nDPI\src\include\;$(ProjectDir)..\..\..\..\submodules\nDPI\;$(ProjectDir)..\..\..\..\submodules\nDPI\src\lib\third_party\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <MinimalRebuild>false</MinimalRebuild>
- <BasicRuntimeChecks>Default</BasicRuntimeChecks>
- <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
- <PrecompiledHeader />
- <WarningLevel>Level3</WarningLevel>
- <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- <StringPooling>false</StringPooling>
- <ProgramDataBaseFileName>$(TargetDir)$(TargetName).pdb</ProgramDataBaseFileName>
- <ExceptionHandling>false</ExceptionHandling>
- <MultiProcessorCompilation>true</MultiProcessorCompilation>
- </ClCompile>
- <Link>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <SubSystem>Windows</SubSystem>
- <TargetMachine>MachineX86</TargetMachine>
- <AdditionalDependencies>Ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <FullProgramDatabaseFile>true</FullProgramDatabaseFile>
- <AssemblyDebug>true</AssemblyDebug>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>$(ProjectDir)..\..\..\..\submodules\nDPI\src\lib\protocols\;$(ProjectDir)..\..\..\..\submodules\nDPI\src\include\;$(ProjectDir)..\..\..\..\submodules\nDPI\;$(ProjectDir)..\..\..\..\submodules\nDPI\src\lib\third_party\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <BasicRuntimeChecks>Default</BasicRuntimeChecks>
- <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
- <PrecompiledHeader>
- </PrecompiledHeader>
- <WarningLevel>Level3</WarningLevel>
- <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- <StringPooling>false</StringPooling>
- <ProgramDataBaseFileName>$(TargetDir)$(TargetName).pdb</ProgramDataBaseFileName>
- <ExceptionHandling>false</ExceptionHandling>
- <MultiProcessorCompilation>true</MultiProcessorCompilation>
- <AdditionalUsingDirectories>$(ProjectDir);%(AdditionalUsingDirectories)</AdditionalUsingDirectories>
- </ClCompile>
- <Link>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <SubSystem>Windows</SubSystem>
- <AdditionalDependencies>Ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <FullProgramDatabaseFile>true</FullProgramDatabaseFile>
- <AssemblyDebug>true</AssemblyDebug>
- </Link>
- <PostBuildEvent>
- </PostBuildEvent>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
- <PrecompiledHeader />
- <WarningLevel>TurnOffAllWarnings</WarningLevel>
- <DebugInformationFormat>None</DebugInformationFormat>
- <AdditionalIncludeDirectories>$(ProjectDir)..\..\..\..\submodules\nDPI\src\lib\protocols\;$(ProjectDir)..\..\..\..\submodules\nDPI\src\include\;$(ProjectDir)..\..\..\..\submodules\nDPI\;$(ProjectDir)..\..\..\..\submodules\nDPI\src\lib\third_party\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <Optimization>Full</Optimization>
- <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
- <OmitFramePointers>true</OmitFramePointers>
- <StringPooling>true</StringPooling>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <ProgramDataBaseFileName>$(TargetDir)$(TargetName).pdb</ProgramDataBaseFileName>
- <EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
- <AdditionalUsingDirectories>$(ProjectDir);%(AdditionalUsingDirectories)</AdditionalUsingDirectories>
- <MultiProcessorCompilation>true</MultiProcessorCompilation>
- <ExceptionHandling>Sync</ExceptionHandling>
- </ClCompile>
- <Link>
- <GenerateDebugInformation>false</GenerateDebugInformation>
- <SubSystem>Console</SubSystem>
- <OptimizeReferences>true</OptimizeReferences>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <TargetMachine>MachineX86</TargetMachine>
- <AdditionalDependencies>Ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
- <PrecompiledHeader>
- </PrecompiledHeader>
- <WarningLevel>TurnOffAllWarnings</WarningLevel>
- <DebugInformationFormat>None</DebugInformationFormat>
- <AdditionalIncludeDirectories>$(ProjectDir)..\..\..\..\submodules\nDPI\src\lib\protocols\;$(ProjectDir)..\..\..\..\submodules\nDPI\src\include\;$(ProjectDir)..\..\..\..\submodules\nDPI\;$(ProjectDir)..\..\..\..\submodules\nDPI\src\lib\third_party\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <Optimization>Full</Optimization>
- <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
- <OmitFramePointers>true</OmitFramePointers>
- <StringPooling>true</StringPooling>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <ProgramDataBaseFileName>$(TargetDir)$(TargetName).pdb</ProgramDataBaseFileName>
- <EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
- <AdditionalUsingDirectories>$(ProjectDir);%(AdditionalUsingDirectories)</AdditionalUsingDirectories>
- <ExceptionHandling>Sync</ExceptionHandling>
- <MultiProcessorCompilation>true</MultiProcessorCompilation>
- </ClCompile>
- <Link>
- <GenerateDebugInformation>false</GenerateDebugInformation>
- <SubSystem>Console</SubSystem>
- <OptimizeReferences>true</OptimizeReferences>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <AdditionalDependencies>Ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\afp.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\bjnp.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\kxun.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\third_party\src\ahocorasick.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\aimini.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\applejuice.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\armagetron.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\ayiya.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\battlefield.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\bgp.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\bittorrent.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\btlib.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\ciscovpn.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\citrix.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\coap.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\collectd.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\corba.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\crossfire.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\dcerpc.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\dhcp.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\dhcpv6.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\directconnect.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\directdownloadlink.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\dns.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\dofus.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\drda.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\dropbox.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\eaq.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\edonkey.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\fasttrack.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\fiesta.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\filetopia.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\attic\flash.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\florensia.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\attic\ftp.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\ftp_control.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\ftp_data.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\git.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\gnutella.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\gtp.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\guildwars.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\h323.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\halflife2_and_mods.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\hangout.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\hep.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\http.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\http_activesync.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\iax.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\icecast.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\ipp.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\irc.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\jabber.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\kakaotalk_voice.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\kerberos.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\kontiki.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\ldap.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\lotus_notes.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\mail_imap.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\mail_pop.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\mail_smtp.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\attic\manolito.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\maplestory.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\mdns.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\megaco.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\mgcp.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\mms.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\mpegts.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\mqtt.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\msn.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\mssql_tds.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\mysql.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\ndpi_main.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\netbios.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\netflow.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\nfs.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\third_party\src\node.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\noe.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\non_tcp_udp.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\ntp.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\openft.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\openvpn.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\oracle.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\oscar.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\pando.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\pcanywhere.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\attic\popo.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\postgres.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\pplive.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\ppstream.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\pptp.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\qq.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\quake.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\quic.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\radius.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\rdp.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\redis_net.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\rsync.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\rtcp.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\rtmp.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\rtp.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\rtsp.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\rx.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\attic\secondlife.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\sflow.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\shoutcast.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\sip.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\skinny.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\skype.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\smb.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\snmp.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\socks45.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\socrates.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\sopcast.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\third_party\src\sort.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\soulseek.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\spotify.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\ssdp.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\ssh.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\ssl.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\starcraft.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\stealthnet.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\steam.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\stun.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\syslog.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\tcp_udp.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\teamspeak.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\teamviewer.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\telegram.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\telnet.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\teredo.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\tftp.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\thunder.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\tor.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\tvants.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\tvuplayer.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\ubntac2.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\usenet.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\vhua.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\viber.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\vmware.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\vnc.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\warcraft3.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\whoisdas.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\world_of_kung_fu.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\world_of_warcraft.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\xbox.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\xdmcp.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\yahoo.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\zattoo.c" />
- <ClCompile Include="..\..\..\..\submodules\nDPI\src\lib\protocols\zeromq.c" />
- <ClCompile Include="ndpi.c" />
- <ClCompile Include="ndpi_util.c" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="..\..\..\..\submodules\nDPI\src\lib\protocols\btlib.h" />
- <ClInclude Include="..\..\..\..\submodules\nDPI\src\lib\third_party\include\actypes.h" />
- <ClInclude Include="..\..\..\..\submodules\nDPI\src\lib\third_party\include\ahocorasick.h" />
- <ClInclude Include="..\..\..\..\submodules\nDPI\src\include\ndpi_api.h" />
- <ClInclude Include="..\..\..\..\submodules\nDPI\src\include\ndpi_define.h" />
- <ClInclude Include="..\..\..\..\submodules\nDPI\src\include\ndpi_includes.h" />
- <ClInclude Include="..\..\..\..\submodules\nDPI\src\include\ndpi_main.h" />
- <ClInclude Include="..\..\..\..\submodules\nDPI\src\lib\third_party\include\ndpi_patricia.h" />
- <ClInclude Include="..\..\..\..\submodules\nDPI\src\include\ndpi_protocol_ids.h" />
- <ClInclude Include="..\..\..\..\submodules\nDPI\src\include\ndpi_protocols.h" />
- <ClInclude Include="..\..\..\..\submodules\nDPI\src\include\ndpi_typedefs.h" />
- <ClInclude Include="..\..\..\..\submodules\nDPI\src\include\ndpi_unix.h" />
- <ClInclude Include="..\..\..\..\submodules\nDPI\src\include\ndpi_win32.h" />
- <ClInclude Include="..\..\..\..\submodules\nDPI\src\lib\third_party\include\node.h" />
- <ClInclude Include="..\..\..\..\submodules\nDPI\src\lib\third_party\include\sort.h" />
- <ClInclude Include="arpa\inet.h" />
- <ClInclude Include="bpf.h" />
- <ClInclude Include="config.h" />
- <ClInclude Include="getopt.h" />
- <ClInclude Include="ndpi_util.h" />
- <ClInclude Include="ndpi_utils.h" />
- <ClInclude Include="strings.h" />
- <ClInclude Include="unistd.h" />
- </ItemGroup>
- <ItemGroup>
- <None Include="..\..\..\..\submodules\nDPI\src\lib\ndpi_content_match.c.inc" />
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file