Fixed msys2 build warnings and re-activated CI Mingw64 build.
* Removed Visual Studio leftovers. Maintaining an autotools project with VS integration requires some additional overhead. Signed-off-by: Toni Uhlig <matzeton@googlemail.com> Signed-off-by: lns <matzeton@googlemail.com>
This commit is contained in:
+27
-14
@@ -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
|
||||
|
||||
all: ndpiReader$(SUFFIX) @DPDK_TARGET@
|
||||
LIBS+=-Wl,-Bstatic -lpthread -Wl,-Bdynamic
|
||||
else
|
||||
LIBS+=-pthread
|
||||
endif
|
||||
|
||||
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
|
||||
|
||||
+43
-43
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
+35
-31
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user