fixed some dissector for logic or syntax

This commit is contained in:
Campus
2016-10-07 11:37:42 +02:00
parent 7e8e243e68
commit 2c47dca086
6 changed files with 199 additions and 224 deletions
+20 -8
View File
@@ -69,6 +69,8 @@ typedef struct ndpi_flow_info {
void *src_id, *dst_id; void *src_id, *dst_id;
} ndpi_flow_info_t; } ndpi_flow_info_t;
// flow statistics info
typedef struct ndpi_stats { typedef struct ndpi_stats {
u_int32_t guessed_flow_protocols; u_int32_t guessed_flow_protocols;
u_int64_t raw_packet_count; u_int64_t raw_packet_count;
@@ -84,6 +86,8 @@ typedef struct ndpi_stats {
u_int16_t max_packet_len; u_int16_t max_packet_len;
} ndpi_stats_t; } ndpi_stats_t;
// flow preferences
typedef struct ndpi_workflow_prefs { typedef struct ndpi_workflow_prefs {
u_int8_t decode_tunnels; u_int8_t decode_tunnels;
u_int8_t quiet_mode; u_int8_t quiet_mode;
@@ -92,9 +96,12 @@ typedef struct ndpi_workflow_prefs {
} ndpi_workflow_prefs_t; } ndpi_workflow_prefs_t;
struct ndpi_workflow; struct ndpi_workflow;
/** workflow, flow, user data */ /** workflow, flow, user data */
typedef void (*ndpi_workflow_callback_ptr) (struct ndpi_workflow *, struct ndpi_flow_info *, void *); typedef void (*ndpi_workflow_callback_ptr) (struct ndpi_workflow *, struct ndpi_flow_info *, void *);
// workflow main structure
typedef struct ndpi_workflow { typedef struct ndpi_workflow {
u_int64_t last_time; u_int64_t last_time;
@@ -114,38 +121,43 @@ typedef struct ndpi_workflow {
struct ndpi_detection_module_struct *ndpi_struct; struct ndpi_detection_module_struct *ndpi_struct;
} ndpi_workflow_t; } ndpi_workflow_t;
/* TODO: remove wrappers parameters and use ndpi global, when their initialization will be fixed... */ /* TODO: remove wrappers parameters and use ndpi global, when their initialization will be fixed... */
struct ndpi_workflow * ndpi_workflow_init(const struct ndpi_workflow_prefs * prefs, pcap_t * pcap_handle); struct ndpi_workflow * ndpi_workflow_init(const struct ndpi_workflow_prefs * prefs, pcap_t * pcap_handle);
// workflow main free function
void ndpi_workflow_free(struct ndpi_workflow * workflow); void ndpi_workflow_free(struct ndpi_workflow * workflow);
/** Free flow_info ndpi support structures but not the flow_info itself /** Free flow_info ndpi support structures but not the flow_info itself
* *
* TODO remove! Half freeing things is bad! * TODO remove! Half freeing things is bad!
*/ */
void ndpi_free_flow_info_half(struct ndpi_flow_info *flow); void ndpi_free_flow_info_half(struct ndpi_flow_info *flow);
/** Process a @packet and update the @workflow. */ /** Process a @packet and update the @workflow. */
void ndpi_workflow_process_packet (struct ndpi_workflow * workflow, void ndpi_workflow_process_packet (struct ndpi_workflow * workflow,
const struct pcap_pkthdr *header, const struct pcap_pkthdr *header,
const u_char *packet); const u_char *packet);
/* flow callbacks: ndpi_flow_info will be freed right after */
static inline void ndpi_workflow_set_flow_detected_callback(struct ndpi_workflow * workflow, /* flow callbacks for complete detected flow
ndpi_workflow_callback_ptr callback, (ndpi_flow_info will be freed right after) */
void * udata) { static inline void ndpi_workflow_set_flow_detected_callback(struct ndpi_workflow * workflow, ndpi_workflow_callback_ptr callback, void * udata) {
workflow->__flow_detected_callback = callback; workflow->__flow_detected_callback = callback;
workflow->__flow_detected_udata = udata; workflow->__flow_detected_udata = udata;
} }
static inline void ndpi_workflow_set_flow_giveup_callback(struct ndpi_workflow * workflow, /* flow callbacks for sufficient detected flow
ndpi_workflow_callback_ptr callback, (ndpi_flow_info will be freed right after) */
void * udata) { static inline void ndpi_workflow_set_flow_giveup_callback(struct ndpi_workflow * workflow, ndpi_workflow_callback_ptr callback, void * udata) {
workflow->__flow_giveup_callback = callback; workflow->__flow_giveup_callback = callback;
workflow->__flow_giveup_udata = udata; workflow->__flow_giveup_udata = udata;
} }
// compare two nodes in workflow
int ndpi_workflow_node_cmp(const void *a, const void *b); int ndpi_workflow_node_cmp(const void *a, const void *b);
#endif #endif
+140 -164
View File
@@ -21,15 +21,13 @@
* along with nDPI. If not, see <http://www.gnu.org/licenses/>. * along with nDPI. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
#include "ndpi_api.h" #include "ndpi_api.h"
#ifdef NDPI_PROTOCOL_MSN #ifdef NDPI_PROTOCOL_MSN
#define MAX_PACKETS_FOR_MSN 100 #define MAX_PACKETS_FOR_MSN 100
static void ndpi_int_msn_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow/* , */
/* ndpi_protocol_type_t protocol_type */) static void ndpi_int_msn_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{ {
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_MSN, NDPI_PROTOCOL_UNKNOWN); ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_MSN, NDPI_PROTOCOL_UNKNOWN);
} }
@@ -38,11 +36,11 @@ static u_int8_t ndpi_int_find_xmsn(struct ndpi_detection_module_struct *ndpi_str
{ {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
if (packet->parsed_lines > 3) { if(packet->parsed_lines > 3) {
u_int16_t i; u_int16_t i;
for (i = 2; i < packet->parsed_lines; i++) { for(i = 2; i < packet->parsed_lines; i++) {
if (packet->line[i].ptr != NULL && packet->line[i].len > NDPI_STATICSTRING_LEN("X-MSN") && if(packet->line[i].ptr != NULL && packet->line[i].len > NDPI_STATICSTRING_LEN("X-MSN") &&
memcmp(packet->line[i].ptr, "X-MSN", NDPI_STATICSTRING_LEN("X-MSN")) == 0) { memcmp(packet->line[i].ptr, "X-MSN", NDPI_STATICSTRING_LEN("X-MSN")) == 0) {
return 1; return 1;
} }
} }
@@ -50,7 +48,7 @@ static u_int8_t ndpi_int_find_xmsn(struct ndpi_detection_module_struct *ndpi_str
return 0; return 0;
} }
/* search over TCP */
static void ndpi_search_msn_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) static void ndpi_search_msn_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{ {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
@@ -63,32 +61,33 @@ static void ndpi_search_msn_tcp(struct ndpi_detection_module_struct *ndpi_struct
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE, "MSN tcp detection...\n"); NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE, "MSN tcp detection...\n");
#ifdef NDPI_PROTOCOL_SSL #ifdef NDPI_PROTOCOL_SSL
if (packet->detected_protocol_stack[0] == NDPI_PROTOCOL_SSL) { if(packet->detected_protocol_stack[0] == NDPI_PROTOCOL_SSL) {
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE, "msn ssl ft test\n");
if (flow->packet_counter < 10) {
}
if (flow->packet_counter == 7 && packet->payload_packet_len > 300) { NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE, "msn ssl ft test\n");
if (memcmp(packet->payload + 24, "MSNSLP", 6) == 0
|| (get_u_int32_t(packet->payload, 0) == htonl(0x30000000) && get_u_int32_t(packet->payload, 4) == 0x00000000)) { if(flow->packet_counter < 10) {
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE, "detected MSN File Transfer, ifdef ssl.\n"); if(flow->packet_counter == 7 && packet->payload_packet_len > 300) {
ndpi_int_msn_add_connection(ndpi_struct, flow); if(memcmp(packet->payload + 24, "MSNSLP", 6) == 0
|| (get_u_int32_t(packet->payload, 0) == htonl(0x30000000) && get_u_int32_t(packet->payload, 4) == 0x00000000)) {
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE, "detected MSN File Transfer, ifdef ssl.\n");
ndpi_int_msn_add_connection(ndpi_struct, flow);
return;
}
}
if(flow->packet_counter >= 5 && flow->packet_counter <= 10 && (get_u_int32_t(packet->payload, 0) == htonl(0x18000000)
&& get_u_int32_t(packet->payload, 4) == 0x00000000)) {
flow->l4.tcp.msn_ssl_ft++;
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE,
"increased msn ft ssl stage to: %u at packet nr: %u\n", flow->l4.tcp.msn_ssl_ft,
flow->packet_counter);
if (flow->l4.tcp.msn_ssl_ft == 2) {
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE,
"detected MSN File Transfer, ifdef ssl 2.\n");
ndpi_int_msn_add_connection(ndpi_struct, flow);
}
return; return;
} }
} }
if (flow->packet_counter >= 5 && flow->packet_counter <= 10 && (get_u_int32_t(packet->payload, 0) == htonl(0x18000000)
&& get_u_int32_t(packet->payload, 4) == 0x00000000)) {
flow->l4.tcp.msn_ssl_ft++;
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE,
"increased msn ft ssl stage to: %u at packet nr: %u\n", flow->l4.tcp.msn_ssl_ft,
flow->packet_counter);
if (flow->l4.tcp.msn_ssl_ft == 2) {
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE,
"detected MSN File Transfer, ifdef ssl 2.\n");
ndpi_int_msn_add_connection(ndpi_struct, flow);
}
return;
}
} }
#endif #endif
@@ -98,25 +97,25 @@ static void ndpi_search_msn_tcp(struct ndpi_detection_module_struct *ndpi_struct
* x is now "0", but can be increased * x is now "0", but can be increased
*/ */
/* now we have a look at the first packet only. */ /* now we have a look at the first packet only. */
if (flow->packet_counter == 1 if(flow->packet_counter == 1
#ifdef NDPI_PROTOCOL_SSL #ifdef NDPI_PROTOCOL_SSL
|| ((packet->detected_protocol_stack[0] == NDPI_PROTOCOL_SSL) && flow->packet_counter <= 3) || ((packet->detected_protocol_stack[0] == NDPI_PROTOCOL_SSL) && flow->packet_counter <= 3)
#endif #endif
) { ) {
/* this part is working asymmetrically */ /* this part is working asymmetrically */
if (packet->payload_packet_len > 32 && (packet->payload[0] == 0x02 || packet->payload[0] == 0x00) if(packet->payload_packet_len > 32 && (packet->payload[0] == 0x02 || packet->payload[0] == 0x00)
&& (ntohl(get_u_int32_t(packet->payload, 8)) == 0x2112a442 || ntohl(get_u_int32_t(packet->payload, 4)) == 0x2112a442) && (ntohl(get_u_int32_t(packet->payload, 8)) == 0x2112a442 || ntohl(get_u_int32_t(packet->payload, 4)) == 0x2112a442)
&& ((ntohl(get_u_int32_t(packet->payload, 24)) == 0x000f0004 && ntohl(get_u_int32_t(packet->payload, 28)) == 0x72c64bc6) && ((ntohl(get_u_int32_t(packet->payload, 24)) == 0x000f0004 && ntohl(get_u_int32_t(packet->payload, 28)) == 0x72c64bc6)
|| (ntohl(get_u_int32_t(packet->payload, 20)) == 0x000f0004 || (ntohl(get_u_int32_t(packet->payload, 20)) == 0x000f0004
&& ntohl(get_u_int32_t(packet->payload, 24)) == 0x72c64bc6))) { && ntohl(get_u_int32_t(packet->payload, 24)) == 0x72c64bc6))) {
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE, NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE,
"found MSN in packets that also contain voice.messenger.live.com.\n"); "found MSN in packets that also contain voice.messenger.live.com.\n");
/* TODO this is an alternative pattern for video detection */ /* TODO this is an alternative pattern for video detection */
/* if (packet->payload_packet_len > 100 && /* if (packet->payload_packet_len > 100 &&
get_u_int16_t(packet->payload, 86) == htons(0x05dc)) { */ get_u_int16_t(packet->payload, 86) == htons(0x05dc)) { */
if (packet->payload_packet_len > 101 && packet->payload[101] == 0x02) { if(packet->payload_packet_len > 101 && packet->payload[101] == 0x02) {
ndpi_int_msn_add_connection(ndpi_struct, flow); ndpi_int_msn_add_connection(ndpi_struct, flow);
} else { } else {
ndpi_int_msn_add_connection(ndpi_struct, flow); ndpi_int_msn_add_connection(ndpi_struct, flow);
@@ -148,13 +147,12 @@ static void ndpi_search_msn_tcp(struct ndpi_detection_module_struct *ndpi_struct
} }
} }
} }
if(
if (
#ifdef NDPI_PROTOCOL_HTTP #ifdef NDPI_PROTOCOL_HTTP
packet->detected_protocol_stack[0] == NDPI_PROTOCOL_HTTP || packet->detected_protocol_stack[0] == NDPI_PROTOCOL_HTTP ||
#endif #endif
ndpi_match_strprefix(packet->payload, packet->payload_packet_len, "GET ") || ndpi_match_strprefix(packet->payload, packet->payload_packet_len, "GET ") ||
ndpi_match_strprefix(packet->payload, packet->payload_packet_len, "POST ")) { ndpi_match_strprefix(packet->payload, packet->payload_packet_len, "POST ")) {
ndpi_parse_packet_line_info(ndpi_struct, flow); ndpi_parse_packet_line_info(ndpi_struct, flow);
if (packet->user_agent_line.ptr != NULL && if (packet->user_agent_line.ptr != NULL &&
packet->user_agent_line.len > NDPI_STATICSTRING_LEN("Messenger/") && packet->user_agent_line.len > NDPI_STATICSTRING_LEN("Messenger/") &&
@@ -163,15 +161,15 @@ static void ndpi_search_msn_tcp(struct ndpi_detection_module_struct *ndpi_struct
return; return;
} }
} }
#ifdef NDPI_PROTOCOL_HTTP /* #ifdef NDPI_PROTOCOL_HTTP */
/* we have to examine two http packets */ /* /\* we have to examine two http packets *\/ */
if (packet->detected_protocol_stack[0] == NDPI_PROTOCOL_HTTP) { /* if(packet->detected_protocol_stack[0] == NDPI_PROTOCOL_HTTP) { */
} /* } */
#endif /* #endif */
/* not seen this pattern in any trace */ /* not seen this pattern in any trace */
/* now test for http login, at least 100 a bytes packet */ /* now test for http login, at least 100 a bytes packet */
if (packet->payload_packet_len > 100) { if(packet->payload_packet_len > 100) {
if ( if(
#ifdef NDPI_PROTOCOL_HTTP #ifdef NDPI_PROTOCOL_HTTP
packet->detected_protocol_stack[0] == NDPI_PROTOCOL_HTTP || packet->detected_protocol_stack[0] == NDPI_PROTOCOL_HTTP ||
#endif #endif
@@ -179,13 +177,13 @@ static void ndpi_search_msn_tcp(struct ndpi_detection_module_struct *ndpi_struct
/* scan packet if not already done... */ /* scan packet if not already done... */
ndpi_parse_packet_line_info(ndpi_struct, flow); ndpi_parse_packet_line_info(ndpi_struct, flow);
if (packet->content_line.ptr != NULL && if(packet->content_line.ptr != NULL &&
((packet->content_line.len == NDPI_STATICSTRING_LEN("application/x-msn-messenger") && ((packet->content_line.len == NDPI_STATICSTRING_LEN("application/x-msn-messenger") &&
memcmp(packet->content_line.ptr, "application/x-msn-messenger", memcmp(packet->content_line.ptr, "application/x-msn-messenger",
NDPI_STATICSTRING_LEN("application/x-msn-messenger")) == 0) || NDPI_STATICSTRING_LEN("application/x-msn-messenger")) == 0) ||
(packet->content_line.len >= NDPI_STATICSTRING_LEN("text/x-msnmsgr") && (packet->content_line.len >= NDPI_STATICSTRING_LEN("text/x-msnmsgr") &&
memcmp(packet->content_line.ptr, "text/x-msnmsgr", memcmp(packet->content_line.ptr, "text/x-msnmsgr",
NDPI_STATICSTRING_LEN("text/x-msnmsgr")) == 0))) { NDPI_STATICSTRING_LEN("text/x-msnmsgr")) == 0))) {
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE, NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE,
"found MSN by pattern POST http:// .... application/x-msn-messenger.\n"); "found MSN by pattern POST http:// .... application/x-msn-messenger.\n");
ndpi_int_msn_add_connection(ndpi_struct, flow); ndpi_int_msn_add_connection(ndpi_struct, flow);
@@ -193,25 +191,24 @@ static void ndpi_search_msn_tcp(struct ndpi_detection_module_struct *ndpi_struct
} }
} }
} }
/* now test for http login that uses a gateway, at least 400 a bytes packet */ /* now test for http login that uses a gateway, at least 400 a bytes packet */
/* for this case the asymmetric detection is asym (1) */ /* for this case the asymmetric detection is asym (1) */
if (packet->payload_packet_len > 400) { if(packet->payload_packet_len > 400) {
if (( if((
#ifdef NDPI_PROTOCOL_HTTP #ifdef NDPI_PROTOCOL_HTTP
packet->detected_protocol_stack[0] == NDPI_PROTOCOL_HTTP || packet->detected_protocol_stack[0] == NDPI_PROTOCOL_HTTP ||
#endif #endif
(memcmp(packet->payload, "POST ", 5) == 0))) { (memcmp(packet->payload, "POST ", 5) == 0))) {
u_int16_t c; u_int16_t c;
if (memcmp(&packet->payload[5], "http://", 7) == 0) { if(memcmp(&packet->payload[5], "http://", 7) == 0) {
/* /*
* We are searching for a paten "POST http://gateway.messenger.hotmail.com/gateway/gateway.dll" or * We are searching for a pattern "POST http://gateway.messenger.hotmail.com/gateway/gateway.dll" or
* "POST http://<some ip addres here like 172.0.0.0>/gateway/gateway.dll" * "POST http://<some ip addres here like 172.0.0.0>/gateway/gateway.dll"
* POST http:// is 12 byte so we are searching for 13 to 70 byte for this paten. * POST http:// is 12 byte so we are searching for 13 to 70 byte for this paten.
*/ */
for (c = 13; c < 50; c++) { for(c = 13; c < 50; c++) {
if (memcmp(&packet->payload[c], "/", 1) == 0) { if(memcmp(&packet->payload[c], "/", 1) == 0) {
if (memcmp(&packet->payload[c], "/gateway/gateway.dll", 20) == 0) { if(memcmp(&packet->payload[c], "/gateway/gateway.dll", 20) == 0) {
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE, NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE,
"found pattern http://.../gateway/gateway.ddl.\n"); "found pattern http://.../gateway/gateway.ddl.\n");
status = 1; status = 1;
@@ -219,44 +216,38 @@ static void ndpi_search_msn_tcp(struct ndpi_detection_module_struct *ndpi_struct
} }
} }
} }
} else if ((memcmp(&packet->payload[5], "/gateway/gateway.dll", 20) == 0)) { } else if((memcmp(&packet->payload[5], "/gateway/gateway.dll", 20) == 0)) {
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE, NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE,
"found pattern http://.../gateway/gateway.ddl.\n"); "found pattern http://.../gateway/gateway.ddl.\n");
status = 1; status = 1;
} }
} }
if (status) { if(status) {
u_int16_t a; u_int16_t a;
ndpi_parse_packet_line_info(ndpi_struct, flow); ndpi_parse_packet_line_info(ndpi_struct, flow);
if (packet->content_line.ptr != NULL if(packet->content_line.ptr != NULL && ((packet->content_line.len == 23
&& && memcmp(packet->content_line.ptr, "text/xml; charset=utf-8", 23) == 0)
((packet->content_line.len == 23 ||
&& memcmp(packet->content_line.ptr, "text/xml; charset=utf-8", 23) == 0) (packet->content_line.len == 24
|| && memcmp(packet->content_line.ptr, "text/html; charset=utf-8", 24) == 0)
(packet->content_line.len == 24 ||
&& memcmp(packet->content_line.ptr, "text/html; charset=utf-8", 24) == 0) (packet->content_line.len == 33
|| && memcmp(packet->content_line.ptr, "application/x-www-form-urlencoded", 33) == 0))) {
(packet->content_line.len == 33
&& memcmp(packet->content_line.ptr, "application/x-www-form-urlencoded", 33) == 0) if ((src != NULL && NDPI_COMPARE_PROTOCOL_TO_BITMASK(src->detected_protocol_bitmask, NDPI_PROTOCOL_MSN) != 0)
)) { || (dst != NULL && NDPI_COMPARE_PROTOCOL_TO_BITMASK(dst->detected_protocol_bitmask, NDPI_PROTOCOL_MSN) != 0)) {
if ((src != NULL
&& NDPI_COMPARE_PROTOCOL_TO_BITMASK(src->detected_protocol_bitmask, NDPI_PROTOCOL_MSN) NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE, "found MSN with pattern text/xml; charset=utf-8.\n");
!= 0) || (dst != NULL
&& NDPI_COMPARE_PROTOCOL_TO_BITMASK(dst->detected_protocol_bitmask,
NDPI_PROTOCOL_MSN)
!= 0)) {
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE,
"found MSN with pattern text/xml; charset=utf-8.\n");
ndpi_int_msn_add_connection(ndpi_struct, flow); ndpi_int_msn_add_connection(ndpi_struct, flow);
return; return;
} }
for (a = 0; a < packet->parsed_lines; a++) { for(a = 0; a < packet->parsed_lines; a++) {
if (packet->line[a].len >= 4 && if(packet->line[a].len >= 4 && (memcmp(packet->line[a].ptr, "CVR ", 4) == 0
(memcmp(packet->line[a].ptr, "CVR ", 4) == 0 || memcmp(packet->line[a].ptr, "VER ", 4) == 0 ||
|| memcmp(packet->line[a].ptr, "VER ", memcmp(packet->line[a].ptr, "ANS ", 4) == 0)) {
4) == 0 || memcmp(packet->line[a].ptr, "ANS ", 4) == 0)) {
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE, NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE,
"found MSN with pattern text/sml; charset0utf-8.\n"); "found MSN with pattern text/sml; charset0utf-8.\n");
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct,
@@ -269,52 +260,47 @@ static void ndpi_search_msn_tcp(struct ndpi_detection_module_struct *ndpi_struct
} }
} }
/* asym (1) ; possibly occurs in symmetric cases also. */ /* asym (1) ; possibly occurs in symmetric cases also. */
if (flow->packet_counter <= 10 && if(flow->packet_counter <= 10 &&
(flow->packet_direction_counter[0] <= 2 || flow->packet_direction_counter[1] <= 2) (flow->packet_direction_counter[0] <= 2 || flow->packet_direction_counter[1] <= 2)
&& packet->payload_packet_len > 100) { && packet->payload_packet_len > 100) {
/* not necessary to check the length, because this has been done : >400. */ /* not necessary to check the length, because this has been done : >400. */
if ( if(
#ifdef NDPI_PROTOCOL_HTTP #ifdef NDPI_PROTOCOL_HTTP
packet->detected_protocol_stack[0] == NDPI_PROTOCOL_HTTP || packet->detected_protocol_stack[0] == NDPI_PROTOCOL_HTTP ||
#endif #endif
ndpi_match_strprefix(packet->payload, packet->payload_packet_len, "HTTP/1.0 200 OK") || ndpi_match_strprefix(packet->payload, packet->payload_packet_len, "HTTP/1.0 200 OK") ||
ndpi_match_strprefix(packet->payload, packet->payload_packet_len, "HTTP/1.1 200 OK") ndpi_match_strprefix(packet->payload, packet->payload_packet_len, "HTTP/1.1 200 OK")
) { ) {
ndpi_parse_packet_line_info(ndpi_struct, flow); ndpi_parse_packet_line_info(ndpi_struct, flow);
if (packet->content_line.ptr != NULL && if(packet->content_line.ptr != NULL &&
((packet->content_line.len == NDPI_STATICSTRING_LEN("application/x-msn-messenger") && ((packet->content_line.len == NDPI_STATICSTRING_LEN("application/x-msn-messenger") &&
memcmp(packet->content_line.ptr, "application/x-msn-messenger", memcmp(packet->content_line.ptr, "application/x-msn-messenger", NDPI_STATICSTRING_LEN("application/x-msn-messenger")) == 0) ||
NDPI_STATICSTRING_LEN("application/x-msn-messenger")) == 0) ||
(packet->content_line.len >= NDPI_STATICSTRING_LEN("text/x-msnmsgr") && (packet->content_line.len >= NDPI_STATICSTRING_LEN("text/x-msnmsgr") &&
memcmp(packet->content_line.ptr, "text/x-msnmsgr", memcmp(packet->content_line.ptr, "text/x-msnmsgr", NDPI_STATICSTRING_LEN("text/x-msnmsgr")) == 0))) {
NDPI_STATICSTRING_LEN("text/x-msnmsgr")) == 0))) {
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE, NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE,
"HTTP/1.0 200 OK .... application/x-msn-messenger.\n"); "HTTP/1.0 200 OK .... application/x-msn-messenger.\n");
ndpi_int_msn_add_connection(ndpi_struct, flow); ndpi_int_msn_add_connection(ndpi_struct, flow);
return; return;
} }
if (ndpi_int_find_xmsn(ndpi_struct, flow) == 1) { if(ndpi_int_find_xmsn(ndpi_struct, flow) == 1) {
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE, "HTTP/1.0 200 OK .... X-MSN.\n"); NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE, "HTTP/1.0 200 OK .... X-MSN.\n");
ndpi_int_msn_add_connection(ndpi_struct, flow); ndpi_int_msn_add_connection(ndpi_struct, flow);
return; return;
} }
} }
} }
/* did not find any trace with this pattern */
/* did not find any trace with this pattern !!!!! */
/* now block proxy connection */ /* now block proxy connection */
if (packet->payload_packet_len >= 42) { if(packet->payload_packet_len >= 42) {
if (memcmp(packet->payload, "CONNECT messenger.hotmail.com:1863 HTTP/1.", 42) == 0) { if(memcmp(packet->payload, "CONNECT messenger.hotmail.com:1863 HTTP/1.", 42) == 0) {
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE, NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE, "found MSN with pattern CONNECT messenger.hotmail.com:1863 HTTP/1..\n");
"found MSN with pattern CONNECT messenger.hotmail.com:1863 HTTP/1..\n");
ndpi_int_msn_add_connection(ndpi_struct, flow); ndpi_int_msn_add_connection(ndpi_struct, flow);
return; return;
} }
} }
if (packet->payload_packet_len >= 18) { if (packet->payload_packet_len >= 18) {
if (memcmp(packet->payload, "USR ", 4) == 0 || memcmp(packet->payload, "ANS ", 4) == 0) { if (memcmp(packet->payload, "USR ", 4) == 0 || memcmp(packet->payload, "ANS ", 4) == 0) {
@@ -347,59 +333,52 @@ static void ndpi_search_msn_tcp(struct ndpi_detection_module_struct *ndpi_struct
if (plen >= endlen) { if (plen >= endlen) {
goto ndpi_msn_exclude; goto ndpi_msn_exclude;
} }
} }
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE, NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE, "found MSN with pattern USR/ANS ...mail_address.\n");
"found MSN with pattern USR/ANS ...mail_address.\n");
ndpi_int_msn_add_connection(ndpi_struct, flow); ndpi_int_msn_add_connection(ndpi_struct, flow);
return; return;
} }
} }
} }
/* finished examining the first packet only. */ /* finished examining the first packet only. */
/* asym (1) ; possibly occurs in symmetric cases also. */ /* asym (1) ; possibly occurs in symmetric cases also. */
if (flow->packet_counter <= 10 && if(flow->packet_counter <= 10 &&
(flow->packet_direction_counter[0] <= 2 || flow->packet_direction_counter[1] <= 2) && (flow->packet_direction_counter[0] <= 2 || flow->packet_direction_counter[1] <= 2) &&
packet->payload_packet_len > 100) { packet->payload_packet_len > 100) {
/* not necessary to check the length, because this has been done : >400. */ /* not necessary to check the length, because this has been done : >400. */
if ( if(
#ifdef NDPI_PROTOCOL_HTTP #ifdef NDPI_PROTOCOL_HTTP
packet->detected_protocol_stack[0] == NDPI_PROTOCOL_HTTP || packet->detected_protocol_stack[0] == NDPI_PROTOCOL_HTTP ||
#endif #endif
(memcmp(packet->payload, "HTTP/1.0 200 OK", 15) == 0) || (memcmp(packet->payload, "HTTP/1.0 200 OK", 15) == 0) ||
(memcmp(packet->payload, "HTTP/1.1 200 OK", 15) == 0) (memcmp(packet->payload, "HTTP/1.1 200 OK", 15) == 0)) {
) {
ndpi_parse_packet_line_info(ndpi_struct, flow); ndpi_parse_packet_line_info(ndpi_struct, flow);
if (packet->content_line.ptr != NULL && if(packet->content_line.ptr != NULL && ((packet->content_line.len == NDPI_STATICSTRING_LEN("application/x-msn-messenger") &&
((packet->content_line.len == NDPI_STATICSTRING_LEN("application/x-msn-messenger") && memcmp(packet->content_line.ptr, "application/x-msn-messenger",
memcmp(packet->content_line.ptr, "application/x-msn-messenger", NDPI_STATICSTRING_LEN("application/x-msn-messenger")) == 0) ||
NDPI_STATICSTRING_LEN("application/x-msn-messenger")) == 0) || (packet->content_line.len >= NDPI_STATICSTRING_LEN("text/x-msnmsgr") &&
(packet->content_line.len >= NDPI_STATICSTRING_LEN("text/x-msnmsgr") && memcmp(packet->content_line.ptr, "text/x-msnmsgr", NDPI_STATICSTRING_LEN("text/x-msnmsgr")) == 0))) {
memcmp(packet->content_line.ptr, "text/x-msnmsgr", NDPI_STATICSTRING_LEN("text/x-msnmsgr")) == 0))) {
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE, NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE, "HTTP/1.0 200 OK .... application/x-msn-messenger.\n");
"HTTP/1.0 200 OK .... application/x-msn-messenger.\n");
ndpi_int_msn_add_connection(ndpi_struct, flow); ndpi_int_msn_add_connection(ndpi_struct, flow);
return; return;
} }
if (ndpi_int_find_xmsn(ndpi_struct, flow) == 1) { if(ndpi_int_find_xmsn(ndpi_struct, flow) == 1) {
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE, "HTTP/1.0 200 OK .... X-MSN.\n"); NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE, "HTTP/1.0 200 OK .... X-MSN.\n");
ndpi_int_msn_add_connection(ndpi_struct, flow); ndpi_int_msn_add_connection(ndpi_struct, flow);
return; return;
} }
} }
} }
/* finished examining the secone packet only */ /* finished examining the secone packet only */
/* direct user connection (file transfer,...) */ /* direct user connection (file transfer,...) */
if ((src != NULL && NDPI_COMPARE_PROTOCOL_TO_BITMASK(src->detected_protocol_bitmask, NDPI_PROTOCOL_MSN) != 0) if((src != NULL && NDPI_COMPARE_PROTOCOL_TO_BITMASK(src->detected_protocol_bitmask, NDPI_PROTOCOL_MSN) != 0)
|| (dst != NULL || (dst != NULL
&& NDPI_COMPARE_PROTOCOL_TO_BITMASK(dst->detected_protocol_bitmask, NDPI_PROTOCOL_MSN) != 0)) { && NDPI_COMPARE_PROTOCOL_TO_BITMASK(dst->detected_protocol_bitmask, NDPI_PROTOCOL_MSN) != 0)) {
if (flow->packet_counter == 1 && if (flow->packet_counter == 1 &&
packet->payload_packet_len > 12 && memcmp(packet->payload, "recipientid=", 12) == 0) { packet->payload_packet_len > 12 && memcmp(packet->payload, "recipientid=", 12) == 0) {
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_DEBUG, "detected file transfer.\n"); NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_DEBUG, "detected file transfer.\n");
@@ -407,23 +386,22 @@ static void ndpi_search_msn_tcp(struct ndpi_detection_module_struct *ndpi_struct
return; return;
} }
} }
/* MSN File Transfer of MSN 8.1 and 8.5 /* MSN File Transfer of MSN 8.1 and 8.5
* first packet with length 4 and pattern 0x04000000 * first packet with length 4 and pattern 0x04000000
* second packet (in the same direction), with length 56 and pattern 0x00000000 from payload[16] * second packet (in the same direction), with length 56 and pattern 0x00000000 from payload[16]
* third packet (in the opposite direction to 1 & 2), with length 4 and pattern 0x30000000 * third packet (in the opposite direction to 1 & 2), with length 4 and pattern 0x30000000
*/ */
if (flow->l4.tcp.msn_stage == 0) { if(flow->l4.tcp.msn_stage == 0) {
/* asymmetric detection to this pattern is asym (2) */ /* asymmetric detection to this pattern is asym (2) */
if ((packet->payload_packet_len == 4 || packet->payload_packet_len == 8) if((packet->payload_packet_len == 4 || packet->payload_packet_len == 8)
&& get_u_int32_t(packet->payload, 0) == htonl(0x04000000)) { && get_u_int32_t(packet->payload, 0) == htonl(0x04000000)) {
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_DEBUG, "maybe first TCP MSN detected\n"); NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_DEBUG, "maybe first TCP MSN detected\n");
if (packet->payload_packet_len == 8 && get_u_int32_t(packet->payload, 4) == htonl(0x666f6f00)) { if(packet->payload_packet_len == 8 && get_u_int32_t(packet->payload, 4) == htonl(0x666f6f00)) {
flow->l4.tcp.msn_stage = 5 + packet->packet_direction; flow->l4.tcp.msn_stage = 5 + packet->packet_direction;
return; return;
} }
flow->l4.tcp.msn_stage = 1 + packet->packet_direction; flow->l4.tcp.msn_stage = 1 + packet->packet_direction;
return; return;
} }
@@ -469,10 +447,11 @@ static void ndpi_search_msn_tcp(struct ndpi_detection_module_struct *ndpi_struct
} }
} }
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_DEBUG, "msn 7.\n"); NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_DEBUG, "msn 7.\n");
if (flow->packet_counter <= MAX_PACKETS_FOR_MSN) { if (flow->packet_counter <= MAX_PACKETS_FOR_MSN) {
if (packet->tcp->source == htons(443) if (packet->tcp->source == htons(443) || packet->tcp->dest == htons(443)) {
|| packet->tcp->dest == htons(443)) {
if (packet->payload_packet_len > 300) { if (packet->payload_packet_len > 300) {
if (memcmp(&packet->payload[40], "INVITE MSNMSGR", 14) == 0 if (memcmp(&packet->payload[40], "INVITE MSNMSGR", 14) == 0
|| memcmp(&packet->payload[56], "INVITE MSNMSGR", 14) == 0 || memcmp(&packet->payload[56], "INVITE MSNMSGR", 14) == 0
|| memcmp(&packet->payload[172], "INVITE MSNMSGR", 14) == 0) { || memcmp(&packet->payload[172], "INVITE MSNMSGR", 14) == 0) {
@@ -484,17 +463,15 @@ static void ndpi_search_msn_tcp(struct ndpi_detection_module_struct *ndpi_struct
} }
return; return;
} }
/* For no /* For non port 443 flows exclude flow bitmask after first packet itself */
n port 443 flows exclude flow bitmask after first packet itself */
} }
NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE, "MSN tcp excluded.\n"); NDPI_LOG(NDPI_PROTOCOL_MSN, ndpi_struct, NDPI_LOG_TRACE, "MSN tcp excluded.\n");
ndpi_msn_exclude: ndpi_msn_exclude:
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_MSN); NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_MSN);
} }
/* search over UDP */
static void ndpi_search_msn_udp_misc(struct ndpi_detection_module_struct
static void ndpi_search_udp_msn_misc(struct ndpi_detection_module_struct
*ndpi_struct, struct ndpi_flow_struct *flow) *ndpi_struct, struct ndpi_flow_struct *flow)
{ {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
@@ -530,27 +507,26 @@ void ndpi_search_msn(struct ndpi_detection_module_struct *ndpi_struct, struct nd
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
/* this if request should always be true */ /* this if request should always be true */
if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_MSN) == 0) { if(NDPI_COMPARE_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_MSN) == 0) {
/* we deal with tcp now */ /* we deal with tcp now */
if (packet->tcp != NULL) { if(packet->tcp != NULL) {
/* msn can use http or ssl for connection. That's why every http, ssl and ukn packet must enter in the msn detection */ /* msn can use http or ssl for connection. That's why every http, ssl and ukn packet must enter in the msn detection */
/* the detection can swich out the http or the ssl detection. In this case we need not check those protocols */ /* the detection can swich out the http or the ssl detection. In this case we need not check those protocols */
// need to do the ceck when protocol == http too (POST /gateway ...) // need to do the ceck when protocol == http too (POST /gateway ...)
if (packet->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN if(packet->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN
#if defined(NDPI_PROTOCOL_HTTP) #ifdef NDPI_PROTOCOL_HTTP
|| packet->detected_protocol_stack[0] == NDPI_PROTOCOL_HTTP || packet->detected_protocol_stack[0] == NDPI_PROTOCOL_HTTP
#endif #endif
#if defined(NDPI_PROTOCOL_SSL) #ifdef NDPI_PROTOCOL_SSL
|| packet->detected_protocol_stack[0] == NDPI_PROTOCOL_SSL || packet->detected_protocol_stack[0] == NDPI_PROTOCOL_SSL
#endif #endif
#if defined(NDPI_PROTOCOL_STUN) #ifdef NDPI_PROTOCOL_STUN
|| packet->detected_protocol_stack[0] == NDPI_PROTOCOL_STUN || packet->detected_protocol_stack[0] == NDPI_PROTOCOL_STUN
#endif #endif
) { )
ndpi_search_msn_tcp(ndpi_struct, flow); ndpi_search_msn_tcp(ndpi_struct, flow);
}
} else if (packet->udp != NULL) { } else if (packet->udp != NULL) {
ndpi_search_udp_msn_misc(ndpi_struct, flow); ndpi_search_msn_udp_misc(ndpi_struct, flow);
} }
} }
} }
+2 -10
View File
@@ -1,8 +1,7 @@
/* /*
* ppstream.c * ppstream.c
* *
* Copyright (C) 2009-2011 by ipoque GmbH * Copyright (C) 2016 - ntop.org
* Copyright (C) 2011-15 - ntop.org
* *
* This file is part of nDPI, an open source deep packet inspection * This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH * library based on the OpenDPI and PACE technology by ipoque GmbH
@@ -21,9 +20,8 @@
* along with nDPI. If not, see <http://www.gnu.org/licenses/>. * along with nDPI. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
#include "ndpi_protocols.h" #include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_PPSTREAM #ifdef NDPI_PROTOCOL_PPSTREAM
static void ndpi_int_ppstream_add_connection(struct ndpi_detection_module_struct static void ndpi_int_ppstream_add_connection(struct ndpi_detection_module_struct
@@ -37,12 +35,6 @@ void ndpi_search_ppstream(struct ndpi_detection_module_struct
{ {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
// struct ndpi_id_struct *src=ndpi_struct->src;
// struct ndpi_id_struct *dst=ndpi_struct->dst;
/* check TCP Connections -> Videodata */ /* check TCP Connections -> Videodata */
if (packet->tcp != NULL) { if (packet->tcp != NULL) {
if (packet->payload_packet_len >= 60 && get_u_int32_t(packet->payload, 52) == 0 if (packet->payload_packet_len >= 60 && get_u_int32_t(packet->payload, 52) == 0
+18 -18
View File
@@ -27,30 +27,30 @@ void ndpi_search_vmware(struct ndpi_detection_module_struct *ndpi_struct, struct
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
/* Check whether this is an VMWARE flow */ /* Check whether this is an VMWARE flow */
if(packet->udp != NULL) { if(packet->udp != NULL){
if((packet->payload_packet_len == 66) if((packet->payload_packet_len == 66) &&
&& (ntohs(packet->udp->dest) == 902) (ntohs(packet->udp->dest) == 902) &&
&& ((packet->payload[0] & 0xFF) == 0xA4)) { ((packet->payload[0] & 0xFF) == 0xA4)){
NDPI_LOG(NDPI_PROTOCOL_VMWARE, ndpi_struct, NDPI_LOG_DEBUG, "Found vmware.\n"); NDPI_LOG(NDPI_PROTOCOL_VMWARE, ndpi_struct, NDPI_LOG_DEBUG, "Found vmware.\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_VMWARE, NDPI_PROTOCOL_UNKNOWN); ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_VMWARE, NDPI_PROTOCOL_UNKNOWN);
} return;
else {
NDPI_LOG(NDPI_PROTOCOL_VMWARE, ndpi_struct, NDPI_LOG_DEBUG, "exclude vmware.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_VMWARE);
} }
} }
NDPI_LOG(NDPI_PROTOCOL_VMWARE, ndpi_struct, NDPI_LOG_DEBUG, "exclude vmware.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_VMWARE);
} }
void init_vmware_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask) void init_vmware_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{ {
ndpi_set_bitmask_protocol_detection("VMWARE", ndpi_struct, detection_bitmask, *id, ndpi_set_bitmask_protocol_detection("VMWARE", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_VMWARE, NDPI_PROTOCOL_VMWARE,
ndpi_search_vmware, ndpi_search_vmware,
NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD, NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD,
SAVE_DETECTION_BITMASK_AS_UNKNOWN, SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK); ADD_TO_DETECTION_BITMASK);
*id += 1; *id += 1;
} }
#endif #endif
+7 -12
View File
@@ -1,8 +1,7 @@
/* /*
* xbox.c * xbox.c
* *
* Copyright (C) 2009-2011 by ipoque GmbH * Copyright (C) 2016 - ntop.org
* Copyright (C) 2011-15 - ntop.org
* *
* This file is part of nDPI, an open source deep packet inspection * This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH * library based on the OpenDPI and PACE technology by ipoque GmbH
@@ -22,8 +21,8 @@
* *
*/ */
#include "ndpi_protocols.h" #include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_XBOX #ifdef NDPI_PROTOCOL_XBOX
static void ndpi_int_xbox_add_connection(struct ndpi_detection_module_struct static void ndpi_int_xbox_add_connection(struct ndpi_detection_module_struct
@@ -41,13 +40,11 @@ void ndpi_search_xbox(struct ndpi_detection_module_struct *ndpi_struct, struct n
// struct ndpi_id_struct *dst = flow->dst; // struct ndpi_id_struct *dst = flow->dst;
/* /*
* THIS IS TH XBOX UDP DETCTION ONLY !!! * XBOX UDP DETCTION ONLY
* the xbox tcp detection is done by http code * the xbox TCP detection is done by http code
* this detection also works for asymmetric xbox udp traffic
*/ */
if(packet->udp != NULL) {
/* this detection also works for asymmetric xbox udp traffic */
if (packet->udp != NULL) {
u_int16_t dport = ntohs(packet->udp->dest); u_int16_t dport = ntohs(packet->udp->dest);
u_int16_t sport = ntohs(packet->udp->source); u_int16_t sport = ntohs(packet->udp->source);
@@ -88,11 +85,9 @@ void ndpi_search_xbox(struct ndpi_detection_module_struct *ndpi_struct, struct n
} }
/* exclude here all non matched udp traffic, exclude here tcp only if http has been excluded, because xbox could use http */ /* exclude here all non matched udp traffic, exclude here tcp only if http has been excluded, because xbox could use http */
if (packet->tcp == NULL
#ifdef NDPI_PROTOCOL_HTTP #ifdef NDPI_PROTOCOL_HTTP
|| NDPI_COMPARE_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_HTTP) != 0 if(NDPI_COMPARE_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_HTTP) != 0) {
#endif #endif
) {
NDPI_LOG(NDPI_PROTOCOL_XBOX, ndpi_struct, NDPI_LOG_DEBUG, "xbox udp excluded.\n"); NDPI_LOG(NDPI_PROTOCOL_XBOX, ndpi_struct, NDPI_LOG_DEBUG, "xbox udp excluded.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_XBOX); NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_XBOX);
} }
+2 -2
View File
@@ -88,8 +88,8 @@ void ndpi_search_zmq(struct ndpi_detection_module_struct *ndpi_struct, struct nd
NDPI_LOG(NDPI_PROTOCOL_ZMQ, ndpi_struct, NDPI_LOG_TRACE, "ZMQ detection...\n"); NDPI_LOG(NDPI_PROTOCOL_ZMQ, ndpi_struct, NDPI_LOG_TRACE, "ZMQ detection...\n");
/* skip marked packets */ /* skip marked packets */
if (packet->detected_protocol_stack[0] != NDPI_PROTOCOL_ZMQ) { if(packet->detected_protocol_stack[0] != NDPI_PROTOCOL_ZMQ) {
if (packet->tcp_retransmission == 0) { if(packet->tcp && packet->tcp_retransmission == 0) {
ndpi_check_zmq(ndpi_struct, flow); ndpi_check_zmq(ndpi_struct, flow);
} }
} }