aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Deri <deri@ntop.org>2019-10-29 10:29:12 +0100
committerLuca Deri <deri@ntop.org>2019-10-29 10:29:12 +0100
commit42c8d3ac273ef92ef507a01aff8f3127840cda3b (patch)
treeb2547335b21522eb8def4948edf5ac07ebfc00c0
parentd53563ab4651f0bb70fbcc48193e450d92e4c8cd (diff)
Added ability to defien custom protocols
-rw-r--r--configure.seed12
-rw-r--r--src/include/ndpi_protocol_ids.h9
-rw-r--r--src/lib/Makefile.in2
-rw-r--r--src/lib/ndpi_main.c10
-rw-r--r--src/lib/protocols/kerberos.c4
5 files changed, 28 insertions, 9 deletions
diff --git a/configure.seed b/configure.seed
index a3cc646f2..15c922f08 100644
--- a/configure.seed
+++ b/configure.seed
@@ -68,8 +68,14 @@ SYSTEM=`uname -s`
if test $SYSTEM = "Darwin"; then
CC=clang
fi
-
-
+
+CUSTOM_NDPI=
+
+if test -d ../nDPI-custom; then :
+ CUSTOM_NDPI="-DCUSTOM_NDPI_PROTOCOLS"
+ AC_MSG_RESULT([Compiling with custom nDPI protocols])
+fi
+
AC_ARG_WITH(hyperscan, [ --with-hyperscan Enable nDPI build with Intel Hyperscan])
AS_IF([test "${with_hyperscan+set}" = set],[
@@ -155,5 +161,5 @@ AC_SUBST(PCAP_LIB)
AC_SUBST(DL_LIB)
AC_SUBST(DPDK_TARGET)
AC_SUBST(HAVE_PTHREAD_SETAFFINITY_NP)
-
+AC_SUBST(CUSTOM_NDPI)
AC_OUTPUT
diff --git a/src/include/ndpi_protocol_ids.h b/src/include/ndpi_protocol_ids.h
index 758609030..c6d486933 100644
--- a/src/include/ndpi_protocol_ids.h
+++ b/src/include/ndpi_protocol_ids.h
@@ -1,4 +1,3 @@
-
/*
* ndpi_protocol_ids.h
*
@@ -283,8 +282,12 @@ typedef enum {
NDPI_PROTOCOL_BLOOMBERG = 246,
NDPI_PROTOCOL_CAPWAP = 247,
NDPI_PROTOCOL_ZABBIX = 248,
-
-/*
+
+#ifdef CUSTOM_NDPI_PROTOCOLS
+#include "../../../nDPI-custom/custom_ndpi_protocol_ids.h"
+#endif
+
+ /*
IMPORTANT
before allocating a new identifier please fill up
one of those named NDPI_PROTOCOL_FREE_XXX and not used
diff --git a/src/lib/Makefile.in b/src/lib/Makefile.in
index 1a884ac9d..0c3f44838 100644
--- a/src/lib/Makefile.in
+++ b/src/lib/Makefile.in
@@ -14,7 +14,7 @@ prefix = @prefix@
libdir = ${prefix}/lib
includedir = ${prefix}/include/ndpi
CC = @CC@
-CFLAGS += -fPIC -DPIC -I../include -Ithird_party/include -DNDPI_LIB_COMPILATION -O2 -g -Wall
+CFLAGS += -fPIC -DPIC -I../include -Ithird_party/include -DNDPI_LIB_COMPILATION -O2 -g -Wall @CUSTOM_NDPI@
RANLIB = ranlib
OBJECTS = $(patsubst protocols/%.c, protocols/%.o, $(wildcard protocols/*.c)) $(patsubst third_party/src/%.c, third_party/src/%.o, $(wildcard third_party/src/*.c)) $(patsubst ./%.c, ./%.o, $(wildcard ./*.c))
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c
index b65a1f36f..31f2e362d 100644
--- a/src/lib/ndpi_main.c
+++ b/src/lib/ndpi_main.c
@@ -1778,6 +1778,10 @@ static void ndpi_init_protocol_defaults(struct ndpi_detection_module_struct *ndp
ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0) /* UDP */
);
+#ifdef CUSTOM_NDPI_PROTOCOLS
+#include "../../../nDPI-custom/custom_ndpi_main.c"
+#endif
+
/* calling function for host and content matched protocols */
init_string_based_protocols(ndpi_str);
@@ -1786,6 +1790,12 @@ static void ndpi_init_protocol_defaults(struct ndpi_detection_module_struct *ndp
/* ****************************************************** */
+#ifdef CUSTOM_NDPI_PROTOCOLS
+#include "../../../nDPI-custom/custom_ndpi_protocols.c"
+#endif
+
+/* ****************************************************** */
+
static int ac_match_handler(AC_MATCH_t *m, AC_TEXT_t *txt, AC_REP_t *match) {
int min_len = (txt->length < m->patterns->length) ? txt->length : m->patterns->length;
char buf[64] = { '\0' };
diff --git a/src/lib/protocols/kerberos.c b/src/lib/protocols/kerberos.c
index fa73ab0ae..b7fcfb61d 100644
--- a/src/lib/protocols/kerberos.c
+++ b/src/lib/protocols/kerberos.c
@@ -63,8 +63,8 @@ void ndpi_search_kerberos(struct ndpi_detection_module_struct *ndpi_struct,
u_int realm_len, realm_offset = cname_len + name_offset + 4, i;
char cname_str[24];
- if(cname_len >= sizeof(cname_str))
- cname_len = sizeof(cname_str);
+ if(cname_len > sizeof(cname_str)-1)
+ cname_len = sizeof(cname_str)-1;
strncpy(cname_str, (char*)&packet->payload[name_offset+1], cname_len);
cname_str[cname_len] = '\0';