@@ -1,8 +1,8 @@
/*
* ndpi_main.c
*
- * Copyright (C) 2009-2011 by ipoque GmbH
- * Copyright (C) 2011-13 - ntop.org
+ * Copyright (C) 2009-11 - ipoque GmbH
+ * Copyright (C) 2011-14 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
@@ -28,11 +28,14 @@
#include <errno.h>
#endif
+#include "ahocorasick.h"
#include "ndpi_main.h"
#include "ndpi_protocols.h"
#include "ndpi_utils.h"
-#include "ahocorasick.h"
+#ifndef __KERNEL__
+#include "../../config.h"
+#endif
#undef DEBUG
@@ -62,7 +65,7 @@
#endif
#ifdef __KERNEL__
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
static inline char _tolower(const char c)
{
return c | 0x20;
@@ -73,16 +76,16 @@
unsigned long long acc;
int ok;
- if (base == 0) {
- if (s[0] == '0') {
- if (_tolower(s[1]) == 'x' && isxdigit(s[2]))
+ if(base == 0) {
+ if(s[0] == '0') {
+ if(_tolower(s[1]) == 'x' && isxdigit(s[2]))
base = 16;
else
base = 8;
} else
base = 10;
}
- if (base == 16 && s[0] == '0' && _tolower(s[1]) == 'x')
+ if(base == 16 && s[0] == '0' && _tolower(s[1]) == 'x')
s += 2;
acc = 0;
@@ -90,28 +93,28 @@
while (*s) {
unsigned int val;
- if ('0' <= *s && *s <= '9')
+ if('0' <= *s && *s <= '9')
val = *s - '0';
- else if ('a' <= _tolower(*s) && _tolower(*s) <= 'f')
+ else if('a' <= _tolower(*s) && _tolower(*s) <= 'f')
val = _tolower(*s) - 'a' + 10;
- else if (*s == '\n') {
- if (*(s + 1) == '\0')
+ else if(*s == '\n') {
+ if(*(s + 1) == '\0')
break;
else
return -EINVAL;
} else
return -EINVAL;
- if (val >= base)
+ if(val >= base)
return -EINVAL;
- if (acc > div_u64(ULLONG_MAX - val, base))
+ if(acc > div_u64(ULLONG_MAX - val, base))
return -ERANGE;
acc = acc * base + val;
ok = 1;
s++;
}
- if (!ok)
+ if(!ok)
return -EINVAL;
*res = acc;
return 0;
@@ -119,7 +122,7 @@
int kstrtoull(const char *s, unsigned int base, unsigned long long *res)
{
- if (s[0] == '+')
+ if(s[0] == '+')
s++;
return _kstrtoull(s, base, res);
}
@@ -128,18 +131,18 @@
unsigned long long tmp;
int rv;
- if (s[0] == '-') {
+ if(s[0] == '-') {
rv = _kstrtoull(s + 1, base, &tmp);
- if (rv < 0)
+ if(rv < 0)
return rv;
- if ((long long)(-tmp) >= 0)
+ if((long long)(-tmp) >= 0)
return -ERANGE;
*res = -tmp;
} else {
rv = kstrtoull(s, base, &tmp);
- if (rv < 0)
+ if(rv < 0)
return rv;
- if ((long long)tmp < 0)
+ if((long long)tmp < 0)
return -ERANGE;
*res = tmp;
}
@@ -151,9 +154,9 @@
int rv;
rv = kstrtoll(s, base, &tmp);
- if (rv < 0)
+ if(rv < 0)
return rv;
- if (tmp != (long long)(int)tmp)
+ if(tmp != (long long)(int)tmp)
return -ERANGE;
*res = tmp;
return 0;
@@ -180,19 +183,19 @@
char *key = (char *)vkey;
ndpi_node **rootp = (ndpi_node **)vrootp;
- if (rootp == (ndpi_node **)0)
+ if(rootp == (ndpi_node **)0)
return ((void *)0);
while (*rootp != (ndpi_node *)0) { /* Knuth's T1: */
int r;
- if ((r = (*compar)(key, (*rootp)->key)) == 0) /* T2: */
+ if((r = (*compar)(key, (*rootp)->key)) == 0) /* T2: */
return ((void *)*rootp); /* we found it! */
rootp = (r < 0) ?
&(*rootp)->left : /* T3: follow left branch */
&(*rootp)->right; /* T4: follow right branch */
}
q = (ndpi_node *) ndpi_malloc(sizeof(ndpi_node)); /* T5: key not found */
- if (q != (ndpi_node *)0) { /* make new node */
+ if(q != (ndpi_node *)0) { /* make new node */
*rootp = q; /* link new node to old */
q->key = key; /* initialize new node */
q->left = q->right = (ndpi_node *)0;
@@ -212,21 +215,21 @@
ndpi_node *r;
int cmp;
- if (rootp == (ndpi_node **)0 || *rootp == (ndpi_node *)0)
+ if(rootp == (ndpi_node **)0 || *rootp == (ndpi_node *)0)
return ((ndpi_node *)0);
while ((cmp = (*compar)(key, (*rootp)->key)) != 0) {
p = *rootp;
rootp = (cmp < 0) ?
&(*rootp)->left : /* follow left branch */
&(*rootp)->right; /* follow right branch */
- if (*rootp == (ndpi_node *)0)
+ if(*rootp == (ndpi_node *)0)
return ((void *)0); /* key not found */
}
r = (*rootp)->right; /* D1: */
- if ((q = (*rootp)->left) == (ndpi_node *)0) /* Left (ndpi_node *)0? */
+ if((q = (*rootp)->left) == (ndpi_node *)0) /* Left (ndpi_node *)0? */
q = r;
- else if (r != (ndpi_node *)0) { /* Right link is null? */
- if (r->left == (ndpi_node *)0) { /* D2: Find successor */
+ else if(r != (ndpi_node *)0) { /* Right link is null? */
+ if(r->left == (ndpi_node *)0) { /* D2: Find successor */
r->left = q;
q = r;
} else { /* D3: Find (ndpi_node *)0 link */
@@ -246,14 +249,14 @@
static void
ndpi_trecurse(ndpi_node *root, void (*action)(const void *, ndpi_VISIT, int, void*), int level, void *user_data)
{
- if (root->left == (ndpi_node *)0 && root->right == (ndpi_node *)0)
+ if(root->left == (ndpi_node *)0 && root->right == (ndpi_node *)0)
(*action)(root, ndpi_leaf, level, user_data);
else {
(*action)(root, ndpi_preorder, level, user_data);
- if (root->left != (ndpi_node *)0)
+ if(root->left != (ndpi_node *)0)
ndpi_trecurse(root->left, action, level + 1, user_data);
(*action)(root, ndpi_postorder, level, user_data);
- if (root->right != (ndpi_node *)0)
+ if(root->right != (ndpi_node *)0)
ndpi_trecurse(root->right, action, level + 1, user_data);
(*action)(root, ndpi_endorder, level, user_data);
}
@@ -265,7 +268,7 @@
{
ndpi_node *root = (ndpi_node *)vroot;
- if (root != (ndpi_node *)0 && action != (void (*)(const void *, ndpi_VISIT, int, void*))0)
+ if(root != (ndpi_node *)0 && action != (void (*)(const void *, ndpi_VISIT, int, void*))0)
ndpi_trecurse(root, action, 0, user_data);
}
@@ -277,11 +280,11 @@
char *key = (char *)vkey;
ndpi_node **rootp = (ndpi_node **)vrootp;
- if (rootp == (ndpi_node **)0)
+ if(rootp == (ndpi_node **)0)
return ((ndpi_node *)0);
while (*rootp != (ndpi_node *)0) { /* T1: */
int r;
- if ((r = (*compar)(key, (*rootp)->key)) == 0) /* T2: */
+ if((r = (*compar)(key, (*rootp)->key)) == 0) /* T2: */
return (*rootp); /* key found */
rootp = (r < 0) ?
&(*rootp)->left : /* T3: follow left branch */
@@ -294,9 +297,9 @@
/* Walk the nodes of a tree */
static void ndpi_tdestroy_recurse(ndpi_node* root, void (*free_action)(void *)) {
- if (root->left != NULL)
+ if(root->left != NULL)
ndpi_tdestroy_recurse(root->left, free_action);
- if (root->right != NULL)
+ if(root->right != NULL)
ndpi_tdestroy_recurse(root->right, free_action);
(*free_action) ((void *) root->key);
@@ -306,7 +309,7 @@
void ndpi_tdestroy(void *vrootp, void (*freefct)(void *)) {
ndpi_node *root = (ndpi_node *) vrootp;
- if (root != NULL)
+ if(root != NULL)
ndpi_tdestroy_recurse(root, freefct);
}
@@ -317,14 +320,6 @@
/* ****************************************** */
-
-
-
-
-
-
-/* ****************************************** */
-
#ifdef WIN32
/* http://opensource.apple.com/source/Libc/Libc-186/string.subproj/strcasecmp.c */
@@ -377,7 +372,7 @@
*us2 = (const u_char *)s2;
while (cm[*us1] == cm[*us2++])
- if (*us1++ == '\0')
+ if(*us1++ == '\0')
return (0);
return (cm[*us1] - cm[*--us2]);
}
@@ -387,15 +382,15 @@
const char *s1, *s2;
register size_t n;
{
- if (n != 0) {
+ if(n != 0) {
register const u_char *cm = charmap,
*us1 = (const u_char *)s1,
*us2 = (const u_char *)s2;
do {
- if (cm[*us1] != cm[*us2++])
+ if(cm[*us1] != cm[*us2++])
return (cm[*us1] - cm[*--us2]);
- if (*us1++ == '\0')
+ if(*us1++ == '\0')
break;
} while (--n != 0);
}
@@ -539,6 +534,7 @@
if(protoId >= NDPI_MAX_SUPPORTED_PROTOCOLS+NDPI_MAX_NUM_CUSTOM_PROTOCOLS) {
printf("[NDPI] %s(protoId=%d): INTERNAL ERROR\n", __FUNCTION__, protoId);
+ ndpi_free(name);
return;
}
@@ -605,9 +601,25 @@
ret = *(ndpi_default_ports_tree_node_t**)ndpi_tsearch(node, (void*)root, ndpi_default_ports_tree_node_t_cmp); /* Add it to the tree */
if(ret != node) {
- printf("[NDPI] %s(): found duplicate for port %u\n", __FUNCTION__, port);
- ndpi_free(node);
- break;
+ printf("[NDPI] %s(): found duplicate for port %u: overwriting it with new value\n", __FUNCTION__, port);
+ ret = *(ndpi_default_ports_tree_node_t**)ndpi_tdelete(node, (void*)root, ndpi_default_ports_tree_node_t_cmp); /* Add it to the tree */
+
+ if(!ret) {
+ printf("[NDPI] %s(): internal error\n", __FUNCTION__);
+ ndpi_free(node);
+ break;
+ }
+
+ ndpi_free(ret);
+
+ /* Now let's add it */
+ ret = *(ndpi_default_ports_tree_node_t**)ndpi_tsearch(node, (void*)root, ndpi_default_ports_tree_node_t_cmp); /* Add it to the tree */
+
+ if(ret != node) {
+ printf("[NDPI] %s(): internal error\n", __FUNCTION__);
+ ndpi_free(node);
+ break;
+ }
}
}
}
@@ -616,10 +628,10 @@
/* ****************************************************** */
/*
- NOTE
+ NOTE
- This function must be called with a semaphore set, this in order to avoid
- changing the datastrutures while using them
+ This function must be called with a semaphore set, this in order to avoid
+ changing the datastrutures while using them
*/
static int removeDefaultPort(ndpi_port_range *range,
ndpi_proto_defaults_t *def,
@@ -660,7 +672,7 @@
}
/* The attribute is added here for future use */
- if (strcmp(attr, "host") != 0) {
+ if(strcmp(attr, "host") != 0) {
#ifdef DEBUG
printf("[NTOP] attribute %s not supported\n", attr);
#endif
@@ -684,10 +696,10 @@
/* ****************************************************** */
/*
- NOTE
+ NOTE
- This function must be called with a semaphore set, this in order to avoid
- changing the datastrutures while using them
+ This function must be called with a semaphore set, this in order to avoid
+ changing the datastrutures while using them
*/
static int ndpi_remove_host_url_subprotocol(struct ndpi_detection_module_struct *ndpi_struct,
char *attr, char *value, int protocol_id) {
@@ -707,11 +719,18 @@
{ "fbcdn-", "FaceBook", NDPI_PROTOCOL_FACEBOOK }, /* fbcdn-video-a-akamaihd.net */
{ ".dropbox.com", "DropBox", NDPI_PROTOCOL_DROPBOX },
{ ".gmail.", "GoogleGmail", NDPI_PROTOCOL_GMAIL },
- { "maps.google.com", "GoogleMaps", NDPI_PROTOCOL_GOOGLE_MAPS },
+ { "mail.google.", "GoogleGmail", NDPI_PROTOCOL_GMAIL },
+ { "maps.google.", "GoogleMaps", NDPI_PROTOCOL_GOOGLE_MAPS },
{ "maps.gstatic.com", "GoogleMaps", NDPI_PROTOCOL_GOOGLE_MAPS },
{ ".gstatic.com", "Google", NDPI_PROTOCOL_GOOGLE },
- { ".google.com", "Google", NDPI_PROTOCOL_GOOGLE },
- { ".youtube.", "YouTube", NDPI_PROTOCOL_YOUTUBE },
+ { ".google.", "Google", NDPI_PROTOCOL_GOOGLE },
+ { ".googlesyndication.com", "Google", NDPI_PROTOCOL_GOOGLE },
+ { ".googletagservices.com", "Google", NDPI_PROTOCOL_GOOGLE },
+ { ".2mdn.net", "Google", NDPI_PROTOCOL_GOOGLE },
+ { ".doubleclick.net", "Google", NDPI_PROTOCOL_GOOGLE }, /* Ads */
+ { "youtube.", "YouTube", NDPI_PROTOCOL_YOUTUBE },
+ { ".googlevideo.com", "YouTube", NDPI_PROTOCOL_YOUTUBE },
+ { ".ytimg.com", "YouTube", NDPI_PROTOCOL_YOUTUBE },
{ "itunes.apple.com", "AppleiTunes", NDPI_PROTOCOL_APPLE_ITUNES },
{ ".apple.com", "Apple", NDPI_PROTOCOL_APPLE },
{ ".mzstatic.com", "Apple", NDPI_PROTOCOL_APPLE },
@@ -721,6 +740,7 @@
{ ".grooveshark.com", "GrooveShark", NDPI_PROTOCOL_GROOVESHARK },
{ ".tuenti.com", "Tuenti", NDPI_PROTOCOL_TUENTI },
{ ".skype.com", "Skype", NDPI_PROTOCOL_SKYPE },
+ { ".whatsapp.net", "WhatsApp", NDPI_PROTOCOL_WHATSAPP },
{ ".skypeassets.com", "Skype", NDPI_PROTOCOL_SKYPE },
{ ".yahoo.", "Yahoo", NDPI_PROTOCOL_YAHOO },
{ NULL, 0 }
@@ -1236,6 +1256,9 @@
ndpi_set_proto_defaults(ndpi_mod, NDPI_PROTOCOL_WHOIS_DAS, "Whois-DAS",
ndpi_build_default_ports(ports_a, 43, 4343, 0, 0, 0) /* TCP */,
ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0) /* UDP */);
+ ndpi_set_proto_defaults(ndpi_mod, NDPI_PROTOCOL_COLLECTD, "Collectd",
+ ndpi_build_default_ports(ports_a, 0, 0, 0, 0, 0) /* TCP */,
+ ndpi_build_default_ports(ports_b, 25826, 0, 0, 0, 0) /* UDP */);
init_string_based_protocols(ndpi_mod);
@@ -1272,7 +1295,7 @@
ndpi_str = ndpi_malloc(sizeof(struct ndpi_detection_module_struct));
- if (ndpi_str == NULL) {
+ if(ndpi_str == NULL) {
ndpi_debug_printf(0, NULL, NDPI_LOG_DEBUG, "ndpi_init_detection_module initial malloc failed\n");
return NULL;
}
@@ -1319,6 +1342,7 @@
ndpi_str->ac_automa = ac_automata_init(ac_match_handler);
+#ifdef USE_SKYPE_HEURISTICS
ndpi_init_lru_cache(&ndpi_str->skypeCache, 4096);
#ifndef __KERNEL__
@@ -1326,11 +1350,14 @@
#else
spin_lock_init(&ndpi_str->skypeCacheLock);
#endif
+#endif
ndpi_init_protocol_defaults(ndpi_str);
return ndpi_str;
}
+/* ****************************************************** */
+
void ndpi_exit_detection_module(struct ndpi_detection_module_struct
*ndpi_struct, void (*ndpi_free) (void *ptr))
{
@@ -1348,14 +1375,54 @@
if(ndpi_struct->ac_automa != NULL)
ac_automata_release((AC_AUTOMATA_t*)ndpi_struct->ac_automa);
+#ifdef USE_SKYPE_HEURISTICS
ndpi_free_lru_cache(&ndpi_struct->skypeCache);
#ifndef __KERNEL__
pthread_mutex_destroy(&ndpi_struct->skypeCacheLock);
#endif
+#endif
ndpi_free(ndpi_struct);
}
}
+/* ****************************************************** */
+
+static unsigned int ndpi_guess_protocol_id(struct ndpi_detection_module_struct *ndpi_struct,
+ u_int8_t proto,
+ u_int32_t shost, u_int16_t sport,
+ u_int32_t dhost, u_int16_t dport) {
+ const void *ret;
+ ndpi_default_ports_tree_node_t node;
+
+ if(sport && dport) {
+ node.default_port = sport;
+ ret = ndpi_tfind(&node,
+ (proto == IPPROTO_TCP) ? (void*)&ndpi_struct->tcpRoot : (void*)&ndpi_struct->udpRoot,
+ ndpi_default_ports_tree_node_t_cmp);
+
+ if(ret == NULL) {
+ node.default_port = dport;
+ ret = ndpi_tfind(&node,
+ (proto == IPPROTO_TCP) ? (void*)&ndpi_struct->tcpRoot : (void*)&ndpi_struct->udpRoot,
+ ndpi_default_ports_tree_node_t_cmp);
+ }
+
+ if(ret != NULL) {
+ ndpi_default_ports_tree_node_t *found = *(ndpi_default_ports_tree_node_t**)ret;
+
+ return(found->proto->protoId);
+ }
+ }
+
+#ifdef USE_SKYPE_HEURISTICS
+ /* Use skype as last resort */
+ if(shost && dhost && is_skype_connection(ndpi_struct, shost, dhost))
+ return(NDPI_PROTOCOL_SKYPE);
+#endif
+
+ return(NDPI_PROTOCOL_UNKNOWN);
+}
+
/* ******************************************************************** */
#ifndef __KERNEL__
@@ -1458,18 +1525,18 @@
ndpi_port_range range;
int is_tcp = 0, is_udp = 0;
- if (strncmp(attr, "tcp:", 4) == 0)
+ if(strncmp(attr, "tcp:", 4) == 0)
is_tcp = 1, value = &attr[4];
- else if (strncmp(attr, "udp:", 4) == 0)
+ else if(strncmp(attr, "udp:", 4) == 0)
is_udp = 1, value = &attr[4];
- else if (strncmp(attr, "host:", 5) == 0) {
+ else if(strncmp(attr, "host:", 5) == 0) {
/* host:"<value>",host:"<value>",.....@<subproto> */
value = &attr[5];
- if (value[0] == '"') value++; /* remove leading " */
- if (value[strlen(value)-1] == '"') value[strlen(value)-1] = '\0'; /* remove trailing " */
+ if(value[0] == '"') value++; /* remove leading " */
+ if(value[strlen(value)-1] == '"') value[strlen(value)-1] = '\0'; /* remove trailing " */
}
- if (is_tcp || is_udp) {
+ if(is_tcp || is_udp) {
if(sscanf(value, "%u-%u", (unsigned int *)&range.port_low, (unsigned int *)&range.port_high) != 2)
range.port_low = range.port_high = atoi(&elem[4]);
if(do_add)
@@ -1537,6 +1604,50 @@
return(0);
}
+/* ntop */
+void ndpi_set_bitmask_protocol_detection(struct ndpi_detection_module_struct *ndpi_struct,
+ const NDPI_PROTOCOL_BITMASK * detection_bitmask,
+ u_int32_t idx,
+ u_int16_t ndpi_protocol_id,
+ void (*func) (struct ndpi_detection_module_struct *, struct ndpi_flow_struct *flow),
+ const NDPI_SELECTION_BITMASK_PROTOCOL_SIZE ndpi_selection_bitmask,
+ u_int8_t b_save_bitmask_unknow,
+ u_int8_t b_add_detection_bitmask)
+{
+ /*
+ Compare specify protocol bitmask with main detection bitmask
+ */
+ if(NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, ndpi_protocol_id) != 0) {
+
+#ifdef DEBUG
+ printf("[NDPI] ndpi_set_bitmask_protocol_detection: idx callback_buffer= %u, protocol_id=%u\n", idx, ndpi_protocol_id);
+#endif
+ /*
+ Set funcition and index protocol within proto_default strcuture for port protocol detection
+ and callback_buffer function for DPI protocol detection
+ */
+ ndpi_struct->proto_defaults[ndpi_protocol_id].protoIdx = idx;
+
+ ndpi_struct->proto_defaults[ndpi_protocol_id].func =
+ ndpi_struct->callback_buffer[idx].func = func;
+ /*
+ Set ndpi_selection_bitmask for protocol
+ */
+ ndpi_struct->callback_buffer[idx].ndpi_selection_bitmask = ndpi_selection_bitmask;
+
+ /*
+ Reset protocol detection bitmask via NDPI_PROTOCOL_UNKNOW and than add specify protocol bitmast to callback
+ buffer.
+ */
+ if (b_save_bitmask_unknow) NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[idx].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
+
+ if (b_add_detection_bitmask) NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[idx].detection_bitmask, ndpi_protocol_id);
+
+ NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[idx].excluded_protocol_bitmask, ndpi_protocol_id);
+
+ }
+}
+
/* ******************************************************************** */
void ndpi_set_protocol_detection_bitmask2(struct ndpi_detection_module_struct *ndpi_struct,
@@ -1552,1852 +1663,1726 @@
/* set this here to zero to be interrupt safe */
ndpi_struct->callback_buffer_size = 0;
-#ifdef NDPI_PROTOCOL_HTTP
-#ifdef NDPI_PROTOCOL_MPEG
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_MPEG) != 0)
- goto hack_do_http_detection;
-#endif
-#ifdef NDPI_PROTOCOL_FLASH
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_FLASH) != 0)
- goto hack_do_http_detection;
-#endif
-#ifdef NDPI_PROTOCOL_QUICKTIME
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_QUICKTIME) != 0)
- goto hack_do_http_detection;
-#endif
-#ifdef NDPI_PROTOCOL_REALMEDIA
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_REALMEDIA) != 0)
- goto hack_do_http_detection;
-#endif
-#ifdef NDPI_PROTOCOL_WINDOWSMEDIA
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_WINDOWSMEDIA) != 0)
- goto hack_do_http_detection;
-#endif
-#ifdef NDPI_PROTOCOL_MMS
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_MMS) != 0)
- goto hack_do_http_detection;
-#endif
-#ifdef NDPI_PROTOCOL_OFF
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_OFF) != 0)
- goto hack_do_http_detection;
-#endif
-#ifdef NDPI_PROTOCOL_XBOX
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_XBOX) != 0)
- goto hack_do_http_detection;
-#endif
-#ifdef NDPI_PROTOCOL_WINDOWS_UPDATE
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_WINDOWS_UPDATE) != 0)
- goto hack_do_http_detection;
-#endif
-#ifdef NDPI_PROTOCOL_QQ
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_QQ) != 0)
- goto hack_do_http_detection;
-#endif
-#ifdef NDPI_PROTOCOL_AVI
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_AVI) != 0)
- goto hack_do_http_detection;
-#endif
-#ifdef NDPI_PROTOCOL_OGG
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_OGG) != 0)
- goto hack_do_http_detection;
-#endif
-#ifdef NDPI_PROTOCOL_MOVE
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_MOVE) != 0)
- goto hack_do_http_detection;
-#endif
-#ifdef NDPI_PROTOCOL_RTSP
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_RTSP) != 0)
- goto hack_do_http_detection;
-#endif
- /* HTTP DETECTION MUST BE BEFORE DDL BUT AFTER ALL OTHER PROTOCOLS WHICH USE HTTP ALSO */
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_HTTP) != 0) {
- hack_do_http_detection:
- // ndpi_struct->subprotocol_conf[NDPI_PROTOCOL_HTTP].func = ndpi_http_subprotocol_conf;
- ndpi_struct->callback_buffer[a].func = ndpi_search_http_tcp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask = NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD;
+#ifdef NDPI_PROTOCOL_HTTP
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_HTTP,
+ ndpi_search_http_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_HTTP);
#ifdef NDPI_PROTOCOL_MPEG
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_MPEG);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_MPEG,
+ ndpi_search_http_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD,
+ NO_SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
#endif
#ifdef NDPI_PROTOCOL_FLASH
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_FLASH);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_FLASH,
+ ndpi_search_http_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD,
+ NO_SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
#endif
#ifdef NDPI_PROTOCOL_QUICKTIME
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_QUICKTIME);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_QUICKTIME,
+ ndpi_search_http_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD,
+ NO_SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
#endif
#ifdef NDPI_PROTOCOL_REALMEDIA
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_REALMEDIA);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_REALMEDIA,
+ ndpi_search_http_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD,
+ NO_SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
#endif
#ifdef NDPI_PROTOCOL_WINDOWSMEDIA
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask,
- NDPI_PROTOCOL_WINDOWSMEDIA);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_WINDOWSMEDIA,
+ ndpi_search_http_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD,
+ NO_SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
#endif
#ifdef NDPI_PROTOCOL_MMS
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_MMS);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_MMS,
+ ndpi_search_http_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD,
+ NO_SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
#endif
#ifdef NDPI_PROTOCOL_OFF
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_OFF);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_OFF,
+ ndpi_search_http_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD,
+ NO_SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
#endif
#ifdef NDPI_PROTOCOL_XBOX
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_XBOX);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_XBOX,
+ ndpi_search_http_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD,
+ NO_SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
#endif
#ifdef NDPI_PROTOCOL_WINDOWS_UPDATE
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_WINDOWS_UPDATE);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_WINDOWS_UPDATE,
+ ndpi_search_http_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD,
+ NO_SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
#endif
#ifdef NDPI_PROTOCOL_QQ
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_QQ);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_QQ,
+ ndpi_search_http_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD,
+ NO_SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
#endif
#ifdef NDPI_PROTOCOL_AVI
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_AVI);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_AVI,
+ ndpi_search_http_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD,
+ NO_SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
#endif
#ifdef NDPI_PROTOCOL_OGG
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_OGG);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_OGG,
+ ndpi_search_http_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD,
+ NO_SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
#endif
#ifdef NDPI_PROTOCOL_MOVE
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_MOVE);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_MOVE,
+ ndpi_search_http_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD,
+ NO_SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
#endif
#ifdef NDPI_PROTOCOL_RTSP
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_RTSP);
-#endif
-
- NDPI_BITMASK_SET(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
- ndpi_struct->callback_buffer[a].detection_bitmask);
- NDPI_DEL_PROTOCOL_FROM_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
- NDPI_PROTOCOL_UNKNOWN);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_RTSP,
+ ndpi_search_http_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD,
+ NO_SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+#endif
+ /*Update excluded protocol bitmask*/
+ NDPI_BITMASK_SET(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
+ ndpi_struct->callback_buffer[a].detection_bitmask);
+
+ /*Delete protocol from exluded protocol bitmask*/
+ NDPI_DEL_PROTOCOL_FROM_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
+ NDPI_PROTOCOL_UNKNOWN);
- NDPI_DEL_PROTOCOL_FROM_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
- NDPI_PROTOCOL_QQ);
+ NDPI_DEL_PROTOCOL_FROM_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
+ NDPI_PROTOCOL_QQ);
#ifdef NDPI_PROTOCOL_FLASH
- NDPI_DEL_PROTOCOL_FROM_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
- NDPI_PROTOCOL_FLASH);
+ NDPI_DEL_PROTOCOL_FROM_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
+ NDPI_PROTOCOL_FLASH);
#endif
- NDPI_DEL_PROTOCOL_FROM_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
- NDPI_PROTOCOL_MMS);
+ NDPI_DEL_PROTOCOL_FROM_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
+ NDPI_PROTOCOL_MMS);
#ifdef NDPI_PROTOCOL_RTSP
- NDPI_DEL_PROTOCOL_FROM_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
- NDPI_PROTOCOL_RTSP);
+ NDPI_DEL_PROTOCOL_FROM_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
+ NDPI_PROTOCOL_RTSP);
#endif
- NDPI_DEL_PROTOCOL_FROM_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
- NDPI_PROTOCOL_XBOX);
+ NDPI_DEL_PROTOCOL_FROM_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
+ NDPI_PROTOCOL_XBOX);
- NDPI_BITMASK_SET(ndpi_struct->generic_http_packet_bitmask,
- ndpi_struct->callback_buffer[a].detection_bitmask);
+ NDPI_BITMASK_SET(ndpi_struct->generic_http_packet_bitmask,
+ ndpi_struct->callback_buffer[a].detection_bitmask);
- NDPI_DEL_PROTOCOL_FROM_BITMASK(ndpi_struct->generic_http_packet_bitmask, NDPI_PROTOCOL_UNKNOWN);
+ NDPI_DEL_PROTOCOL_FROM_BITMASK(ndpi_struct->generic_http_packet_bitmask, NDPI_PROTOCOL_UNKNOWN);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
-#ifdef NDPI_PROTOCOL_SSL
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_SSL) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_ssl_tcp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask = NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_SSL);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_SSL);
- a++;
- }
-#endif
-#ifdef NDPI_PROTOCOL_STUN
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_STUN) != 0
-#ifdef NDPI_PROTOCOL_RTP
- || NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_RTP) != 0
+#ifdef NDPI_PROTOCOL_SSL
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_SSL,
+ ndpi_search_ssl_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+ /* Update callback_buffer index */
+ a++;
#endif
- ) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_stun;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD;
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
+#ifdef NDPI_PROTOCOL_STUN
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_STUN,
+ ndpi_search_stun,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_STUN);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
-#ifdef NDPI_PROTOCOL_RTP
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_RTP) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_rtp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD;
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
+#ifdef NDPI_PROTOCOL_RTP
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_RTP,
+ ndpi_search_rtp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+ /* Add protocol bitmask dependencies to detected bitmask*/
#ifdef NDPI_PROTOCOL_STUN
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_STUN);
+ NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_STUN);
#endif
+ /* consider also real protocol for detection select in main loop */
+ ndpi_struct->callback_buffer[a].detection_feature = NDPI_SELECT_DETECTION_WITH_REAL_PROTOCOL;
+ /* Update callback_buffer index */
+ a++;
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_RTP);
-
- /* consider also real protocol for detection select in main loop */
- ndpi_struct->callback_buffer[a].detection_feature = NDPI_SELECT_DETECTION_WITH_REAL_PROTOCOL;
-
- a++;
- }
#endif
-#ifdef NDPI_PROTOCOL_RDP
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_RDP) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_rdp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_RDP);
- a++;
- }
+#ifdef NDPI_PROTOCOL_RDP
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,
+ detection_bitmask,
+ a,
+ NDPI_PROTOCOL_RDP,
+ ndpi_search_rdp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+ /* Update callback_buffer index */
+ a++;
#endif
-#ifdef NDPI_PROTOCOL_SIP
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_SIP) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_sip;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD; /* Fix courtesy of Miguel Quesada <mquesadab@gmail.com> */
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_SIP);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_SIP);
- a++;
- }
+#ifdef NDPI_PROTOCOL_SIP
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_SIP,
+ ndpi_search_sip,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD,/* Fix courtesy of Miguel Quesada <mquesadab@gmail.com> */
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_BITTORRENT
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_BITTORRENT) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_bittorrent;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask = NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_BITTORRENT);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_BITTORRENT);
-
- a++;
- }
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_BITTORRENT,
+ ndpi_search_bittorrent,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_EDONKEY
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_EDONKEY) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_edonkey;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask = NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_EDONKEY);
-
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_EDONKEY,
+ ndpi_search_edonkey,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+ /* Add protocol bitmask dependencies to detected bitmask*/
#ifdef NDPI_PROTOCOL_BITTORRENT
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_BITTORRENT);
+ NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_BITTORRENT);
#endif
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_EDONKEY);
-
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_FASTTRACK
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_FASTTRACK) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_fasttrack_tcp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_FASTTRACK);
- a++;
-
- }
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_FASTTRACK,
+ ndpi_search_fasttrack_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_GNUTELLA
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_GNUTELLA) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_gnutella;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_GNUTELLA,
+ ndpi_search_gnutella,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+ /* Add protocol bitmask dependencies to detected bitmask*/
#ifdef NDPI_PROTOCOL_XBOX
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_XBOX);
+ NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_XBOX);
#endif
#ifdef NDPI_PROTOCOL_WINDOWS_UPDATE
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_WINDOWS_UPDATE);
-
+ NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_WINDOWS_UPDATE);
#endif
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_GNUTELLA);
-
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
-#ifdef NDPI_PROTOCOL_WINMX
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_WINMX) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_winmx_tcp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_WINMX);
+#ifdef NDPI_PROTOCOL_WINMX
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_WINMX,
+ ndpi_search_winmx_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
-#ifdef NDPI_PROTOCOL_DIRECTCONNECT
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_DIRECTCONNECT) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_directconnect;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask,
- NDPI_PROTOCOL_DIRECTCONNECT);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
- NDPI_PROTOCOL_DIRECTCONNECT);
+#ifdef NDPI_PROTOCOL_DIRECTCONNECT
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_DIRECTCONNECT,
+ ndpi_search_directconnect,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_MSN
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_MSN) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_msn;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_MSN);
+ NDPI_BITMASK_RESET(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask);
-#ifdef NDPI_PROTOCOL_HTTP
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_HTTP);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_MSN,
+ ndpi_search_msn,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+ /* Add protocol bitmask dependencies to detected bitmask*/
+#ifdef NDPI_PROTOCOL_HTTP
+ NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_HTTP);
#endif
#ifdef NDPI_PROTOCOL_SSL
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_SSL);
-
+ NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_SSL);
#endif
- NDPI_BITMASK_RESET(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_MSN);
-
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
-#ifdef NDPI_PROTOCOL_YAHOO
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_YAHOO) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_yahoo;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask = NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP;
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_YAHOO);
+#ifdef NDPI_PROTOCOL_YAHOO
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_YAHOO,
+ ndpi_search_yahoo,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+ /* Add protocol bitmask dependencies to detected bitmask*/
#ifdef NDPI_PROTOCOL_SSL
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_SSL);
-
+ NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_SSL);
#endif
#ifdef NDPI_PROTOCOL_HTTP
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_HTTP);
-
+ NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_HTTP);
#endif
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_YAHOO);
-
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_OSCAR
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_OSCAR) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_oscar;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_OSCAR);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_OSCAR,
+ ndpi_search_oscar,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_OSCAR);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_APPLEJUICE
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_APPLEJUICE) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_applejuice_tcp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_APPLEJUICE,
+ ndpi_search_applejuice_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_APPLEJUICE);
-
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_SOULSEEK
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_SOULSEEK) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_soulseek_tcp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask = NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_SOULSEEK);
-
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_SOULSEEK,
+ ndpi_search_soulseek_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_SOULSEEK);
-
-
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
-#ifdef NDPI_PROTOCOL_IRC
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_IRC) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_irc_tcp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_IRC);
+#ifdef NDPI_PROTOCOL_IRC
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_IRC,
+ ndpi_search_irc_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+ /* Add protocol bitmask dependencies to detected bitmask*/
#ifdef NDPI_PROTOCOL_HTTP
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_HTTP);
-
+ NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_HTTP);
#endif
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_IRC);
-
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
+
#ifdef NDPI_PROTOCOL_UNENCRYPED_JABBER
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_UNENCRYPED_JABBER) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_jabber_tcp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask,
- NDPI_PROTOCOL_UNENCRYPED_JABBER);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_UNENCRYPED_JABBER,
+ ndpi_search_jabber_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+ /* Add protocol bitmask dependencies to detected bitmask*/
#ifdef NDPI_PROTOCOL_SSL
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_SSL);
-
+ NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_SSL);
#endif
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
- NDPI_PROTOCOL_UNENCRYPED_JABBER);
-
#ifdef NDPI_PROTOCOL_TRUPHONE
- /* also exlude truphone since this is detected in jabber */
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
- NDPI_PROTOCOL_TRUPHONE);
-
+ /* also exlude truphone since this is detected in jabber */
+ NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
+ NDPI_PROTOCOL_TRUPHONE);
#endif
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
-#ifdef NDPI_PROTOCOL_MAIL_POP
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_MAIL_POP) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_mail_pop_tcp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_MAIL_POP);
+#ifdef NDPI_PROTOCOL_MAIL_POP
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_MAIL_POP,
+ ndpi_search_mail_pop_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_MAIL_IMAP
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_MAIL_IMAP) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_mail_imap_tcp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_MAIL_IMAP,
+ ndpi_search_mail_imap_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_MAIL_IMAP);
-
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_MAIL_SMTP
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_MAIL_SMTP) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_mail_smtp_tcp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_MAIL_SMTP,
+ ndpi_search_mail_smtp_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_MAIL_SMTP);
-
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_FTP
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_FTP) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_ftp_tcp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITHOUT_RETRANSMISSION;
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_FTP,
+ ndpi_search_ftp_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_FTP);
-
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_FTP);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_USENET
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_USENET) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_usenet_tcp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_USENET);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_USENET,
+ ndpi_search_usenet_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_DNS
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_DNS) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_dns;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_DNS,
+ ndpi_search_dns,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_DNS);
-
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_FILETOPIA
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_FILETOPIA) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_filetopia_tcp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_FILETOPIA);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_FILETOPIA,
+ ndpi_search_filetopia_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_VMWARE
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_VMWARE) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_vmware;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_VMWARE);
- a++;
- }
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_VMWARE,
+ ndpi_search_vmware,
+ NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_IMESH
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_IMESH) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_imesh_tcp_udp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD;
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_IMESH,
+ ndpi_search_imesh_tcp_udp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_SSL);
-
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_IMESH);
-
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_MMS
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_MMS) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_mms_tcp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_MMS,
+ ndpi_search_mms_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_MMS);
-
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
+
#if defined(NDPI_PROTOCOL_IPSEC) || defined(NDPI_PROTOCOL_GRE) || defined(NDPI_PROTOCOL_ICMP) || defined(NDPI_PROTOCOL_IGMP) || defined(NDPI_PROTOCOL_EGP) || defined(NDPI_PROTOCOL_SCTP) || defined(NDPI_PROTOCOL_OSPF) || defined(NDPI_PROTOCOL_IP_IN_IP) || defined(NDPI_PROTOCOL_ICMPV6)
+
/* always add non tcp/udp if one protocol is compiled in */
- if (1) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_in_non_tcp_udp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask = NDPI_SELECTION_BITMASK_PROTOCOL_IPV4_OR_IPV6;
+ NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
+
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_IPSEC,
+ ndpi_search_in_non_tcp_udp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_IPV4_OR_IPV6,
+ NO_SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_GRE,
+ ndpi_search_in_non_tcp_udp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_IPV4_OR_IPV6,
+ NO_SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_ICMP,
+ ndpi_search_in_non_tcp_udp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_IPV4_OR_IPV6,
+ NO_SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_IGMP,
+ ndpi_search_in_non_tcp_udp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_IPV4_OR_IPV6,
+ NO_SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_EGP,
+ ndpi_search_in_non_tcp_udp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_IPV4_OR_IPV6,
+ NO_SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_SCTP,
+ ndpi_search_in_non_tcp_udp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_IPV4_OR_IPV6,
+ NO_SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_OSPF,
+ ndpi_search_in_non_tcp_udp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_IPV4_OR_IPV6,
+ NO_SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_IP_IN_IP,
+ ndpi_search_in_non_tcp_udp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_IPV4_OR_IPV6,
+ NO_SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_ICMPV6,
+ ndpi_search_in_non_tcp_udp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_IPV4_OR_IPV6,
+ NO_SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+
+ /* Add protocol bitmask dependencies to detected bitmask*/
+ NDPI_BITMASK_RESET(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_BITMASK_RESET(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask);
#ifdef NDPI_PROTOCOL_IPSEC
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
- NDPI_PROTOCOL_IPSEC);
+ NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
+ NDPI_PROTOCOL_IPSEC);
#endif
#ifdef NDPI_PROTOCOL_GRE
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
- NDPI_PROTOCOL_GRE);
+ NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
+ NDPI_PROTOCOL_GRE);
#endif
#ifdef NDPI_PROTOCOL_IGMP
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
- NDPI_PROTOCOL_ICMP);
+ NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
+ NDPI_PROTOCOL_ICMP);
#endif
#ifdef NDPI_PROTOCOL_IGMP
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
- NDPI_PROTOCOL_IGMP);
+ NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
+ NDPI_PROTOCOL_IGMP);
#endif
#ifdef NDPI_PROTOCOL_EGP
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
- NDPI_PROTOCOL_EGP);
+ NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
+ NDPI_PROTOCOL_EGP);
#endif
#ifdef NDPI_PROTOCOL_SCTP
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
- NDPI_PROTOCOL_SCTP);
+ NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
+ NDPI_PROTOCOL_SCTP);
#endif
#ifdef NDPI_PROTOCOL_OSPF
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
- NDPI_PROTOCOL_OSPF);
+ NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
+ NDPI_PROTOCOL_OSPF);
#endif
#ifdef NDPI_PROTOCOL_IP_IN_IP
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
- NDPI_PROTOCOL_IP_IN_IP);
+ NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
+ NDPI_PROTOCOL_IP_IN_IP);
#endif
#ifdef NDPI_PROTOCOL_ICMPV6
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
- NDPI_PROTOCOL_ICMPV6);
+ NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
+ NDPI_PROTOCOL_ICMPV6);
#endif
- a++;
- }
-#endif
-#ifdef NDPI_PROTOCOL_TVANTS
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_TVANTS) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_tvants_udp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD;
+ /* Update callback_buffer index */
+ a++;
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
+#endif
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_TVANTS);
- a++;
- }
-#endif
+#ifdef NDPI_PROTOCOL_TVANTS
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_TVANTS,
+ ndpi_search_tvants_udp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- ndpi_struct->callback_buffer[a].func = ndpi_search_tcp_or_udp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask = NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP;
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
+ /* Update callback_buffer index */
a++;
+#endif
#ifdef NDPI_PROTOCOL_SOPCAST
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_SOPCAST) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_sopcast;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_SOPCAST);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_SOPCAST,
+ ndpi_search_sopcast,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_TVUPLAYER
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_TVUPLAYER) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_tvuplayer;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_TVUPLAYER,
+ ndpi_search_tvuplayer,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_TVUPLAYER);
-
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_PPSTREAM
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_PPSTREAM) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_ppstream;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_PPSTREAM);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_PPSTREAM,
+ ndpi_search_ppstream,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_PPLIVE
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_PPLIVE) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_pplive_tcp_udp;
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_PPLIVE);
-
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD;
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_PPLIVE,
+ ndpi_search_pplive_tcp_udp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_PPLIVE);
-
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_IAX
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_IAX) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_iax;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask = NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_IAX);
-
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_IAX,
+ ndpi_search_iax,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_IAX);
-
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_MGCP
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_MGCP) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_mgcp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask = NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- //NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_MGCP);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_MGCP);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_MGCP,
+ ndpi_search_mgcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_ZATTOO
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_ZATTOO) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_zattoo;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP_WITH_PAYLOAD;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_ZATTOO);
-
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_ZATTOO,
+ ndpi_search_zattoo,
+ NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+ /* Add protocol bitmask dependencies to detected bitmask*/
#ifdef NDPI_PROTOCOL_FLASH
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_FLASH);
-
+ NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_FLASH);
#endif
#ifdef NDPI_PROTOCOL_HTTP
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_HTTP);
-
+ NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_HTTP);
#endif
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_ZATTOO);
-
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_QQ
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_QQ) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_qq;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_QQ,
+ ndpi_search_qq,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_QQ);
-
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_QQ);
-
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_SSH
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_SSH) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_ssh_tcp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_SSH,
+ ndpi_search_ssh_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_SSH);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_POPO
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_POPO) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_popo_tcp_udp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_POPO,
+ ndpi_search_popo_tcp_udp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_POPO);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_THUNDER
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_THUNDER) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_thunder;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_THUNDER,
+ ndpi_search_thunder,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_THUNDER);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_VNC
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_VNC) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_vnc_tcp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_VNC,
+ ndpi_search_vnc_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_VNC);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_TEAMVIEWER
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_TEAMVIEWER) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_teamview;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD;
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_TEAMVIEWER,
+ ndpi_search_teamview,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_TEAMVIEWER);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_TEAMVIEWER);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_DHCP
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_DHCP) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_dhcp_udp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask = NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD;
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_DHCP,
+ ndpi_search_dhcp_udp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_DHCP);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_SOCRATES
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_SOCRATES) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_socrates;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD;
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_SOCRATES,
+ ndpi_search_socrates,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_SOCRATES);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_STEAM
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_STEAM) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_steam;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_STEAM,
+ ndpi_search_steam,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_STEAM);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_HALFLIFE2
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_HALFLIFE2) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_halflife2;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask = NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD;
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_HALFLIFE2,
+ ndpi_search_halflife2,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_HALFLIFE2);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_XBOX
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_XBOX) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_xbox;
-
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_XBOX,
+ ndpi_search_xbox,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_XBOX);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_HTTP_APPLICATION_ACTIVESYNC
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_HTTP_APPLICATION_ACTIVESYNC) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_activesync;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
- NDPI_PROTOCOL_HTTP_APPLICATION_ACTIVESYNC);
- a++;
- }
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_HTTP_APPLICATION_ACTIVESYNC,
+ ndpi_search_activesync,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_SMB
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_SMB) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_smb_tcp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_SMB,
+ ndpi_search_smb_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_SMB);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_TELNET
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_TELNET) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_telnet_tcp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_TELNET,
+ ndpi_search_telnet_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_TELNET);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_NTP
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_NTP) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_ntp_udp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask = NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_NTP,
+ ndpi_search_ntp_udp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_NTP);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_NFS
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_NFS) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_nfs;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_NFS,
+ ndpi_search_nfs,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_NFS);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_SSDP
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_SSDP) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_ssdp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask = NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_SSDP,
+ ndpi_search_ssdp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_SSDP);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_WORLDOFWARCRAFT
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_WORLDOFWARCRAFT) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_worldofwarcraft;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
- NDPI_PROTOCOL_WORLDOFWARCRAFT);
- a++;
- }
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_WORLDOFWARCRAFT,
+ ndpi_search_worldofwarcraft,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_FLASH
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_FLASH) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_flash;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_FLASH,
+ ndpi_search_flash,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_FLASH);
-
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_FLASH);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_POSTGRES
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_POSTGRES) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_postgres_tcp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_POSTGRES,
+ ndpi_search_postgres_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_POSTGRES);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_MYSQL
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_MYSQL) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_mysql_tcp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_MYSQL,
+ ndpi_search_mysql_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_MYSQL);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_BGP
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_BGP) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_bgp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_BGP,
+ ndpi_search_bgp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_BGP);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_QUAKE
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_QUAKE) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_quake;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask = NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_QUAKE,
+ ndpi_search_quake,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_QUAKE);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_BATTLEFIELD
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_BATTLEFIELD) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_battlefield;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask = NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
- NDPI_PROTOCOL_BATTLEFIELD);
- a++;
- }
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_BATTLEFIELD,
+ ndpi_search_battlefield,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_PCANYWHERE
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_PCANYWHERE) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_pcanywhere;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_PCANYWHERE,
+ ndpi_search_pcanywhere,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_PCANYWHERE);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_SNMP
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_SNMP) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_snmp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask = NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD;
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_SNMP,
+ ndpi_search_snmp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_SNMP);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_KONTIKI
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_KONTIKI) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_kontiki;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask = NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_KONTIKI,
+ ndpi_search_kontiki,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_KONTIKI);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_ICECAST
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_ICECAST) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_icecast_tcp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask = NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-#ifdef NDPI_PROTOCOL_HTTP
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_HTTP);
+
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_ICECAST,
+ ndpi_search_icecast_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+ /* Add protocol bitmask dependencies to detected bitmask*/
+#ifdef NDPI_PROTOCOL_HTTP
+ NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_HTTP);
#endif
#ifdef NDPI_PROTOCOL_MPEG
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_MPEG);
+ NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_MPEG);
#endif
#ifdef NDPI_PROTOCOL_QUICKTIME
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_QUICKTIME);
+ NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_QUICKTIME);
#endif
#ifdef NDPI_PROTOCOL_REALMEDIA
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_REALMEDIA);
+ NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_REALMEDIA);
#endif
#ifdef NDPI_PROTOCOL_WINDOWSMEDIA
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask,
- NDPI_PROTOCOL_WINDOWSMEDIA);
+ NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask,
+ NDPI_PROTOCOL_WINDOWSMEDIA);
#endif
#ifdef NDPI_PROTOCOL_AVI
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_AVI);
+ NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_AVI);
#endif
#ifdef NDPI_PROTOCOL_OGG
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_OGG);
+ NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_OGG);
#endif
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_ICECAST);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_SHOUTCAST
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_SHOUTCAST) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_shoutcast_tcp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-#ifdef NDPI_PROTOCOL_HTTP
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_HTTP);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_SHOUTCAST,
+ ndpi_search_shoutcast_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+ /* Add protocol bitmask dependencies to detected bitmask*/
+#ifdef NDPI_PROTOCOL_HTTP
+ NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_HTTP);
#endif
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_SHOUTCAST);
- a++;
- }
+ a++;
#endif
+
#ifdef NDPI_PROTOCOL_HTTP_APPLICATION_VEOHTV
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_HTTP_APPLICATION_VEOHTV) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_veohtv_tcp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-#ifdef NDPI_PROTOCOL_HTTP
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_HTTP);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_HTTP_APPLICATION_VEOHTV,
+ ndpi_search_veohtv_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+ /* Add protocol bitmask dependencies to detected bitmask*/
+#ifdef NDPI_PROTOCOL_HTTP
+ NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_HTTP);
#endif
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
- NDPI_PROTOCOL_HTTP_APPLICATION_VEOHTV);
- a++;
- }
+ a++;
#endif
#ifdef NDPI_PROTOCOL_KERBEROS
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_KERBEROS) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_kerberos;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_KERBEROS,
+ ndpi_search_kerberos,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_KERBEROS);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_OPENFT
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_OPENFT) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_openft_tcp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_OPENFT,
+ ndpi_search_openft_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_OPENFT);
- a++;
- }
+ /* Update callback_buffer index */
#endif
#ifdef NDPI_PROTOCOL_SYSLOG
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_SYSLOG) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_syslog;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_SYSLOG,
+ ndpi_search_syslog,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_SYSLOG);
-
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_TDS
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_TDS) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_tds_tcp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_TDS,
+ ndpi_search_tds_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_TDS);
-
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_direct_download_link_tcp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask = NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD;
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK,
+ ndpi_search_direct_download_link_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask,
- NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
- NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK);
-
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_NETBIOS
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_NETBIOS) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_netbios;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_NETBIOS,
+ ndpi_search_netbios,
+ NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_NETBIOS);
-
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_MDNS
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_MDNS) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_mdns;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask = NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD;
-
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_MDNS);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_MDNS,
+ ndpi_search_mdns,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_IPP
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_IPP) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_ipp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_IPP);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_IPP,
+ ndpi_search_ipp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_LDAP
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_LDAP) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_ldap;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_LDAP);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_LDAP,
+ ndpi_search_ldap,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_WARCRAFT3
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_WARCRAFT3) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_warcraft3;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD;
-
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_WARCRAFT3);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_WARCRAFT3,
+ ndpi_search_warcraft3,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_WARCRAFT3);
-
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_XDMCP
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_XDMCP) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_xdmcp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD;
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_XDMCP,
+ ndpi_search_xdmcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_XDMCP);
-
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_XDMCP);
-
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
-#ifdef NDPI_PROTOCOL_TFTP
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_TFTP) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_tftp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask = NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD;
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
+#ifdef NDPI_PROTOCOL_TFTP
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_TFTP,
+ ndpi_search_tftp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_TFTP);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_MSSQL
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_MSSQL) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_mssql;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_MSSQL,
+ ndpi_search_mssql,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_MSSQL);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
-#ifdef NDPI_PROTOCOL_PPTP
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_PPTP) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_pptp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
+#ifdef NDPI_PROTOCOL_PPTP
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_PPTP,
+ ndpi_search_pptp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_PPTP);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_STEALTHNET
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_STEALTHNET) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_stealthnet;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_STEALTHNET,
+ ndpi_search_stealthnet,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_STEALTHNET);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_DHCPV6
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_DHCPV6) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_dhcpv6_udp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask = NDPI_SELECTION_BITMASK_PROTOCOL_V6_UDP_WITH_PAYLOAD;
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_DHCPV6,
+ ndpi_search_dhcpv6_udp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V6_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_DHCPV6);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_MEEBO
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_MEEBO) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_meebo;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_MEEBO,
+ ndpi_search_meebo,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+ /* Add protocol bitmask dependencies to detected bitmask*/
#ifdef NDPI_PROTOCOL_FLASH
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_FLASH);
+ NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_FLASH);
#endif
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_MEEBO);
- a++;
- }
+ a++;
#endif
#ifdef NDPI_PROTOCOL_AFP
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_AFP) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_afp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_AFP,
+ ndpi_search_afp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_AFP);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_AIMINI
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_AIMINI) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_aimini;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD;
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_AIMINI,
+ ndpi_search_aimini,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_AIMINI);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_FLORENSIA
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_FLORENSIA) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_florensia;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_FLORENSIA,
+ ndpi_search_florensia,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_FLORENSIA);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_MAPLESTORY
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_MAPLESTORY) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_maplestory;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_MAPLESTORY,
+ ndpi_search_maplestory,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_MAPLESTORY);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_DOFUS
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_DOFUS) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_dofus;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_DOFUS,
+ ndpi_search_dofus,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_DOFUS);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_WORLD_OF_KUNG_FU
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_WORLD_OF_KUNG_FU) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_world_of_kung_fu;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask,
- NDPI_PROTOCOL_WORLD_OF_KUNG_FU);
- a++;
- }
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_WORLD_OF_KUNG_FU,
+ ndpi_search_world_of_kung_fu,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_FIESTA
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_FIESTA) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_fiesta;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_FIESTA,
+ ndpi_search_fiesta,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_FIESTA);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_CROSSFIRE
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_CROSSFIRE) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_crossfire_tcp_udp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_CROSSFIRE,
+ ndpi_search_crossfire_tcp_udp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_CROSSFIRE);
-
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_GUILDWARS
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_GUILDWARS) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_guildwars_tcp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_GUILDWARS,
+ ndpi_search_guildwars_tcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_GUILDWARS);
-
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_ARMAGETRON
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_ARMAGETRON) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_armagetron_udp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask = NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD;
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_ARMAGETRON,
+ ndpi_search_armagetron_udp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_ARMAGETRON);
-
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
-
#ifdef NDPI_PROTOCOL_DROPBOX
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_DROPBOX) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_dropbox;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_DROPBOX);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_DROPBOX,
+ ndpi_search_dropbox,
+ NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_DROPBOX);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_SPOTIFY
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_SPOTIFY) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_spotify;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP_WITH_PAYLOAD;
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_SPOTIFY,
+ ndpi_search_spotify,
+ NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_SPOTIFY);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_SPOTIFY);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_SKYPE
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_SKYPE) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_skype;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP_WITH_PAYLOAD;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_SKYPE);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_SKYPE,
+ ndpi_search_skype,
+ NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_SKYPE);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_RADIUS
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_RADIUS) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_radius;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD;
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_RADIUS,
+ ndpi_search_radius,
+ NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_RADIUS);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_RADIUS);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_CITRIX
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_CITRIX) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_citrix;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_CITRIX);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_CITRIX);
- a++;
- }
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_CITRIX,
+ ndpi_search_citrix,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_LOTUS_NOTES
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_LOTUS_NOTES) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_lotus_notes;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_LOTUS_NOTES);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_LOTUS_NOTES);
- a++;
- }
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_LOTUS_NOTES,
+ ndpi_search_lotus_notes,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_GTP
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_GTP) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_gtp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_GTP);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_GTP);
- a++;
- }
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_GTP,
+ ndpi_search_gtp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_DCERPC
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_DCERPC) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_dcerpc;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_DCERPC);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_DCERPC);
- a++;
- }
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_DCERPC,
+ ndpi_search_dcerpc,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_NETFLOW
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_NETFLOW) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_netflow;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_NETFLOW);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_NETFLOW);
- a++;
- }
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_NETFLOW,
+ ndpi_search_netflow,
+ NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_SFLOW
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_SFLOW) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_sflow;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_SFLOW);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_SFLOW);
- a++;
- }
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_SFLOW,
+ ndpi_search_sflow,
+ NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
+
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_H323
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_H323) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_h323;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP_WITH_PAYLOAD;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_H323);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_H323,
+ ndpi_search_h323,
+ NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_H323);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_OPENVPN
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_OPENVPN) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_openvpn;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP_WITH_PAYLOAD;
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_OPENVPN,
+ ndpi_search_openvpn,
+ NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_OPENVPN);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_OPENVPN);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_NOE
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_NOE) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_noe;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP_WITH_PAYLOAD;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_NOE);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_NOE,
+ ndpi_search_noe,
+ NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_NOE);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_CISCOVPN
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_CISCOVPN) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_ciscovpn;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP_WITH_PAYLOAD;
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_CISCOVPN,
+ ndpi_search_ciscovpn,
+ NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_CISCOVPN);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_CISCOVPN);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_TEAMSPEAK
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_TEAMSPEAK) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_teamspeak;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP_WITH_PAYLOAD;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_TEAMSPEAK);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_TEAMSPEAK,
+ ndpi_search_teamspeak,
+ NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_TEAMSPEAK);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_VIBER
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_VIBER) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_viber;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD;
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_VIBER,
+ ndpi_search_viber,
+ NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_VIBER);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_VIBER);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_TOR
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_TOR) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_tor;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_TOR);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_TOR,
+ ndpi_search_tor,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_TOR);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_SKINNY
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_SKINNY) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_skinny;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_SKINNY,
+ ndpi_search_skinny,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_SKINNY);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_SKINNY);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_RTCP
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_RTCP) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_rtcp;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_RTCP);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_RTCP,
+ ndpi_search_rtcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_RTCP);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_RSYNC
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_RSYNC) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_rsync;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_RSYNC,
+ ndpi_search_rsync,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_RSYNC);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_RSYNC);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_WHOIS_DAS
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_WHOIS_DAS) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_whois_das;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_WHOIS_DAS);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_WHOIS_DAS,
+ ndpi_search_whois_das,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_WHOIS_DAS);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_ORACLE
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_ORACLE) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_oracle;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_ORACLE,
+ ndpi_search_oracle,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_ORACLE);
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_ORACLE);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
#ifdef NDPI_PROTOCOL_CORBA
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(*detection_bitmask, NDPI_PROTOCOL_CORBA) != 0) {
- ndpi_struct->callback_buffer[a].func = ndpi_search_corba;
- ndpi_struct->callback_buffer[a].ndpi_selection_bitmask =
- NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION;
-
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_UNKNOWN);
- NDPI_ADD_PROTOCOL_TO_BITMASK(ndpi_struct->callback_buffer[a].detection_bitmask, NDPI_PROTOCOL_CORBA);
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_CORBA,
+ ndpi_search_corba,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
- NDPI_SAVE_AS_BITMASK(ndpi_struct->callback_buffer[a].excluded_protocol_bitmask, NDPI_PROTOCOL_CORBA);
- a++;
- }
+ /* Update callback_buffer index */
+ a++;
#endif
+#ifdef NDPI_PROTOCOL_COLLECTD
+ ndpi_set_bitmask_protocol_detection(ndpi_struct,detection_bitmask,a,
+ NDPI_PROTOCOL_COLLECTD,
+ ndpi_search_collectd,
+ NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOW,
+ ADD_TO_DETECTION_BITMASK);
-
-
-
-
-
-
-
-
-
-
+ /* Update callback_buffer index */
+ a++;
+#endif
ndpi_struct->callback_buffer_size = a;
@@ -3409,10 +3394,10 @@
ndpi_struct->callback_buffer_size_tcp_payload = 0;
ndpi_struct->callback_buffer_size_tcp_no_payload = 0;
for (a = 0; a < ndpi_struct->callback_buffer_size; a++) {
- if ((ndpi_struct->callback_buffer[a].ndpi_selection_bitmask & (NDPI_SELECTION_BITMASK_PROTOCOL_INT_TCP |
- NDPI_SELECTION_BITMASK_PROTOCOL_INT_TCP_OR_UDP |
- NDPI_SELECTION_BITMASK_PROTOCOL_COMPLETE_TRAFFIC))
- != 0) {
+ if((ndpi_struct->callback_buffer[a].ndpi_selection_bitmask
+ & (NDPI_SELECTION_BITMASK_PROTOCOL_INT_TCP |
+ NDPI_SELECTION_BITMASK_PROTOCOL_INT_TCP_OR_UDP |
+ NDPI_SELECTION_BITMASK_PROTOCOL_COMPLETE_TRAFFIC)) != 0) {
NDPI_LOG(NDPI_PROTOCOL_UNKNOWN, ndpi_struct, NDPI_LOG_DEBUG,
"callback_buffer_tcp_payload, adding buffer %u as entry %u\n", a,
ndpi_struct->callback_buffer_size_tcp_payload);
@@ -3421,8 +3406,8 @@
&ndpi_struct->callback_buffer[a], sizeof(struct ndpi_call_function_struct));
ndpi_struct->callback_buffer_size_tcp_payload++;
- if ((ndpi_struct->
- callback_buffer[a].ndpi_selection_bitmask & NDPI_SELECTION_BITMASK_PROTOCOL_HAS_PAYLOAD) == 0) {
+ if((ndpi_struct->
+ callback_buffer[a].ndpi_selection_bitmask & NDPI_SELECTION_BITMASK_PROTOCOL_HAS_PAYLOAD) == 0) {
NDPI_LOG(NDPI_PROTOCOL_UNKNOWN, ndpi_struct, NDPI_LOG_DEBUG,
"callback_buffer_tcp_no_payload, additional adding buffer %u to no_payload process\n", a);
@@ -3436,10 +3421,10 @@
ndpi_struct->callback_buffer_size_udp = 0;
for (a = 0; a < ndpi_struct->callback_buffer_size; a++) {
- if ((ndpi_struct->callback_buffer[a].ndpi_selection_bitmask & (NDPI_SELECTION_BITMASK_PROTOCOL_INT_UDP |
- NDPI_SELECTION_BITMASK_PROTOCOL_INT_TCP_OR_UDP |
- NDPI_SELECTION_BITMASK_PROTOCOL_COMPLETE_TRAFFIC))
- != 0) {
+ if((ndpi_struct->callback_buffer[a].ndpi_selection_bitmask & (NDPI_SELECTION_BITMASK_PROTOCOL_INT_UDP |
+ NDPI_SELECTION_BITMASK_PROTOCOL_INT_TCP_OR_UDP |
+ NDPI_SELECTION_BITMASK_PROTOCOL_COMPLETE_TRAFFIC))
+ != 0) {
NDPI_LOG(NDPI_PROTOCOL_UNKNOWN, ndpi_struct, NDPI_LOG_DEBUG,
"callback_buffer_size_udp, adding buffer %u\n", a);
@@ -3451,12 +3436,12 @@
ndpi_struct->callback_buffer_size_non_tcp_udp = 0;
for (a = 0; a < ndpi_struct->callback_buffer_size; a++) {
- if ((ndpi_struct->callback_buffer[a].ndpi_selection_bitmask & (NDPI_SELECTION_BITMASK_PROTOCOL_INT_TCP |
- NDPI_SELECTION_BITMASK_PROTOCOL_INT_UDP |
- NDPI_SELECTION_BITMASK_PROTOCOL_INT_TCP_OR_UDP))
- == 0
- || (ndpi_struct->
- callback_buffer[a].ndpi_selection_bitmask & NDPI_SELECTION_BITMASK_PROTOCOL_COMPLETE_TRAFFIC) != 0) {
+ if((ndpi_struct->callback_buffer[a].ndpi_selection_bitmask & (NDPI_SELECTION_BITMASK_PROTOCOL_INT_TCP |
+ NDPI_SELECTION_BITMASK_PROTOCOL_INT_UDP |
+ NDPI_SELECTION_BITMASK_PROTOCOL_INT_TCP_OR_UDP))
+ == 0
+ || (ndpi_struct->
+ callback_buffer[a].ndpi_selection_bitmask & NDPI_SELECTION_BITMASK_PROTOCOL_COMPLETE_TRAFFIC) != 0) {
NDPI_LOG(NDPI_PROTOCOL_UNKNOWN, ndpi_struct, NDPI_LOG_DEBUG,
"callback_buffer_size_non_tcp_udp, adding buffer %u\n", a);
@@ -3486,12 +3471,12 @@
u_int16_t ehdr_len;
// no next header
- if (*nxt_hdr == 59) {
+ if(*nxt_hdr == 59) {
return 1;
}
// fragment extension header has fixed size of 8 bytes and the first byte is the next header type
- if (*nxt_hdr == 44) {
- if (*l4len < 8) {
+ if(*nxt_hdr == 44) {
+ if(*l4len < 8) {
return 1;
}
*nxt_hdr = (*l4ptr)[0];
@@ -3505,7 +3490,7 @@
ehdr_len *= 8;
ehdr_len += 8;
- if (*l4len < ehdr_len) {
+ if(*l4len < ehdr_len) {
return 1;
}
*nxt_hdr = (*l4ptr)[0];
@@ -3520,8 +3505,8 @@
static u_int8_t ndpi_iph_is_valid_and_not_fragmented(const struct ndpi_iphdr *iph, const u_int16_t ipsize)
{
//#ifdef REQUIRE_FULL_PACKETS
- if (ipsize < iph->ihl * 4 ||
- ipsize < ntohs(iph->tot_len) || ntohs(iph->tot_len) < iph->ihl * 4 || (iph->frag_off & htons(0x1FFF)) != 0) {
+ if(ipsize < iph->ihl * 4 ||
+ ipsize < ntohs(iph->tot_len) || ntohs(iph->tot_len) < iph->ihl * 4 || (iph->frag_off & htons(0x1FFF)) != 0) {
return 0;
}
//#endif
@@ -3541,16 +3526,16 @@
const u_int8_t *l4ptr = NULL;
u_int8_t l4protocol = 0;
- if (l3 == NULL || l3_len < sizeof(struct ndpi_iphdr))
+ if(l3 == NULL || l3_len < sizeof(struct ndpi_iphdr))
return 1;
iph = (const struct ndpi_iphdr *) l3;
- if (iph->version == 4 && iph->ihl >= 5) {
+ if(iph->version == 4 && iph->ihl >= 5) {
NDPI_LOG(NDPI_PROTOCOL_UNKNOWN, ndpi_struct, NDPI_LOG_DEBUG, "ipv4 header\n");
}
#ifdef NDPI_DETECTION_SUPPORT_IPV6
- else if (iph->version == 6 && l3_len >= sizeof(struct ndpi_ipv6hdr)) {
+ else if(iph->version == 6 && l3_len >= sizeof(struct ndpi_ipv6hdr)) {
NDPI_LOG(NDPI_PROTOCOL_UNKNOWN, ndpi_struct, NDPI_LOG_DEBUG, "ipv6 header\n");
iph_v6 = (const struct ndpi_ipv6hdr *) iph;
iph = NULL;
@@ -3560,18 +3545,18 @@
return 1;
}
- if ((flags & NDPI_DETECTION_ONLY_IPV6) && iph != NULL) {
+ if((flags & NDPI_DETECTION_ONLY_IPV6) && iph != NULL) {
NDPI_LOG(NDPI_PROTOCOL_UNKNOWN, ndpi_struct, NDPI_LOG_DEBUG, "ipv4 header found but excluded by flag\n");
return 1;
}
#ifdef NDPI_DETECTION_SUPPORT_IPV6
- else if ((flags & NDPI_DETECTION_ONLY_IPV4) && iph_v6 != NULL) {
+ else if((flags & NDPI_DETECTION_ONLY_IPV4) && iph_v6 != NULL) {
NDPI_LOG(NDPI_PROTOCOL_UNKNOWN, ndpi_struct, NDPI_LOG_DEBUG, "ipv6 header found but excluded by flag\n");
return 1;
}
#endif
- if (iph != NULL && ndpi_iph_is_valid_and_not_fragmented(iph, l3_len)) {
+ if(iph != NULL && ndpi_iph_is_valid_and_not_fragmented(iph, l3_len)) {
u_int16_t len = ntohs(iph->tot_len);
u_int16_t hlen = (iph->ihl * 4);
@@ -3583,13 +3568,13 @@
l4protocol = iph->protocol;
}
#ifdef NDPI_DETECTION_SUPPORT_IPV6
- else if (iph_v6 != NULL && (l3_len - sizeof(struct ndpi_ipv6hdr)) >= ntohs(iph_v6->payload_len)) {
+ else if(iph_v6 != NULL && (l3_len - sizeof(struct ndpi_ipv6hdr)) >= ntohs(iph_v6->payload_len)) {
l4ptr = (((const u_int8_t *) iph_v6) + sizeof(struct ndpi_ipv6hdr));
l4len = ntohs(iph_v6->payload_len);
l4protocol = iph_v6->nexthdr;
// we need to handle IPv6 extension headers if present
- if (ndpi_handle_ipv6_extension_headers(ndpi_struct, &l4ptr, &l4len, &l4protocol) != 0) {
+ if(ndpi_handle_ipv6_extension_headers(ndpi_struct, &l4ptr, &l4len, &l4protocol) != 0) {
return 1;
}
@@ -3599,15 +3584,15 @@
return 1;
}
- if (l4_return != NULL) {
+ if(l4_return != NULL) {
*l4_return = l4ptr;
}
- if (l4_len_return != NULL) {
+ if(l4_len_return != NULL) {
*l4_len_return = l4len;
}
- if (l4_protocol_return != NULL) {
+ if(l4_protocol_return != NULL) {
*l4_protocol_return = l4protocol;
}
@@ -3652,7 +3637,7 @@
flow->packet.iphv6 = NULL;
#endif /* NDPI_DETECTION_SUPPORT_IPV6 */
- if (flow) {
+ if(flow) {
ndpi_apply_flow_protocol_to_packet(flow, &flow->packet);
} else {
ndpi_int_reset_packet_protocol(&flow->packet);
@@ -3661,7 +3646,7 @@
l3len =flow->packet.l3_packet_len;
#ifdef NDPI_DETECTION_SUPPORT_IPV6
- if (flow->packet.iph != NULL) {
+ if(flow->packet.iph != NULL) {
#endif /* NDPI_DETECTION_SUPPORT_IPV6 */
decaps_iph =flow->packet.iph;
@@ -3670,12 +3655,12 @@
}
#endif /* NDPI_DETECTION_SUPPORT_IPV6 */
- if (decaps_iph->version == 4 && decaps_iph->ihl >= 5) {
+ if(decaps_iph->version == 4 && decaps_iph->ihl >= 5) {
NDPI_LOG(NDPI_PROTOCOL_UNKNOWN, ndpi_struct, NDPI_LOG_DEBUG, "ipv4 header\n");
}
#ifdef NDPI_DETECTION_SUPPORT_IPV6
- else if (decaps_iph->version == 6 && l3len >= sizeof(struct ndpi_ipv6hdr) &&
- (ndpi_struct->ip_version_limit & NDPI_DETECTION_ONLY_IPV4) == 0) {
+ else if(decaps_iph->version == 6 && l3len >= sizeof(struct ndpi_ipv6hdr) &&
+ (ndpi_struct->ip_version_limit & NDPI_DETECTION_ONLY_IPV4) == 0) {
NDPI_LOG(NDPI_PROTOCOL_UNKNOWN, ndpi_struct, NDPI_LOG_DEBUG, "ipv6 header\n");
flow->packet.iphv6 = (struct ndpi_ipv6hdr *)flow->packet.iph;
flow->packet.iph = NULL;
@@ -3701,7 +3686,7 @@
l4_result =
ndpi_detection_get_l4_internal(ndpi_struct, (const u_int8_t *) decaps_iph, l3len, &l4ptr, &l4len, &l4protocol, 0);
- if (l4_result != 0) {
+ if(l4_result != 0) {
return 1;
}
@@ -3709,11 +3694,11 @@
flow->packet.l4_packet_len = l4len;
/* tcp / udp detection */
- if (l4protocol == 6 /* TCP */ &&flow->packet.l4_packet_len >= 20 /* min size of tcp */ ) {
+ if(l4protocol == 6 /* TCP */ &&flow->packet.l4_packet_len >= 20 /* min size of tcp */ ) {
/* tcp */
flow->packet.tcp = (struct ndpi_tcphdr *) l4ptr;
- if (flow->packet.l4_packet_len >=flow->packet.tcp->doff * 4) {
+ if(flow->packet.l4_packet_len >=flow->packet.tcp->doff * 4) {
flow->packet.payload_packet_len =
flow->packet.l4_packet_len -flow->packet.tcp->doff * 4;
flow->packet.actual_payload_len =flow->packet.payload_packet_len;
@@ -3722,10 +3707,10 @@
/* check for new tcp syn packets, here
* idea: reset detection state if a connection is unknown
*/
- if (flow && flow->packet.tcp->syn != 0
- && flow->packet.tcp->ack == 0
- && flow->init_finished != 0
- && flow->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN) {
+ if(flow && flow->packet.tcp->syn != 0
+ && flow->packet.tcp->ack == 0
+ && flow->init_finished != 0
+ && flow->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN) {
memset(flow, 0, sizeof(*(flow)));
@@ -3739,7 +3724,7 @@
/* tcp header not complete */
flow->packet.tcp = NULL;
}
- } else if (l4protocol == 17 /* udp */ &&flow->packet.l4_packet_len >= 8 /* size of udp */ ) {
+ } else if(l4protocol == 17 /* udp */ &&flow->packet.l4_packet_len >= 8 /* size of udp */ ) {
flow->packet.udp = (struct ndpi_udphdr *) l4ptr;
flow->packet.payload_packet_len =flow->packet.l4_packet_len - 8;
flow->packet.payload = ((u_int8_t *)flow->packet.udp) + 8;
@@ -3777,42 +3762,42 @@
packet->packet_direction = 0;
- if (iph != NULL && iph->saddr < iph->daddr)
+ if(iph != NULL && iph->saddr < iph->daddr)
packet->packet_direction = 1;
#ifdef NDPI_DETECTION_SUPPORT_IPV6
- if (iphv6 != NULL && NDPI_COMPARE_IPV6_ADDRESS_STRUCTS(&iphv6->saddr, &iphv6->daddr) != 0)
+ if(iphv6 != NULL && NDPI_COMPARE_IPV6_ADDRESS_STRUCTS(&iphv6->saddr, &iphv6->daddr) != 0)
packet->packet_direction = 1;
#endif
packet->packet_lines_parsed_complete = 0;
packet->packet_unix_lines_parsed_complete = 0;
- if (flow == NULL)
+ if(flow == NULL)
return;
- if (flow->init_finished == 0) {
+ if(flow->init_finished == 0) {
flow->init_finished = 1;
flow->setup_packet_direction = packet->packet_direction;
}
- if (tcph != NULL) {
+ if(tcph != NULL) {
/* reset retried bytes here before setting it */
packet->num_retried_bytes = 0;
- if (tcph->syn != 0 && tcph->ack == 0 && flow->l4.tcp.seen_syn == 0 && flow->l4.tcp.seen_syn_ack == 0
- && flow->l4.tcp.seen_ack == 0) {
+ if(tcph->syn != 0 && tcph->ack == 0 && flow->l4.tcp.seen_syn == 0 && flow->l4.tcp.seen_syn_ack == 0
+ && flow->l4.tcp.seen_ack == 0) {
flow->l4.tcp.seen_syn = 1;
}
- if (tcph->syn != 0 && tcph->ack != 0 && flow->l4.tcp.seen_syn == 1 && flow->l4.tcp.seen_syn_ack == 0
- && flow->l4.tcp.seen_ack == 0) {
+ if(tcph->syn != 0 && tcph->ack != 0 && flow->l4.tcp.seen_syn == 1 && flow->l4.tcp.seen_syn_ack == 0
+ && flow->l4.tcp.seen_ack == 0) {
flow->l4.tcp.seen_syn_ack = 1;
}
- if (tcph->syn == 0 && tcph->ack == 1 && flow->l4.tcp.seen_syn == 1 && flow->l4.tcp.seen_syn_ack == 1
- && flow->l4.tcp.seen_ack == 0) {
+ if(tcph->syn == 0 && tcph->ack == 1 && flow->l4.tcp.seen_syn == 1 && flow->l4.tcp.seen_syn_ack == 1
+ && flow->l4.tcp.seen_ack == 0) {
flow->l4.tcp.seen_ack = 1;
}
- if ((flow->next_tcp_seq_nr[0] == 0 && flow->next_tcp_seq_nr[1] == 0)
- || (proxy_enabled && (flow->next_tcp_seq_nr[0] == 0 || flow->next_tcp_seq_nr[1] == 0))) {
+ if((flow->next_tcp_seq_nr[0] == 0 && flow->next_tcp_seq_nr[1] == 0)
+ || (proxy_enabled && (flow->next_tcp_seq_nr[0] == 0 || flow->next_tcp_seq_nr[1] == 0))) {
/* initalize tcp sequence counters */
/* the ack flag needs to be set to get valid sequence numbers from the other
* direction. Usually it will catch the second packet syn+ack but it works
@@ -3821,25 +3806,25 @@
* if the syn flag is set add one to the sequence number,
* otherwise use the payload length.
*/
- if (tcph->ack != 0) {
+ if(tcph->ack != 0) {
flow->next_tcp_seq_nr[flow->packet.packet_direction] =
ntohl(tcph->seq) + (tcph->syn ? 1 : packet->payload_packet_len);
- if (!proxy_enabled) {
+ if(!proxy_enabled) {
flow->next_tcp_seq_nr[1 -flow->packet.packet_direction] = ntohl(tcph->ack_seq);
}
}
- } else if (packet->payload_packet_len > 0) {
+ } else if(packet->payload_packet_len > 0) {
/* check tcp sequence counters */
- if (((u_int32_t)
- (ntohl(tcph->seq) -
- flow->next_tcp_seq_nr[packet->packet_direction])) >
- ndpi_struct->tcp_max_retransmission_window_size) {
+ if(((u_int32_t)
+ (ntohl(tcph->seq) -
+ flow->next_tcp_seq_nr[packet->packet_direction])) >
+ ndpi_struct->tcp_max_retransmission_window_size) {
packet->tcp_retransmission = 1;
/*CHECK IF PARTIAL RETRY IS HAPPENENING */
- if ((flow->next_tcp_seq_nr[packet->packet_direction] - ntohl(tcph->seq) < packet->payload_packet_len)) {
+ if((flow->next_tcp_seq_nr[packet->packet_direction] - ntohl(tcph->seq) < packet->payload_packet_len)) {
/* num_retried_bytes actual_payload_len hold info about the partial retry
analyzer which require this info can make use of this info
Other analyzer can use packet->payload_packet_len */
@@ -3861,22 +3846,22 @@
}
- if (tcph->rst) {
+ if(tcph->rst) {
flow->next_tcp_seq_nr[0] = 0;
flow->next_tcp_seq_nr[1] = 0;
}
}
- if (flow->packet_counter < MAX_PACKET_COUNTER && packet->payload_packet_len) {
+ if(flow->packet_counter < MAX_PACKET_COUNTER && packet->payload_packet_len) {
flow->packet_counter++;
}
- if (flow->packet_direction_counter[packet->packet_direction] < MAX_PACKET_COUNTER && packet->payload_packet_len) {
+ if(flow->packet_direction_counter[packet->packet_direction] < MAX_PACKET_COUNTER && packet->payload_packet_len) {
flow->packet_direction_counter[packet->packet_direction]++;
}
- if (flow->byte_counter[packet->packet_direction] + packet->payload_packet_len >
- flow->byte_counter[packet->packet_direction]) {
+ if(flow->byte_counter[packet->packet_direction] + packet->payload_packet_len >
+ flow->byte_counter[packet->packet_direction]) {
flow->byte_counter[packet->packet_direction] += packet->payload_packet_len;
}
}
@@ -3892,91 +3877,145 @@
u_int32_t a;
NDPI_SELECTION_BITMASK_PROTOCOL_SIZE ndpi_selection_packet;
NDPI_PROTOCOL_BITMASK detection_bitmask;
+ void *func = NULL;
+ u_int16_t proto_index;
+
+ if(flow == NULL)
+ return NDPI_PROTOCOL_UNKNOWN;
+
+ if(flow->detected_protocol_stack[0] != NDPI_PROTOCOL_UNKNOWN)
+ return(flow->detected_protocol_stack[0]); /* Stop after detecting the first protocol */
/* need at least 20 bytes for ip header */
- if (packetlen < 20) {
+ if(packetlen < 20) {
/* reset protocol which is normally done in init_packet_header */
ndpi_int_reset_packet_protocol(&flow->packet);
return NDPI_PROTOCOL_UNKNOWN;
}
+
flow->packet.tick_timestamp = current_tick;
/* parse packet */
flow->packet.iph = (struct ndpi_iphdr *) packet;
/* we are interested in ipv4 packet */
- if (ndpi_init_packet_header(ndpi_struct, flow, packetlen) != 0) {
+ if(ndpi_init_packet_header(ndpi_struct, flow, packetlen) != 0)
return NDPI_PROTOCOL_UNKNOWN;
- }
+
/* detect traffic for tcp or udp only */
flow->src = src, flow->dst = dst;
ndpi_connection_tracking(ndpi_struct, flow);
- if (flow == NULL && (flow->packet.tcp != NULL || flow->packet.udp != NULL)) {
+ if(flow == NULL && (flow->packet.tcp != NULL || flow->packet.udp != NULL)) {
return (NDPI_PROTOCOL_UNKNOWN);
}
/* build ndpi_selction packet bitmask */
ndpi_selection_packet = NDPI_SELECTION_BITMASK_PROTOCOL_COMPLETE_TRAFFIC;
- if (flow->packet.iph != NULL) {
+ if(flow->packet.iph != NULL) {
ndpi_selection_packet |= NDPI_SELECTION_BITMASK_PROTOCOL_IP | NDPI_SELECTION_BITMASK_PROTOCOL_IPV4_OR_IPV6;
-
}
- if (flow->packet.tcp != NULL) {
+ if(flow->packet.tcp != NULL) {
ndpi_selection_packet |=
(NDPI_SELECTION_BITMASK_PROTOCOL_INT_TCP | NDPI_SELECTION_BITMASK_PROTOCOL_INT_TCP_OR_UDP);
-
}
- if (flow->packet.udp != NULL) {
+ if(flow->packet.udp != NULL) {
ndpi_selection_packet |=
(NDPI_SELECTION_BITMASK_PROTOCOL_INT_UDP | NDPI_SELECTION_BITMASK_PROTOCOL_INT_TCP_OR_UDP);
}
- if (flow->packet.payload_packet_len != 0) {
+ if(flow->packet.payload_packet_len != 0) {
ndpi_selection_packet |= NDPI_SELECTION_BITMASK_PROTOCOL_HAS_PAYLOAD;
}
- if (flow->packet.tcp_retransmission == 0) {
+ if(flow->packet.tcp_retransmission == 0) {
ndpi_selection_packet |= NDPI_SELECTION_BITMASK_PROTOCOL_NO_TCP_RETRANSMISSION;
-
}
#ifdef NDPI_DETECTION_SUPPORT_IPV6
- if (flow->packet.iphv6 != NULL) {
+ if(flow->packet.iphv6 != NULL) {
ndpi_selection_packet |= NDPI_SELECTION_BITMASK_PROTOCOL_IPV6 | NDPI_SELECTION_BITMASK_PROTOCOL_IPV4_OR_IPV6;
-
}
#endif /* NDPI_DETECTION_SUPPORT_IPV6 */
-
NDPI_SAVE_AS_BITMASK(detection_bitmask, flow->packet.detected_protocol_stack[0]);
- if (flow != NULL && flow->packet.tcp != NULL) {
- if (flow->packet.payload_packet_len != 0) {
- for (a = 0; a < ndpi_struct->callback_buffer_size_tcp_payload; a++) {
- if ((ndpi_struct->callback_buffer_tcp_payload[a].ndpi_selection_bitmask & ndpi_selection_packet) ==
- ndpi_struct->callback_buffer_tcp_payload[a].ndpi_selection_bitmask
- && NDPI_BITMASK_COMPARE(flow->excluded_protocol_bitmask,
- ndpi_struct->callback_buffer_tcp_payload[a].excluded_protocol_bitmask) == 0
- && NDPI_BITMASK_COMPARE(ndpi_struct->callback_buffer_tcp_payload[a].detection_bitmask,
- detection_bitmask) != 0) {
- ndpi_struct->callback_buffer_tcp_payload[a].func(ndpi_struct, flow);
+ if((!flow->protocol_id_already_guessed)
+ && (flow->packet.iphv6 || flow->packet.iph)) {
+ u_int16_t sport, dport;
+ u_int8_t protocol;
+ u_int32_t saddr, daddr;
- if(flow->detected_protocol_stack[0] != NDPI_PROTOCOL_UNKNOWN)
- break; /* Stop after detecting the first protocol */
+ if(flow->packet.iphv6 != NULL) {
+ protocol = flow->packet.iphv6->nexthdr, saddr = 0, daddr = 0;
+ } else {
+ protocol = flow->packet.iph->protocol;
+ saddr = ntohl(flow->packet.iph->saddr);
+ daddr = ntohl(flow->packet.iph->daddr);
+ }
+
+ if(flow->packet.udp) sport = ntohs(flow->packet.udp->source), dport = ntohs(flow->packet.udp->dest);
+ else if(flow->packet.tcp) sport = ntohs(flow->packet.tcp->source), dport = ntohs(flow->packet.tcp->dest);
+ else sport = dport = 0;
+
+ flow->guessed_protocol_id = (int16_t)ndpi_guess_protocol_id(ndpi_struct, protocol,
+ saddr, sport, daddr, dport);
+ flow->protocol_id_already_guessed = 1;
+ }
+
+ proto_index = ndpi_struct->proto_defaults[flow->guessed_protocol_id].protoId;
+
+ if(flow->packet.tcp != NULL) {
+ if(flow->packet.payload_packet_len != 0) {
+ if((proto_index != NDPI_PROTOCOL_UNKNOWN)
+ && NDPI_BITMASK_COMPARE(flow->excluded_protocol_bitmask,
+ ndpi_struct->callback_buffer_tcp_payload[proto_index].excluded_protocol_bitmask) == 0
+ && NDPI_BITMASK_COMPARE(ndpi_struct->callback_buffer_tcp_payload[proto_index].detection_bitmask,
+ detection_bitmask) != 0) {
+ if((flow->guessed_protocol_id != NDPI_PROTOCOL_UNKNOWN)
+ && (ndpi_struct->proto_defaults[flow->guessed_protocol_id].func != NULL))
+ ndpi_struct->proto_defaults[flow->guessed_protocol_id].func(ndpi_struct, flow),
+ func = ndpi_struct->proto_defaults[flow->guessed_protocol_id].func;
+ }
+
+ if(flow->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN) {
+ for (a = 0; a < ndpi_struct->callback_buffer_size_tcp_payload; a++) {
+ if((func != ndpi_struct->callback_buffer_tcp_payload[a].func)
+ && (ndpi_struct->callback_buffer_tcp_payload[a].ndpi_selection_bitmask
+ & ndpi_selection_packet) == ndpi_struct->callback_buffer_tcp_payload[a].ndpi_selection_bitmask
+ && NDPI_BITMASK_COMPARE(flow->excluded_protocol_bitmask,
+ ndpi_struct->callback_buffer_tcp_payload[a].excluded_protocol_bitmask) == 0
+ && NDPI_BITMASK_COMPARE(ndpi_struct->callback_buffer_tcp_payload[a].detection_bitmask,
+ detection_bitmask) != 0) {
+ ndpi_struct->callback_buffer_tcp_payload[a].func(ndpi_struct, flow);
+
+ if(flow->detected_protocol_stack[0] != NDPI_PROTOCOL_UNKNOWN)
+ break; /* Stop after detecting the first protocol */
+ }
}
}
} else { /* no payload */
+ if((proto_index != NDPI_PROTOCOL_UNKNOWN)
+ && NDPI_BITMASK_COMPARE(flow->excluded_protocol_bitmask,
+ ndpi_struct->callback_buffer_tcp_no_payload[proto_index].excluded_protocol_bitmask) == 0
+ && NDPI_BITMASK_COMPARE(ndpi_struct->callback_buffer_tcp_no_payload[proto_index].detection_bitmask,
+ detection_bitmask) != 0) {
+ if((flow->guessed_protocol_id != NDPI_PROTOCOL_UNKNOWN)
+ && (ndpi_struct->proto_defaults[flow->guessed_protocol_id].func != NULL))
+ ndpi_struct->proto_defaults[flow->guessed_protocol_id].func(ndpi_struct, flow),
+ func = ndpi_struct->proto_defaults[flow->guessed_protocol_id].func;
+ }
for (a = 0; a < ndpi_struct->callback_buffer_size_tcp_no_payload; a++) {
- if ((ndpi_struct->callback_buffer_tcp_no_payload[a].ndpi_selection_bitmask & ndpi_selection_packet) ==
- ndpi_struct->callback_buffer_tcp_no_payload[a].ndpi_selection_bitmask
- && NDPI_BITMASK_COMPARE(flow->excluded_protocol_bitmask,
- ndpi_struct->
- callback_buffer_tcp_no_payload[a].excluded_protocol_bitmask) == 0
- && NDPI_BITMASK_COMPARE(ndpi_struct->callback_buffer_tcp_no_payload[a].detection_bitmask,
- detection_bitmask) != 0) {
+ if((func != ndpi_struct->callback_buffer_tcp_payload[a].func)
+ && (ndpi_struct->callback_buffer_tcp_no_payload[a].ndpi_selection_bitmask & ndpi_selection_packet) ==
+ ndpi_struct->callback_buffer_tcp_no_payload[a].ndpi_selection_bitmask
+ && NDPI_BITMASK_COMPARE(flow->excluded_protocol_bitmask,
+ ndpi_struct->
+ callback_buffer_tcp_no_payload[a].excluded_protocol_bitmask) == 0
+ && NDPI_BITMASK_COMPARE(ndpi_struct->callback_buffer_tcp_no_payload[a].detection_bitmask,
+ detection_bitmask) != 0) {
ndpi_struct->callback_buffer_tcp_no_payload[a].func(ndpi_struct, flow);
if(flow->detected_protocol_stack[0] != NDPI_PROTOCOL_UNKNOWN)
@@ -3984,14 +4023,26 @@
}
}
}
- } else if (flow != NULL && flow->packet.udp != NULL) {
+ } else if(flow->packet.udp != NULL) {
+ if((proto_index != NDPI_PROTOCOL_UNKNOWN)
+ && NDPI_BITMASK_COMPARE(flow->excluded_protocol_bitmask,
+ ndpi_struct->callback_buffer_udp[proto_index].excluded_protocol_bitmask) == 0
+ && NDPI_BITMASK_COMPARE(ndpi_struct->callback_buffer_udp[proto_index].detection_bitmask,
+ detection_bitmask) != 0) {
+ if((flow->guessed_protocol_id != NDPI_PROTOCOL_UNKNOWN)
+ && (ndpi_struct->proto_defaults[flow->guessed_protocol_id].func != NULL))
+ ndpi_struct->proto_defaults[flow->guessed_protocol_id].func(ndpi_struct, flow),
+ func = ndpi_struct->proto_defaults[flow->guessed_protocol_id].func;
+ }
+
for (a = 0; a < ndpi_struct->callback_buffer_size_udp; a++) {
- if ((ndpi_struct->callback_buffer_udp[a].ndpi_selection_bitmask & ndpi_selection_packet) ==
- ndpi_struct->callback_buffer_udp[a].ndpi_selection_bitmask
- && NDPI_BITMASK_COMPARE(flow->excluded_protocol_bitmask,
- ndpi_struct->callback_buffer_udp[a].excluded_protocol_bitmask) == 0
- && NDPI_BITMASK_COMPARE(ndpi_struct->callback_buffer_udp[a].detection_bitmask,
- detection_bitmask) != 0) {
+ if((func != ndpi_struct->callback_buffer_tcp_payload[a].func)
+ && (ndpi_struct->callback_buffer_udp[a].ndpi_selection_bitmask & ndpi_selection_packet) ==
+ ndpi_struct->callback_buffer_udp[a].ndpi_selection_bitmask
+ && NDPI_BITMASK_COMPARE(flow->excluded_protocol_bitmask,
+ ndpi_struct->callback_buffer_udp[a].excluded_protocol_bitmask) == 0
+ && NDPI_BITMASK_COMPARE(ndpi_struct->callback_buffer_udp[a].detection_bitmask,
+ detection_bitmask) != 0) {
ndpi_struct->callback_buffer_udp[a].func(ndpi_struct, flow);
if(flow->detected_protocol_stack[0] != NDPI_PROTOCOL_UNKNOWN)
@@ -3999,17 +4050,28 @@
}
}
} else {
+ if((proto_index != NDPI_PROTOCOL_UNKNOWN)
+ && NDPI_BITMASK_COMPARE(flow->excluded_protocol_bitmask,
+ ndpi_struct->callback_buffer_non_tcp_udp[proto_index].excluded_protocol_bitmask) == 0
+ && NDPI_BITMASK_COMPARE(ndpi_struct->callback_buffer_non_tcp_udp[proto_index].detection_bitmask,
+ detection_bitmask) != 0) {
+ if((flow->guessed_protocol_id != NDPI_PROTOCOL_UNKNOWN)
+ && (ndpi_struct->proto_defaults[flow->guessed_protocol_id].func != NULL))
+ ndpi_struct->proto_defaults[flow->guessed_protocol_id].func(ndpi_struct, flow),
+ func = ndpi_struct->proto_defaults[flow->guessed_protocol_id].func;
+ }
for (a = 0; a < ndpi_struct->callback_buffer_size_non_tcp_udp; a++) {
- if ((ndpi_struct->callback_buffer_non_tcp_udp[a].ndpi_selection_bitmask & ndpi_selection_packet) ==
- ndpi_struct->callback_buffer_non_tcp_udp[a].ndpi_selection_bitmask
- && (flow == NULL
- ||
- NDPI_BITMASK_COMPARE
- (flow->excluded_protocol_bitmask,
- ndpi_struct->callback_buffer_non_tcp_udp[a].excluded_protocol_bitmask) == 0)
- && NDPI_BITMASK_COMPARE(ndpi_struct->callback_buffer_non_tcp_udp[a].detection_bitmask,
- detection_bitmask) != 0) {
+ if((func != ndpi_struct->callback_buffer_tcp_payload[a].func)
+ && (ndpi_struct->callback_buffer_non_tcp_udp[a].ndpi_selection_bitmask & ndpi_selection_packet) ==
+ ndpi_struct->callback_buffer_non_tcp_udp[a].ndpi_selection_bitmask
+ && (flow == NULL
+ ||
+ NDPI_BITMASK_COMPARE
+ (flow->excluded_protocol_bitmask,
+ ndpi_struct->callback_buffer_non_tcp_udp[a].excluded_protocol_bitmask) == 0)
+ && NDPI_BITMASK_COMPARE(ndpi_struct->callback_buffer_non_tcp_udp[a].detection_bitmask,
+ detection_bitmask) != 0) {
ndpi_struct->callback_buffer_non_tcp_udp[a].func(ndpi_struct, flow);
@@ -4020,38 +4082,50 @@
}
a = flow->packet.detected_protocol_stack[0];
- if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(ndpi_struct->detection_bitmask, a) == 0)
+ if(NDPI_COMPARE_PROTOCOL_TO_BITMASK(ndpi_struct->detection_bitmask, a) == 0)
a = NDPI_PROTOCOL_UNKNOWN;
+ if(a != NDPI_PROTOCOL_UNKNOWN) {
+ int i;
+
+ for(i=0; (i<sizeof(flow->host_server_name)) && (flow->host_server_name[i] != '\0'); i++)
+ flow->host_server_name[i] = tolower(flow->host_server_name[i]);
+
+ flow->host_server_name[i] ='\0';
+ }
+
return a;
}
static u_int8_t ndpi_detection_build_key_internal(struct ndpi_detection_module_struct *ndpi_struct,
- const u_int8_t * l3, u_int16_t l3_len, const u_int8_t * l4, u_int16_t l4_len, u_int8_t l4_protocol,
- struct ndpi_unique_flow_ipv4_and_6_struct *key_return, u_int8_t * dir_return,
+ const u_int8_t * l3, u_int16_t l3_len,
+ const u_int8_t * l4, u_int16_t l4_len,
+ u_int8_t l4_protocol,
+ struct ndpi_unique_flow_ipv4_and_6_struct *key_return,
+ u_int8_t * dir_return,
u_int32_t flags)
{
const struct ndpi_iphdr *iph = NULL;
u_int8_t swapped = 0;
- if (key_return == NULL || l3 == NULL)
+ if(key_return == NULL || l3 == NULL)
return 1;
- if (l3_len < sizeof(*iph))
+ if(l3_len < sizeof(*iph))
return 1;
iph = (const struct ndpi_iphdr *) l3;
- if (iph->version == 4 && ((iph->ihl * 4) > l3_len || l3_len < ntohs(iph->tot_len)
- || (iph->frag_off & htons(0x1FFF)) != 0)) {
+ if(iph->version == 4 && ((iph->ihl * 4) > l3_len || l3_len < ntohs(iph->tot_len)
+ || (iph->frag_off & htons(0x1FFF)) != 0)) {
return 1;
}
- if ((flags & NDPI_DETECTION_ONLY_IPV6) && iph->version == 4) {
+ if((flags & NDPI_DETECTION_ONLY_IPV6) && iph->version == 4) {
return 1;
}
#ifdef NDPI_DETECTION_SUPPORT_IPV6
- else if ((flags & NDPI_DETECTION_ONLY_IPV4) && iph->version == 6) {
+ else if((flags & NDPI_DETECTION_ONLY_IPV4) && iph->version == 6) {
return 1;
}
#endif
@@ -4064,13 +4138,13 @@
* - ip total length >= packet len
*/
- if (iph->version == 4 && iph->ihl >= 5) {
+ if(iph->version == 4 && iph->ihl >= 5) {
NDPI_LOG(NDPI_PROTOCOL_UNKNOWN, ndpi_struct, NDPI_LOG_DEBUG, "ipv4 header\n");
key_return->is_ip_v6 = 0;
key_return->protocol = l4_protocol;
- if (iph->saddr < iph->daddr) {
+ if(iph->saddr < iph->daddr) {
key_return->ip.ipv4.lower_ip = iph->saddr;
key_return->ip.ipv4.upper_ip = iph->daddr;
} else {
@@ -4085,17 +4159,17 @@
#ifdef NDPI_DETECTION_SUPPORT_IPV6
- } else if (iph->version == 6 && l3_len >= sizeof(struct ndpi_ipv6hdr)) {
+ } else if(iph->version == 6 && l3_len >= sizeof(struct ndpi_ipv6hdr)) {
const struct ndpi_ipv6hdr *ip6h = (const struct ndpi_ipv6hdr *) iph;
- if ((l3_len - sizeof(struct ndpi_ipv6hdr)) < ntohs(ip6h->payload_len)) {
+ if((l3_len - sizeof(struct ndpi_ipv6hdr)) < ntohs(ip6h->payload_len)) {
return 3;
}
key_return->is_ip_v6 = 1;
key_return->protocol = l4_protocol;
- if (NDPI_COMPARE_IPV6_ADDRESS_STRUCTS(&ip6h->saddr, &ip6h->daddr)) {
+ if(NDPI_COMPARE_IPV6_ADDRESS_STRUCTS(&ip6h->saddr, &ip6h->daddr)) {
key_return->ip.ipv6.lower_ip[0] = ((u_int64_t *) & ip6h->saddr)[0];
key_return->ip.ipv6.lower_ip[1] = ((u_int64_t *) & ip6h->saddr)[1];
key_return->ip.ipv6.upper_ip[0] = ((u_int64_t *) & ip6h->daddr)[0];
@@ -4113,18 +4187,18 @@
}
/* tcp / udp detection */
- if (key_return->protocol == 6 /* TCP */ && l4_len >= sizeof(struct ndpi_tcphdr)) {
+ if(key_return->protocol == 6 /* TCP */ && l4_len >= sizeof(struct ndpi_tcphdr)) {
const struct ndpi_tcphdr *tcph = (const struct ndpi_tcphdr *) l4;
- if (swapped == 0) {
+ if(swapped == 0) {
key_return->lower_port = tcph->source;
key_return->upper_port = tcph->dest;
} else {
key_return->lower_port = tcph->dest;
key_return->upper_port = tcph->source;
}
- } else if (key_return->protocol == 17 /* UDP */ && l4_len >= sizeof(struct ndpi_udphdr)) {
+ } else if(key_return->protocol == 17 /* UDP */ && l4_len >= sizeof(struct ndpi_udphdr)) {
const struct ndpi_udphdr *udph = (struct ndpi_udphdr *) l4;
- if (swapped == 0) {
+ if(swapped == 0) {
key_return->lower_port = udph->source;
key_return->upper_port = udph->dest;
} else {
@@ -4137,7 +4211,7 @@
key_return->upper_port = 0;
}
- if (dir_return != NULL) {
+ if(dir_return != NULL) {
*dir_return = swapped;
}
@@ -4163,7 +4237,7 @@
{
u_int32_t val;
val = 0;
- if (max_chars_to_read <= 2 || str[0] != '0' || str[1] != 'x') {
+ if(max_chars_to_read <= 2 || str[0] != '0' || str[1] != 'x') {
return ndpi_bytestream_to_number(str, max_chars_to_read, bytes_read);
} else {
/*use base 16 system */
@@ -4172,13 +4246,13 @@
*bytes_read = *bytes_read + 2;
while (max_chars_to_read > 0) {
- if (*str >= '0' && *str <= '9') {
+ if(*str >= '0' && *str <= '9') {
val *= 16;
val += *str - '0';
- } else if (*str >= 'a' && *str <= 'f') {
+ } else if(*str >= 'a' && *str <= 'f') {
val *= 16;
val += *str + 10 - 'a';
- } else if (*str >= 'A' && *str <= 'F') {
+ } else if(*str >= 'A' && *str <= 'F') {
val *= 16;
val += *str + 10 - 'A';
} else {
@@ -4212,7 +4286,7 @@
{
u_int64_t val;
val = 0;
- if (max_chars_to_read <= 2 || str[0] != '0' || str[1] != 'x') {
+ if(max_chars_to_read <= 2 || str[0] != '0' || str[1] != 'x') {
return ndpi_bytestream_to_number64(str, max_chars_to_read, bytes_read);
} else {
/*use base 16 system */
@@ -4221,13 +4295,13 @@
*bytes_read = *bytes_read + 2;
while (max_chars_to_read > 0) {
- if (*str >= '0' && *str <= '9') {
+ if(*str >= '0' && *str <= '9') {
val *= 16;
val += *str - '0';
- } else if (*str >= 'a' && *str <= 'f') {
+ } else if(*str >= 'a' && *str <= 'f') {
val *= 16;
val += *str + 10 - 'a';
- } else if (*str >= 'A' && *str <= 'F') {
+ } else if(*str >= 'A' && *str <= 'F') {
val *= 16;
val += *str + 10 - 'A';
} else {
@@ -4251,25 +4325,25 @@
/* ip address must be X.X.X.X with each X between 0 and 255 */
oldread = read;
c = ndpi_bytestream_to_number(str, max_chars_to_read, &read);
- if (c > 255 || oldread == read || max_chars_to_read == read || str[read] != '.')
+ if(c > 255 || oldread == read || max_chars_to_read == read || str[read] != '.')
return 0;
read++;
val = c << 24;
oldread = read;
c = ndpi_bytestream_to_number(&str[read], max_chars_to_read - read, &read);
- if (c > 255 || oldread == read || max_chars_to_read == read || str[read] != '.')
+ if(c > 255 || oldread == read || max_chars_to_read == read || str[read] != '.')
return 0;
read++;
val = val + (c << 16);
oldread = read;
c = ndpi_bytestream_to_number(&str[read], max_chars_to_read - read, &read);
- if (c > 255 || oldread == read || max_chars_to_read == read || str[read] != '.')
+ if(c > 255 || oldread == read || max_chars_to_read == read || str[read] != '.')
return 0;
read++;
val = val + (c << 8);
oldread = read;
c = ndpi_bytestream_to_number(&str[read], max_chars_to_read - read, &read);
- if (c > 255 || oldread == read || max_chars_to_read == read)
+ if(c > 255 || oldread == read || max_chars_to_read == read)
return 0;
val = val + c;
@@ -4285,7 +4359,7 @@
u_int32_t a;
struct ndpi_packet_struct *packet = &flow->packet;
u_int16_t end = packet->payload_packet_len - 1;
- if (packet->packet_lines_parsed_complete != 0)
+ if(packet->packet_lines_parsed_complete != 0)
return;
packet->packet_lines_parsed_complete = 1;
@@ -4329,24 +4403,24 @@
packet->line[packet->parsed_lines].ptr = packet->payload;
packet->line[packet->parsed_lines].len = 0;
- for (a = 0; (a+1) < end; a++) {
- if (get_u_int16_t(packet->payload, a) == ntohs(0x0d0a)) {
+ for (a = 0; a < end; a++) {
+ if(get_u_int16_t(packet->payload, a) == ntohs(0x0d0a)) {
packet->line[packet->parsed_lines].len = (u_int16_t)(((unsigned long) &packet->payload[a]) - ((unsigned long) packet->line[packet->parsed_lines].ptr));
- if (packet->parsed_lines == 0 && packet->line[0].len >= NDPI_STATICSTRING_LEN("HTTP/1.1 200 ") &&
- memcmp(packet->line[0].ptr, "HTTP/1.", NDPI_STATICSTRING_LEN("HTTP/1.")) == 0 &&
- packet->line[0].ptr[NDPI_STATICSTRING_LEN("HTTP/1.1 ")] > '0' &&
- packet->line[0].ptr[NDPI_STATICSTRING_LEN("HTTP/1.1 ")] < '6') {
+ if(packet->parsed_lines == 0 && packet->line[0].len >= NDPI_STATICSTRING_LEN("HTTP/1.1 200 ") &&
+ memcmp(packet->line[0].ptr, "HTTP/1.", NDPI_STATICSTRING_LEN("HTTP/1.")) == 0 &&
+ packet->line[0].ptr[NDPI_STATICSTRING_LEN("HTTP/1.1 ")] > '0' &&
+ packet->line[0].ptr[NDPI_STATICSTRING_LEN("HTTP/1.1 ")] < '6') {
packet->http_response.ptr = &packet->line[0].ptr[NDPI_STATICSTRING_LEN("HTTP/1.1 ")];
packet->http_response.len = packet->line[0].len - NDPI_STATICSTRING_LEN("HTTP/1.1 ");
NDPI_LOG(NDPI_PROTOCOL_UNKNOWN, ndpi_struct, NDPI_LOG_DEBUG,
"ndpi_parse_packet_line_info: HTTP response parsed: \"%.*s\"\n",
packet->http_response.len, packet->http_response.ptr);
}
- if (packet->line[packet->parsed_lines].len > NDPI_STATICSTRING_LEN("Server:") + 1
- && memcmp(packet->line[packet->parsed_lines].ptr, "Server:", NDPI_STATICSTRING_LEN("Server:")) == 0) {
+ if(packet->line[packet->parsed_lines].len > NDPI_STATICSTRING_LEN("Server:") + 1
+ && memcmp(packet->line[packet->parsed_lines].ptr, "Server:", NDPI_STATICSTRING_LEN("Server:")) == 0) {
// some stupid clients omit a space and place the servername directly after the colon
- if (packet->line[packet->parsed_lines].ptr[NDPI_STATICSTRING_LEN("Server:")] == ' ') {
+ if(packet->line[packet->parsed_lines].ptr[NDPI_STATICSTRING_LEN("Server:")] == ' ') {
packet->server_line.ptr =
&packet->line[packet->parsed_lines].ptr[NDPI_STATICSTRING_LEN("Server:") + 1];
packet->server_line.len =
@@ -4357,10 +4431,10 @@
}
}
- if (packet->line[packet->parsed_lines].len > 6
- && memcmp(packet->line[packet->parsed_lines].ptr, "Host:", 5) == 0) {
+ if(packet->line[packet->parsed_lines].len > 6
+ && memcmp(packet->line[packet->parsed_lines].ptr, "Host:", 5) == 0) {
// some stupid clients omit a space and place the hostname directly after the colon
- if (packet->line[packet->parsed_lines].ptr[5] == ' ') {
+ if(packet->line[packet->parsed_lines].ptr[5] == ' ') {
packet->host_line.ptr = &packet->line[packet->parsed_lines].ptr[6];
packet->host_line.len = packet->line[packet->parsed_lines].len - 6;
} else {
@@ -4369,75 +4443,75 @@
}
}
- if (packet->line[packet->parsed_lines].len > 14
- &&
- (memcmp
- (packet->line[packet->parsed_lines].ptr, "Content-Type: ",
- 14) == 0 || memcmp(packet->line[packet->parsed_lines].ptr, "Content-type: ", 14) == 0)) {
+ if(packet->line[packet->parsed_lines].len > 14
+ &&
+ (memcmp
+ (packet->line[packet->parsed_lines].ptr, "Content-Type: ",
+ 14) == 0 || memcmp(packet->line[packet->parsed_lines].ptr, "Content-type: ", 14) == 0)) {
packet->content_line.ptr = &packet->line[packet->parsed_lines].ptr[14];
packet->content_line.len = packet->line[packet->parsed_lines].len - 14;
}
- if (packet->line[packet->parsed_lines].len > 13
- && memcmp(packet->line[packet->parsed_lines].ptr, "Content-type:", 13) == 0) {
+ if(packet->line[packet->parsed_lines].len > 13
+ && memcmp(packet->line[packet->parsed_lines].ptr, "Content-type:", 13) == 0) {
packet->content_line.ptr = &packet->line[packet->parsed_lines].ptr[13];
packet->content_line.len = packet->line[packet->parsed_lines].len - 13;
}
- if (packet->line[packet->parsed_lines].len > 8
- && memcmp(packet->line[packet->parsed_lines].ptr, "Accept: ", 8) == 0) {
+ if(packet->line[packet->parsed_lines].len > 8
+ && memcmp(packet->line[packet->parsed_lines].ptr, "Accept: ", 8) == 0) {
packet->accept_line.ptr = &packet->line[packet->parsed_lines].ptr[8];
packet->accept_line.len = packet->line[packet->parsed_lines].len - 8;
}
- if (packet->line[packet->parsed_lines].len > 9
- && memcmp(packet->line[packet->parsed_lines].ptr, "Referer: ", 9) == 0) {
+ if(packet->line[packet->parsed_lines].len > 9
+ && memcmp(packet->line[packet->parsed_lines].ptr, "Referer: ", 9) == 0) {
packet->referer_line.ptr = &packet->line[packet->parsed_lines].ptr[9];
packet->referer_line.len = packet->line[packet->parsed_lines].len - 9;
}
- if (packet->line[packet->parsed_lines].len > 12
- && (memcmp(packet->line[packet->parsed_lines].ptr, "User-Agent: ", 12) == 0 ||
- memcmp(packet->line[packet->parsed_lines].ptr, "User-agent: ", 12) == 0)) {
+ if(packet->line[packet->parsed_lines].len > 12
+ && (memcmp(packet->line[packet->parsed_lines].ptr, "User-Agent: ", 12) == 0 ||
+ memcmp(packet->line[packet->parsed_lines].ptr, "User-agent: ", 12) == 0)) {
packet->user_agent_line.ptr = &packet->line[packet->parsed_lines].ptr[12];
packet->user_agent_line.len = packet->line[packet->parsed_lines].len - 12;
}
- if (packet->line[packet->parsed_lines].len > 18
- && memcmp(packet->line[packet->parsed_lines].ptr, "Content-Encoding: ", 18) == 0) {
+ if(packet->line[packet->parsed_lines].len > 18
+ && memcmp(packet->line[packet->parsed_lines].ptr, "Content-Encoding: ", 18) == 0) {
packet->http_encoding.ptr = &packet->line[packet->parsed_lines].ptr[18];
packet->http_encoding.len = packet->line[packet->parsed_lines].len - 18;
}
- if (packet->line[packet->parsed_lines].len > 19
- && memcmp(packet->line[packet->parsed_lines].ptr, "Transfer-Encoding: ", 19) == 0) {
+ if(packet->line[packet->parsed_lines].len > 19
+ && memcmp(packet->line[packet->parsed_lines].ptr, "Transfer-Encoding: ", 19) == 0) {
packet->http_transfer_encoding.ptr = &packet->line[packet->parsed_lines].ptr[19];
packet->http_transfer_encoding.len = packet->line[packet->parsed_lines].len - 19;
}
- if (packet->line[packet->parsed_lines].len > 16
- && ((memcmp(packet->line[packet->parsed_lines].ptr, "Content-Length: ", 16) == 0)
- || (memcmp(packet->line[packet->parsed_lines].ptr, "content-length: ", 16) == 0))) {
+ if(packet->line[packet->parsed_lines].len > 16
+ && ((memcmp(packet->line[packet->parsed_lines].ptr, "Content-Length: ", 16) == 0)
+ || (memcmp(packet->line[packet->parsed_lines].ptr, "content-length: ", 16) == 0))) {
packet->http_contentlen.ptr = &packet->line[packet->parsed_lines].ptr[16];
packet->http_contentlen.len = packet->line[packet->parsed_lines].len - 16;
}
- if (packet->line[packet->parsed_lines].len > 8
- && memcmp(packet->line[packet->parsed_lines].ptr, "Cookie: ", 8) == 0) {
+ if(packet->line[packet->parsed_lines].len > 8
+ && memcmp(packet->line[packet->parsed_lines].ptr, "Cookie: ", 8) == 0) {
packet->http_cookie.ptr = &packet->line[packet->parsed_lines].ptr[8];
packet->http_cookie.len = packet->line[packet->parsed_lines].len - 8;
}
- if (packet->line[packet->parsed_lines].len > 16
- && memcmp(packet->line[packet->parsed_lines].ptr, "X-Session-Type: ", 16) == 0) {
+ if(packet->line[packet->parsed_lines].len > 16
+ && memcmp(packet->line[packet->parsed_lines].ptr, "X-Session-Type: ", 16) == 0) {
packet->http_x_session_type.ptr = &packet->line[packet->parsed_lines].ptr[16];
packet->http_x_session_type.len = packet->line[packet->parsed_lines].len - 16;
}
- if (packet->line[packet->parsed_lines].len == 0) {
+ if(packet->line[packet->parsed_lines].len == 0) {
packet->empty_line_position = a;
packet->empty_line_position_set = 1;
}
- if (packet->parsed_lines >= (NDPI_MAX_PARSE_LINES_PER_PACKET - 1)) {
+ if(packet->parsed_lines >= (NDPI_MAX_PARSE_LINES_PER_PACKET - 1)) {
return;
}
@@ -4445,7 +4519,7 @@
packet->line[packet->parsed_lines].ptr = &packet->payload[a + 2];
packet->line[packet->parsed_lines].len = 0;
- if ((a + 2) >= packet->payload_packet_len) {
+ if((a + 2) >= packet->payload_packet_len) {
return;
}
@@ -4453,7 +4527,7 @@
}
}
- if (packet->parsed_lines >= 1) {
+ if(packet->parsed_lines >= 1) {
packet->line[packet->parsed_lines].len
= (u_int16_t)(((unsigned long) &packet->payload[packet->payload_packet_len]) -
((unsigned long) packet->line[packet->parsed_lines].ptr));
@@ -4467,7 +4541,7 @@
struct ndpi_packet_struct *packet = &flow->packet;
u_int32_t a;
u_int16_t end = packet->payload_packet_len;
- if (packet->packet_unix_lines_parsed_complete != 0)
+ if(packet->packet_unix_lines_parsed_complete != 0)
return;
@@ -4475,19 +4549,19 @@
packet->packet_unix_lines_parsed_complete = 1;
packet->parsed_unix_lines = 0;
- if (packet->payload_packet_len == 0)
+ if(packet->payload_packet_len == 0)
return;
packet->unix_line[packet->parsed_unix_lines].ptr = packet->payload;
packet->unix_line[packet->parsed_unix_lines].len = 0;
for (a = 0; a < end; a++) {
- if (packet->payload[a] == 0x0a) {
+ if(packet->payload[a] == 0x0a) {
packet->unix_line[packet->parsed_unix_lines].len = (u_int16_t)(
((unsigned long) &packet->payload[a]) -
((unsigned long) packet->unix_line[packet->parsed_unix_lines].ptr));
- if (packet->parsed_unix_lines >= (NDPI_MAX_PARSE_LINES_PER_PACKET - 1)) {
+ if(packet->parsed_unix_lines >= (NDPI_MAX_PARSE_LINES_PER_PACKET - 1)) {
break;
}
@@ -4495,7 +4569,7 @@
packet->unix_line[packet->parsed_unix_lines].ptr = &packet->payload[a + 1];
packet->unix_line[packet->parsed_unix_lines].len = 0;
- if ((a + 1) >= packet->payload_packet_len) {
+ if((a + 1) >= packet->payload_packet_len) {
break;
}
//a++;
@@ -4513,10 +4587,10 @@
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_DEBUG, "called ndpi_check_for_email_address\n");
- if (packet->payload_packet_len > counter && ((packet->payload[counter] >= 'a' && packet->payload[counter] <= 'z')
- || (packet->payload[counter] >= 'A' && packet->payload[counter] <= 'Z')
- || (packet->payload[counter] >= '0' && packet->payload[counter] <= '9')
- || packet->payload[counter] == '-' || packet->payload[counter] == '_')) {
+ if(packet->payload_packet_len > counter && ((packet->payload[counter] >= 'a' && packet->payload[counter] <= 'z')
+ || (packet->payload[counter] >= 'A' && packet->payload[counter] <= 'Z')
+ || (packet->payload[counter] >= '0' && packet->payload[counter] <= '9')
+ || packet->payload[counter] == '-' || packet->payload[counter] == '_')) {
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_DEBUG, "first letter\n");
counter++;
while (packet->payload_packet_len > counter
@@ -4527,7 +4601,7 @@
|| packet->payload[counter] == '.')) {
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_DEBUG, "further letter\n");
counter++;
- if (packet->payload_packet_len > counter && packet->payload[counter] == '@') {
+ if(packet->payload_packet_len > counter && packet->payload[counter] == '@') {
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_DEBUG, "@\n");
counter++;
while (packet->payload_packet_len > counter
@@ -4537,31 +4611,31 @@
|| packet->payload[counter] == '-' || packet->payload[counter] == '_')) {
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_DEBUG, "letter\n");
counter++;
- if (packet->payload_packet_len > counter && packet->payload[counter] == '.') {
+ if(packet->payload_packet_len > counter && packet->payload[counter] == '.') {
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_DEBUG, ".\n");
counter++;
- if (packet->payload_packet_len > counter + 1
- && ((packet->payload[counter] >= 'a' && packet->payload[counter] <= 'z')
- && (packet->payload[counter + 1] >= 'a' && packet->payload[counter + 1] <= 'z'))) {
+ if(packet->payload_packet_len > counter + 1
+ && ((packet->payload[counter] >= 'a' && packet->payload[counter] <= 'z')
+ && (packet->payload[counter + 1] >= 'a' && packet->payload[counter + 1] <= 'z'))) {
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_DEBUG, "two letters\n");
counter += 2;
- if (packet->payload_packet_len > counter
- && (packet->payload[counter] == ' ' || packet->payload[counter] == ';')) {
+ if(packet->payload_packet_len > counter
+ && (packet->payload[counter] == ' ' || packet->payload[counter] == ';')) {
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_DEBUG, "whitespace1\n");
return counter;
- } else if (packet->payload_packet_len > counter && packet->payload[counter] >= 'a'
- && packet->payload[counter] <= 'z') {
+ } else if(packet->payload_packet_len > counter && packet->payload[counter] >= 'a'
+ && packet->payload[counter] <= 'z') {
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_DEBUG, "one letter\n");
counter++;
- if (packet->payload_packet_len > counter
- && (packet->payload[counter] == ' ' || packet->payload[counter] == ';')) {
+ if(packet->payload_packet_len > counter
+ && (packet->payload[counter] == ' ' || packet->payload[counter] == ';')) {
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_DEBUG, "whitespace2\n");
return counter;
- } else if (packet->payload_packet_len > counter && packet->payload[counter] >= 'a'
- && packet->payload[counter] <= 'z') {
+ } else if(packet->payload_packet_len > counter && packet->payload[counter] >= 'a'
+ && packet->payload[counter] <= 'z') {
counter++;
- if (packet->payload_packet_len > counter
- && (packet->payload[counter] == ' ' || packet->payload[counter] == ';')) {
+ if(packet->payload_packet_len > counter
+ && (packet->payload[counter] == ' ' || packet->payload[counter] == ';')) {
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_DEBUG, "whitespace3\n");
return counter;
} else {
@@ -4592,10 +4666,10 @@
*file = "";
*func = "";
- if (ndpi_struct->ndpi_debug_print_file != NULL)
+ if(ndpi_struct->ndpi_debug_print_file != NULL)
*file = ndpi_struct->ndpi_debug_print_file;
- if (ndpi_struct->ndpi_debug_print_function != NULL)
+ if(ndpi_struct->ndpi_debug_print_function != NULL)
*func = ndpi_struct->ndpi_debug_print_function;
*line = ndpi_struct->ndpi_debug_print_line;
@@ -4623,10 +4697,10 @@
ndpi_int_change_protocol(ndpi_struct, flow, detected_protocol, protocol_type);
- if (src != NULL) {
+ if(src != NULL) {
NDPI_ADD_PROTOCOL_TO_BITMASK(src->detected_protocol_bitmask, detected_protocol);
}
- if (dst != NULL) {
+ if(dst != NULL) {
NDPI_ADD_PROTOCOL_TO_BITMASK(dst->detected_protocol_bitmask, detected_protocol);
}
}
@@ -4642,7 +4716,7 @@
u_int16_t preserve_bitmask;
#endif
- if (!flow)
+ if(!flow)
return;
#if NDPI_PROTOCOL_HISTORY_SIZE > 1
@@ -4657,20 +4731,20 @@
* in the stack
*/
- if (protocol_type == NDPI_CORRELATED_PROTOCOL) {
+ if(protocol_type == NDPI_CORRELATED_PROTOCOL) {
u_int16_t saved_real_protocol = NDPI_PROTOCOL_UNKNOWN;
- if (stack_size == NDPI_PROTOCOL_HISTORY_SIZE) {
+ if(stack_size == NDPI_PROTOCOL_HISTORY_SIZE) {
/* check whether we will lost real protocol information due to shifting */
u_int16_t real_protocol = flow->protocol_stack_info.entry_is_real_protocol;
for (a = 0; a < stack_size; a++) {
- if (real_protocol & 1)
+ if(real_protocol & 1)
break;
real_protocol >>= 1;
}
- if (a == (stack_size - 1)) {
+ if(a == (stack_size - 1)) {
/* oh, only one real protocol at the end, store it and insert it later */
saved_real_protocol = flow->detected_protocol_stack[stack_size - 1];
}
@@ -4691,7 +4765,7 @@
flow->detected_protocol_stack[0] = detected_protocol;
/* restore real protocol */
- if (saved_real_protocol != NDPI_PROTOCOL_UNKNOWN) {
+ if(saved_real_protocol != NDPI_PROTOCOL_UNKNOWN) {
flow->detected_protocol_stack[stack_size - 1] = saved_real_protocol;
flow->protocol_stack_info.entry_is_real_protocol |= 1 << (stack_size - 1);
}
@@ -4699,11 +4773,11 @@
} else {
u_int8_t insert_at = 0;
- if (!(flow->protocol_stack_info.entry_is_real_protocol & 1)) {
+ if(!(flow->protocol_stack_info.entry_is_real_protocol & 1)) {
u_int16_t real_protocol = flow->protocol_stack_info.entry_is_real_protocol;
for (a = 0; a < stack_size; a++) {
- if (real_protocol & 1)
+ if(real_protocol & 1)
break;
real_protocol >>= 1;
}
@@ -4711,13 +4785,13 @@
insert_at = a;
}
- if (insert_at >= stack_size) {
+ if(insert_at >= stack_size) {
/* no real protocol found, insert it at the bottom */
insert_at = stack_size - 1;
}
- if (stack_size < NDPI_PROTOCOL_HISTORY_SIZE) {
+ if(stack_size < NDPI_PROTOCOL_HISTORY_SIZE) {
flow->protocol_stack_info.current_stack_size_minus_one++;
stack_size++;
}
@@ -4764,7 +4838,7 @@
u_int16_t preserve_bitmask;
#endif
- if (!packet)
+ if(!packet)
return;
#if NDPI_PROTOCOL_HISTORY_SIZE > 1
@@ -4779,20 +4853,20 @@
* in the stack
*/
- if (protocol_type == NDPI_CORRELATED_PROTOCOL) {
+ if(protocol_type == NDPI_CORRELATED_PROTOCOL) {
u_int16_t saved_real_protocol = NDPI_PROTOCOL_UNKNOWN;
- if (stack_size == NDPI_PROTOCOL_HISTORY_SIZE) {
+ if(stack_size == NDPI_PROTOCOL_HISTORY_SIZE) {
/* check whether we will lost real protocol information due to shifting */
u_int16_t real_protocol = packet->protocol_stack_info.entry_is_real_protocol;
for (a = 0; a < stack_size; a++) {
- if (real_protocol & 1)
+ if(real_protocol & 1)
break;
real_protocol >>= 1;
}
- if (a == (stack_size - 1)) {
+ if(a == (stack_size - 1)) {
/* oh, only one real protocol at the end, store it and insert it later */
saved_real_protocol = packet->detected_protocol_stack[stack_size - 1];
}
@@ -4813,7 +4887,7 @@
packet->detected_protocol_stack[0] = detected_protocol;
/* restore real protocol */
- if (saved_real_protocol != NDPI_PROTOCOL_UNKNOWN) {
+ if(saved_real_protocol != NDPI_PROTOCOL_UNKNOWN) {
packet->detected_protocol_stack[stack_size - 1] = saved_real_protocol;
packet->protocol_stack_info.entry_is_real_protocol |= 1 << (stack_size - 1);
}
@@ -4821,11 +4895,11 @@
} else {
u_int8_t insert_at = 0;
- if (!(packet->protocol_stack_info.entry_is_real_protocol & 1)) {
+ if(!(packet->protocol_stack_info.entry_is_real_protocol & 1)) {
u_int16_t real_protocol = packet->protocol_stack_info.entry_is_real_protocol;
for (a = 0; a < stack_size; a++) {
- if (real_protocol & 1)
+ if(real_protocol & 1)
break;
real_protocol >>= 1;
}
@@ -4833,13 +4907,13 @@
insert_at = a;
}
- if (insert_at >= stack_size) {
+ if(insert_at >= stack_size) {
/* no real protocol found, insert it at the first unknown protocol */
insert_at = stack_size - 1;
}
- if (stack_size < NDPI_PROTOCOL_HISTORY_SIZE) {
+ if(stack_size < NDPI_PROTOCOL_HISTORY_SIZE) {
packet->protocol_stack_info.current_stack_size_minus_one++;
stack_size++;
}
@@ -4886,7 +4960,7 @@
u_int16_t real_protocol;
#endif
- if (!packet)
+ if(!packet)
return NDPI_PROTOCOL_UNKNOWN;
#if NDPI_PROTOCOL_HISTORY_SIZE > 1
@@ -4894,7 +4968,7 @@
real_protocol = packet->protocol_stack_info.entry_is_real_protocol;
for (a = 0; a < stack_size; a++) {
- if (real_protocol & 1)
+ if(real_protocol & 1)
return packet->detected_protocol_stack[a];
real_protocol >>= 1;
}
@@ -4918,7 +4992,7 @@
u_int8_t stack_size;
struct ndpi_packet_struct *packet = &flow->packet;
- if (!packet)
+ if(!packet)
return 0;
#if NDPI_PROTOCOL_HISTORY_SIZE > 1
@@ -4928,7 +5002,7 @@
#endif
for (a = 0; a < stack_size; a++) {
- if (packet->detected_protocol_stack[a] == protocol_id)
+ if(packet->detected_protocol_stack[a] == protocol_id)
return 1;
}
@@ -4991,7 +5065,7 @@
void ndpi_int_reset_protocol(struct ndpi_flow_struct *flow)
{
- if (flow) {
+ if(flow) {
flow->detected_protocol_stack[0] = NDPI_PROTOCOL_UNKNOWN;
#if NDPI_PROTOCOL_HISTORY_SIZE > 1
@@ -5017,9 +5091,9 @@
int ndpi_packet_src_ip_eql(const struct ndpi_packet_struct *packet, const ndpi_ip_addr_t * ip)
{
#ifdef NDPI_DETECTION_SUPPORT_IPV6
- if (packet->iphv6 != NULL) {
- if (packet->iphv6->saddr.ndpi_v6_u.u6_addr64[0] == ip->ipv6.ndpi_v6_u.u6_addr64[0] &&
- packet->iphv6->saddr.ndpi_v6_u.u6_addr64[1] == ip->ipv6.ndpi_v6_u.u6_addr64[1]) {
+ if(packet->iphv6 != NULL) {
+ if(packet->iphv6->saddr.ndpi_v6_u.u6_addr64[0] == ip->ipv6.ndpi_v6_u.u6_addr64[0] &&
+ packet->iphv6->saddr.ndpi_v6_u.u6_addr64[1] == ip->ipv6.ndpi_v6_u.u6_addr64[1]) {
return 1;
} else {
@@ -5027,7 +5101,7 @@
}
}
#endif
- if (packet->iph->saddr == ip->ipv4) {
+ if(packet->iph->saddr == ip->ipv4) {
return 1;
}
return 0;
@@ -5037,16 +5111,16 @@
int ndpi_packet_dst_ip_eql(const struct ndpi_packet_struct *packet, const ndpi_ip_addr_t * ip)
{
#ifdef NDPI_DETECTION_SUPPORT_IPV6
- if (packet->iphv6 != NULL) {
- if (packet->iphv6->daddr.ndpi_v6_u.u6_addr64[0] == ip->ipv6.ndpi_v6_u.u6_addr64[0] &&
- packet->iphv6->daddr.ndpi_v6_u.u6_addr64[1] == ip->ipv6.ndpi_v6_u.u6_addr64[1]) {
+ if(packet->iphv6 != NULL) {
+ if(packet->iphv6->daddr.ndpi_v6_u.u6_addr64[0] == ip->ipv6.ndpi_v6_u.u6_addr64[0] &&
+ packet->iphv6->daddr.ndpi_v6_u.u6_addr64[1] == ip->ipv6.ndpi_v6_u.u6_addr64[1]) {
return 1;
} else {
return 0;
}
}
#endif
- if (packet->iph->daddr == ip->ipv4) {
+ if(packet->iph->daddr == ip->ipv4) {
return 1;
}
return 0;
@@ -5058,7 +5132,7 @@
{
ndpi_ip_clear(ip);
#ifdef NDPI_DETECTION_SUPPORT_IPV6
- if (packet->iphv6 != NULL) {
+ if(packet->iphv6 != NULL) {
ip->ipv6.ndpi_v6_u.u6_addr64[0] = packet->iphv6->saddr.ndpi_v6_u.u6_addr64[0];
ip->ipv6.ndpi_v6_u.u6_addr64[1] = packet->iphv6->saddr.ndpi_v6_u.u6_addr64[1];
} else
@@ -5072,7 +5146,7 @@
{
ndpi_ip_clear(ip);
#ifdef NDPI_DETECTION_SUPPORT_IPV6
- if (packet->iphv6 != NULL) {
+ if(packet->iphv6 != NULL) {
ip->ipv6.ndpi_v6_u.u6_addr64[0] = packet->iphv6->daddr.ndpi_v6_u.u6_addr64[0];
ip->ipv6.ndpi_v6_u.u6_addr64[1] = packet->iphv6->daddr.ndpi_v6_u.u6_addr64[1];
} else
@@ -5090,7 +5164,7 @@
const u_int8_t *a = (const u_int8_t *) &ip->ipv4;
#ifdef NDPI_DETECTION_SUPPORT_IPV6
- if (ip->ipv6.ndpi_v6_u.u6_addr32[1] != 0 || ip->ipv6.ndpi_v6_u.u6_addr64[1] != 0) {
+ if(ip->ipv6.ndpi_v6_u.u6_addr32[1] != 0 || ip->ipv6.ndpi_v6_u.u6_addr64[1] != 0) {
const u_int16_t *b = ip->ipv6.ndpi_v6_u.u6_addr16;
snprintf(ndpi_struct->ip_string, NDPI_IP_STRING_SIZE, "%x:%x:%x:%x:%x:%x:%x:%x",
ntohs(b[0]), ntohs(b[1]), ntohs(b[2]), ntohs(b[3]),
@@ -5161,37 +5235,27 @@
u_int8_t proto,
u_int32_t shost, u_int16_t sport,
u_int32_t dhost, u_int16_t dport) {
- const void *ret;
- ndpi_default_ports_tree_node_t node;
-
- if(sport && dport) {
- node.default_port = sport;
- ret = ndpi_tfind(&node, (proto == IPPROTO_TCP) ? (void*)&ndpi_struct->tcpRoot : (void*)&ndpi_struct->udpRoot, ndpi_default_ports_tree_node_t_cmp);
-
- if(ret == NULL) {
- node.default_port = dport;
- ret = ndpi_tfind(&node, (proto == IPPROTO_TCP) ? (void*)&ndpi_struct->tcpRoot : (void*)&ndpi_struct->udpRoot, ndpi_default_ports_tree_node_t_cmp);
- }
+ unsigned int rc;
- if(ret != NULL) {
- ndpi_default_ports_tree_node_t *found = *(ndpi_default_ports_tree_node_t**)ret;
+ rc = ndpi_search_tcp_or_udp_raw(ndpi_struct, proto,
+ shost, dhost, sport, dport);
- return(found->proto->protoId);
- }
- }
+ if(rc == NDPI_PROTOCOL_UNKNOWN)
+ rc = ndpi_guess_protocol_id(ndpi_struct, proto,
+ shost, sport, dhost, dport);
- /* Use skype as last resort */
- if(shost && dhost && is_skype_connection(ndpi_struct, shost, dhost))
- return(NDPI_PROTOCOL_SKYPE);
+ if(rc != NDPI_PROTOCOL_UNKNOWN)
+ return(rc);
- return(ndpi_search_tcp_or_udp_raw(ndpi_struct, proto, shost, dhost, sport, dport));
+ return(ndpi_search_tcp_or_udp_raw(ndpi_struct, proto,
+ shost, dhost, sport, dport));
}
/* ****************************************************** */
char* ndpi_get_proto_name(struct ndpi_detection_module_struct *ndpi_mod, u_int16_t proto_id) {
if((proto_id >= ndpi_mod->ndpi_num_supported_protocols)
- && ((proto_id < NDPI_MAX_SUPPORTED_PROTOCOLS+NDPI_MAX_NUM_CUSTOM_PROTOCOLS)
+ && ((proto_id < (NDPI_MAX_SUPPORTED_PROTOCOLS+NDPI_MAX_NUM_CUSTOM_PROTOCOLS))
&& (ndpi_mod->proto_defaults[proto_id].protoName == NULL)))
proto_id = NDPI_PROTOCOL_UNKNOWN;
@@ -5229,14 +5293,14 @@
char c, sc;
size_t len;
- if ((c = *find++) != '\0') {
+ if((c = *find++) != '\0') {
len = strlen(find);
do {
do {
- if (slen-- < 1 || (sc = *s++) == '\0')
+ if(slen-- < 1 || (sc = *s++) == '\0')
return (NULL);
} while (sc != c);
- if (len > slen)
+ if(len > slen)
return (NULL);
} while (strncmp(s, find, len) != 0);
s--;
@@ -5279,7 +5343,7 @@
}
#endif
- if (matching_protocol_id != NDPI_PROTOCOL_UNKNOWN) {
+ if(matching_protocol_id != NDPI_PROTOCOL_UNKNOWN) {
packet->detected_protocol_stack[0] = matching_protocol_id;
return(packet->detected_protocol_stack[0]);
}
@@ -5359,52 +5423,54 @@
/* ****************************************************** */
+#ifndef __KERNEL__
char* ndpi_revision() {
- return("$Revision: 6926 $");
+ return(NDPI_SVN_RELEASE);
}
+#endif
/* ****************************************************** */
#ifdef WIN32
/*
-int pthread_mutex_init(pthread_mutex_t *mutex, void *unused) {
+ int pthread_mutex_init(pthread_mutex_t *mutex, void *unused) {
unused = NULL;
*mutex = CreateMutex(NULL, FALSE, NULL);
return *mutex == NULL ? -1 : 0;
-}
+ }
-int pthread_mutex_destroy(pthread_mutex_t *mutex) {
+ int pthread_mutex_destroy(pthread_mutex_t *mutex) {
return CloseHandle(*mutex) == 0 ? -1 : 0;
-}
+ }
-int pthread_mutex_lock(pthread_mutex_t *mutex) {
+ int pthread_mutex_lock(pthread_mutex_t *mutex) {
return WaitForSingleObject(*mutex, INFINITE) == WAIT_OBJECT_0 ? 0 : -1;
-}
+ }
-int pthread_mutex_unlock(pthread_mutex_t *mutex) {
+ int pthread_mutex_unlock(pthread_mutex_t *mutex) {
return ReleaseMutex(*mutex) == 0 ? -1 : 0;
-}
+ }
*/
/* http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/port/gettimeofday.c;h=75a91993b74414c0a1c13a2a09ce739cb8aa8a08;hb=HEAD */
int gettimeofday(struct timeval * tp, struct timezone * tzp) {
- /* FILETIME of Jan 1 1970 00:00:00. */
- const unsigned __int64 epoch = (__int64)(116444736000000000);
+ /* FILETIME of Jan 1 1970 00:00:00. */
+ const unsigned __int64 epoch = (__int64)(116444736000000000);
- FILETIME file_time;
- SYSTEMTIME system_time;
- ULARGE_INTEGER ularge;
-
- GetSystemTime(&system_time);
- SystemTimeToFileTime(&system_time, &file_time);
- ularge.LowPart = file_time.dwLowDateTime;
- ularge.HighPart = file_time.dwHighDateTime;
+ FILETIME file_time;
+ SYSTEMTIME system_time;
+ ULARGE_INTEGER ularge;
+
+ GetSystemTime(&system_time);
+ SystemTimeToFileTime(&system_time, &file_time);
+ ularge.LowPart = file_time.dwLowDateTime;
+ ularge.HighPart = file_time.dwHighDateTime;
- tp->tv_sec = (long) ((ularge.QuadPart - epoch) / 10000000L);
- tp->tv_usec = (long) (system_time.wMilliseconds * 1000);
+ tp->tv_sec = (long) ((ularge.QuadPart - epoch) / 10000000L);
+ tp->tv_usec = (long) (system_time.wMilliseconds * 1000);
- return 0;
- }
+ return 0;
+}
#endif
int NDPI_BITMASK_COMPARE(NDPI_PROTOCOL_BITMASK a, NDPI_PROTOCOL_BITMASK b) {
@@ -5458,14 +5524,14 @@
int c, sc;
char *tok;
- if ((s = *stringp) == NULL)
+ if((s = *stringp) == NULL)
return (NULL);
for (tok = s;;) {
c = *s++;
spanp = delim;
do {
- if ((sc = *spanp++) == c) {
- if (c == 0)
+ if((sc = *spanp++) == c) {
+ if(c == 0)
s = NULL;
else
s[-1] = 0;
|