Various optimizations to reduce not-necessary calls
Optimized various UDP dissectors Removed dead protocols such as pando and pplive
This commit is contained in:
@@ -82,7 +82,7 @@ typedef enum {
|
||||
NDPI_PROTOCOL_RTSP = 50,
|
||||
NDPI_PROTOCOL_MAIL_IMAPS = 51,
|
||||
NDPI_PROTOCOL_ICECAST = 52,
|
||||
NDPI_PROTOCOL_PPLIVE = 53, /* Tomasz Bujlow <tomasz@skatnet.dk> */
|
||||
NDPI_PROTOCOL_FREE_53 = 53,
|
||||
NDPI_PROTOCOL_PPSTREAM = 54,
|
||||
NDPI_PROTOCOL_ZATTOO = 55,
|
||||
NDPI_PROTOCOL_SHOUTCAST = 56,
|
||||
@@ -212,7 +212,7 @@ typedef enum {
|
||||
NDPI_PROTOCOL_CNN = 180, /* Tomasz Bujlow <tomasz@skatnet.dk> */
|
||||
NDPI_PROTOCOL_MEGACO = 181, /* Gianluca Costa <g.costa@xplico.org> */
|
||||
NDPI_PROTOCOL_REDIS = 182,
|
||||
NDPI_PROTOCOL_PANDO = 183, /* Tomasz Bujlow <tomasz@skatnet.dk> */
|
||||
NDPI_PROTOCOL_FREE_183 = 183,
|
||||
NDPI_PROTOCOL_VHUA = 184,
|
||||
NDPI_PROTOCOL_TELEGRAM = 185, /* Gianluca Costa <g.costa@xplico.org> */
|
||||
NDPI_PROTOCOL_VEVO = 186,
|
||||
|
||||
@@ -119,9 +119,7 @@ void init_ntp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int3
|
||||
void init_openft_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_openvpn_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_oracle_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_pando_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_postgres_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_pplive_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_ppstream_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_pptp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_qq_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
|
||||
@@ -860,6 +860,7 @@ struct ndpi_detection_module_struct;
|
||||
struct ndpi_flow_struct;
|
||||
|
||||
struct ndpi_call_function_struct {
|
||||
u_int16_t ndpi_protocol_id;
|
||||
NDPI_PROTOCOL_BITMASK detection_bitmask;
|
||||
NDPI_PROTOCOL_BITMASK excluded_protocol_bitmask;
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_SIZE ndpi_selection_bitmask;
|
||||
@@ -1163,7 +1164,7 @@ struct ndpi_flow_struct {
|
||||
|
||||
/* init parameter, internal used to set up timestamp,... */
|
||||
u_int16_t guessed_protocol_id, guessed_host_protocol_id, guessed_category, guessed_header_category;
|
||||
u_int8_t l4_proto, protocol_id_already_guessed:1, host_already_guessed:1,
|
||||
u_int8_t l4_proto, protocol_id_already_guessed:1, host_already_guessed:1, fail_with_unknown:1,
|
||||
init_finished:1, setup_packet_direction:1, packet_direction:1, check_extra_packets:1;
|
||||
|
||||
/*
|
||||
@@ -1330,9 +1331,6 @@ struct ndpi_flow_struct {
|
||||
/* NDPI_PROTOCOL_DIRECTCONNECT */
|
||||
u_int8_t directconnect_stage:2; // 0 - 1
|
||||
|
||||
/* NDPI_PROTOCOL_YAHOO */
|
||||
u_int8_t sip_yahoo_voice:1;
|
||||
|
||||
/* NDPI_PROTOCOL_HTTP */
|
||||
u_int8_t http_detected:1;
|
||||
|
||||
@@ -1366,15 +1364,9 @@ struct ndpi_flow_struct {
|
||||
/* NDPI_PROTOCOL_RTMP */
|
||||
u_int8_t rtmp_stage:2;
|
||||
|
||||
/* NDPI_PROTOCOL_PANDO */
|
||||
u_int8_t pando_stage:3;
|
||||
|
||||
/* NDPI_PROTOCOL_STEAM */
|
||||
u_int16_t steam_stage:3, steam_stage1:3, steam_stage2:2, steam_stage3:2;
|
||||
|
||||
/* NDPI_PROTOCOL_PPLIVE */
|
||||
u_int8_t pplive_stage1:3, pplive_stage2:2, pplive_stage3:2;
|
||||
|
||||
/* NDPI_PROTOCOL_STARCRAFT */
|
||||
u_int8_t starcraft_udp_stage : 3; // 0-7
|
||||
|
||||
|
||||
+194
-165
@@ -899,8 +899,8 @@ static void ndpi_init_protocol_defaults(struct ndpi_detection_module_struct *ndp
|
||||
no_master, no_master, "IceCast", NDPI_PROTOCOL_CATEGORY_MEDIA,
|
||||
ndpi_build_default_ports(ports_a, 0, 0, 0, 0, 0) /* TCP */,
|
||||
ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0) /* UDP */);
|
||||
ndpi_set_proto_defaults(ndpi_str, NDPI_PROTOCOL_FUN, NDPI_PROTOCOL_PPLIVE, 0 /* can_have_a_subprotocol */,
|
||||
no_master, no_master, "PPLive", NDPI_PROTOCOL_CATEGORY_MEDIA,
|
||||
ndpi_set_proto_defaults(ndpi_str, NDPI_PROTOCOL_FUN, NDPI_PROTOCOL_FREE_53, 0 /* can_have_a_subprotocol */,
|
||||
no_master, no_master, "FREE53", NDPI_PROTOCOL_CATEGORY_MEDIA,
|
||||
ndpi_build_default_ports(ports_a, 0, 0, 0, 0, 0) /* TCP */,
|
||||
ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0) /* UDP */);
|
||||
ndpi_set_proto_defaults(ndpi_str, NDPI_PROTOCOL_FUN, NDPI_PROTOCOL_PPSTREAM, 0 /* can_have_a_subprotocol */,
|
||||
@@ -1351,8 +1351,8 @@ static void ndpi_init_protocol_defaults(struct ndpi_detection_module_struct *ndp
|
||||
no_master, no_master, "RTMP", NDPI_PROTOCOL_CATEGORY_MEDIA,
|
||||
ndpi_build_default_ports(ports_a, 1935, 0, 0, 0, 0), /* TCP */
|
||||
ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0)); /* UDP */
|
||||
ndpi_set_proto_defaults(ndpi_str, NDPI_PROTOCOL_FUN, NDPI_PROTOCOL_PANDO, 0 /* can_have_a_subprotocol */, no_master,
|
||||
no_master, "Pando_Media_Booster", NDPI_PROTOCOL_CATEGORY_WEB,
|
||||
ndpi_set_proto_defaults(ndpi_str, NDPI_PROTOCOL_FUN, NDPI_PROTOCOL_FREE_183, 0 /* can_have_a_subprotocol */, no_master,
|
||||
no_master, "FREE183", NDPI_PROTOCOL_CATEGORY_WEB,
|
||||
ndpi_build_default_ports(ports_a, 0, 0, 0, 0, 0), /* TCP */
|
||||
ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0)); /* UDP */
|
||||
ndpi_set_proto_defaults(ndpi_str, NDPI_PROTOCOL_ACCEPTABLE, NDPI_PROTOCOL_MEGACO, 0 /* can_have_a_subprotocol */,
|
||||
@@ -1503,9 +1503,9 @@ static void ndpi_init_protocol_defaults(struct ndpi_detection_module_struct *ndp
|
||||
ndpi_build_default_ports(ports_a, 0, 0, 0, 0, 0) /* TCP */,
|
||||
ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0) /* UDP */);
|
||||
ndpi_set_proto_defaults(ndpi_str, NDPI_PROTOCOL_ACCEPTABLE, NDPI_PROTOCOL_SOAP, 1 /* no subprotocol */,
|
||||
no_master, no_master, "SOAP", NDPI_PROTOCOL_CATEGORY_RPC,
|
||||
ndpi_build_default_ports(ports_a, 0, 0, 0, 0, 0) /* TCP */,
|
||||
ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0) /* UDP */);
|
||||
no_master, no_master, "SOAP", NDPI_PROTOCOL_CATEGORY_RPC,
|
||||
ndpi_build_default_ports(ports_a, 0, 0, 0, 0, 0) /* TCP */,
|
||||
ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0) /* UDP */);
|
||||
|
||||
#ifdef CUSTOM_NDPI_PROTOCOLS
|
||||
#include "../../../nDPI-custom/custom_ndpi_main.c"
|
||||
@@ -1858,112 +1858,112 @@ void set_ndpi_debug_function(struct ndpi_detection_module_struct *ndpi_str, ndpi
|
||||
|
||||
/* Keep it in order and in sync with ndpi_protocol_category_t in ndpi_typedefs.h */
|
||||
static const char *categories[] = {
|
||||
"Unspecified",
|
||||
"Media",
|
||||
"VPN",
|
||||
"Email",
|
||||
"DataTransfer",
|
||||
"Web",
|
||||
"SocialNetwork",
|
||||
"Download-FileTransfer-FileSharing",
|
||||
"Game",
|
||||
"Chat",
|
||||
"VoIP",
|
||||
"Database",
|
||||
"RemoteAccess",
|
||||
"Cloud",
|
||||
"Network",
|
||||
"Collaborative",
|
||||
"RPC",
|
||||
"Streaming",
|
||||
"System",
|
||||
"SoftwareUpdate",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"Music",
|
||||
"Video",
|
||||
"Shopping",
|
||||
"Productivity",
|
||||
"FileSharing",
|
||||
"ConnectivityCheck",
|
||||
"IoT-Scada",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"Mining", /* 99 */
|
||||
"Malware",
|
||||
"Advertisement",
|
||||
"Banned_Site",
|
||||
"Site_Unavailable",
|
||||
"Allowed_Site",
|
||||
"Antimalware",
|
||||
"Unspecified",
|
||||
"Media",
|
||||
"VPN",
|
||||
"Email",
|
||||
"DataTransfer",
|
||||
"Web",
|
||||
"SocialNetwork",
|
||||
"Download-FileTransfer-FileSharing",
|
||||
"Game",
|
||||
"Chat",
|
||||
"VoIP",
|
||||
"Database",
|
||||
"RemoteAccess",
|
||||
"Cloud",
|
||||
"Network",
|
||||
"Collaborative",
|
||||
"RPC",
|
||||
"Streaming",
|
||||
"System",
|
||||
"SoftwareUpdate",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"Music",
|
||||
"Video",
|
||||
"Shopping",
|
||||
"Productivity",
|
||||
"FileSharing",
|
||||
"ConnectivityCheck",
|
||||
"IoT-Scada",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"Mining", /* 99 */
|
||||
"Malware",
|
||||
"Advertisement",
|
||||
"Banned_Site",
|
||||
"Site_Unavailable",
|
||||
"Allowed_Site",
|
||||
"Antimalware",
|
||||
};
|
||||
|
||||
/* ******************************************************************** */
|
||||
@@ -2849,7 +2849,8 @@ void ndpi_set_bitmask_protocol_detection(char *label, struct ndpi_detection_modu
|
||||
*/
|
||||
ndpi_str->proto_defaults[ndpi_protocol_id].protoIdx = idx;
|
||||
ndpi_str->proto_defaults[ndpi_protocol_id].func = ndpi_str->callback_buffer[idx].func = func;
|
||||
|
||||
ndpi_str->callback_buffer[idx].ndpi_protocol_id = ndpi_protocol_id;
|
||||
|
||||
/*
|
||||
Set ndpi_selection_bitmask for protocol
|
||||
*/
|
||||
@@ -2975,9 +2976,6 @@ void ndpi_set_protocol_detection_bitmask2(struct ndpi_detection_module_struct *n
|
||||
/* PPSTREAM */
|
||||
init_ppstream_dissector(ndpi_str, &a, detection_bitmask);
|
||||
|
||||
/* PPLIVE */
|
||||
init_pplive_dissector(ndpi_str, &a, detection_bitmask);
|
||||
|
||||
/* IAX */
|
||||
init_iax_dissector(ndpi_str, &a, detection_bitmask);
|
||||
|
||||
@@ -3209,9 +3207,6 @@ void ndpi_set_protocol_detection_bitmask2(struct ndpi_detection_module_struct *n
|
||||
/* FTP_DATA */
|
||||
init_ftp_data_dissector(ndpi_str, &a, detection_bitmask);
|
||||
|
||||
/* PANDO */
|
||||
init_pando_dissector(ndpi_str, &a, detection_bitmask);
|
||||
|
||||
/* MEGACO */
|
||||
init_megaco_dissector(ndpi_str, &a, detection_bitmask);
|
||||
|
||||
@@ -3705,9 +3700,12 @@ static int ndpi_init_packet_header(struct ndpi_detection_module_struct *ndpi_str
|
||||
backup1 = flow->guessed_protocol_id;
|
||||
backup2 = flow->guessed_host_protocol_id;
|
||||
memset(flow, 0, sizeof(*(flow)));
|
||||
|
||||
/* Restore pointers */
|
||||
flow->num_processed_pkts = backup;
|
||||
flow->guessed_protocol_id = backup1;
|
||||
flow->guessed_host_protocol_id = backup2;
|
||||
flow->packet.tcp = (struct ndpi_tcphdr *) l4ptr;
|
||||
|
||||
NDPI_LOG_DBG(ndpi_str, "tcp syn packet for unknown protocol, reset detection state\n");
|
||||
}
|
||||
@@ -3857,13 +3855,11 @@ void ndpi_connection_tracking(struct ndpi_detection_module_struct *ndpi_str,
|
||||
|
||||
/* ************************************************ */
|
||||
|
||||
void check_ndpi_other_flow_func(struct ndpi_detection_module_struct *ndpi_str, struct ndpi_flow_struct *flow,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_SIZE *ndpi_selection_packet) {
|
||||
if(!flow)
|
||||
return;
|
||||
|
||||
u_int32_t check_ndpi_other_flow_func(struct ndpi_detection_module_struct *ndpi_str,
|
||||
struct ndpi_flow_struct *flow,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_SIZE *ndpi_selection_packet) {
|
||||
void *func = NULL;
|
||||
u_int32_t a;
|
||||
u_int32_t a, num_calls = 0;
|
||||
u_int16_t proto_index = ndpi_str->proto_defaults[flow->guessed_protocol_id].protoIdx;
|
||||
int16_t proto_id = ndpi_str->proto_defaults[flow->guessed_protocol_id].protoId;
|
||||
NDPI_PROTOCOL_BITMASK detection_bitmask;
|
||||
@@ -3879,7 +3875,7 @@ void check_ndpi_other_flow_func(struct ndpi_detection_module_struct *ndpi_str, s
|
||||
if((flow->guessed_protocol_id != NDPI_PROTOCOL_UNKNOWN) &&
|
||||
(ndpi_str->proto_defaults[flow->guessed_protocol_id].func != NULL))
|
||||
ndpi_str->proto_defaults[flow->guessed_protocol_id].func(ndpi_str, flow),
|
||||
func = ndpi_str->proto_defaults[flow->guessed_protocol_id].func;
|
||||
func = ndpi_str->proto_defaults[flow->guessed_protocol_id].func, num_calls++;
|
||||
}
|
||||
|
||||
for (a = 0; a < ndpi_str->callback_buffer_size_non_tcp_udp; a++) {
|
||||
@@ -3890,20 +3886,23 @@ void check_ndpi_other_flow_func(struct ndpi_detection_module_struct *ndpi_str, s
|
||||
ndpi_str->callback_buffer_non_tcp_udp[a].excluded_protocol_bitmask) == 0 &&
|
||||
NDPI_BITMASK_COMPARE(ndpi_str->callback_buffer_non_tcp_udp[a].detection_bitmask, detection_bitmask) != 0) {
|
||||
if(ndpi_str->callback_buffer_non_tcp_udp[a].func != NULL)
|
||||
ndpi_str->callback_buffer_non_tcp_udp[a].func(ndpi_str, flow);
|
||||
ndpi_str->callback_buffer_non_tcp_udp[a].func(ndpi_str, flow), num_calls++;
|
||||
|
||||
if(flow->detected_protocol_stack[0] != NDPI_PROTOCOL_UNKNOWN)
|
||||
break; /* Stop after detecting the first protocol */
|
||||
}
|
||||
}
|
||||
|
||||
return(num_calls);
|
||||
}
|
||||
|
||||
/* ************************************************ */
|
||||
|
||||
void check_ndpi_udp_flow_func(struct ndpi_detection_module_struct *ndpi_str, struct ndpi_flow_struct *flow,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_SIZE *ndpi_selection_packet) {
|
||||
static u_int32_t check_ndpi_udp_flow_func(struct ndpi_detection_module_struct *ndpi_str,
|
||||
struct ndpi_flow_struct *flow,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_SIZE *ndpi_selection_packet) {
|
||||
void *func = NULL;
|
||||
u_int32_t a;
|
||||
u_int32_t a, num_calls = 0;
|
||||
u_int16_t proto_index = ndpi_str->proto_defaults[flow->guessed_protocol_id].protoIdx;
|
||||
int16_t proto_id = ndpi_str->proto_defaults[flow->guessed_protocol_id].protoId;
|
||||
NDPI_PROTOCOL_BITMASK detection_bitmask;
|
||||
@@ -3919,7 +3918,7 @@ void check_ndpi_udp_flow_func(struct ndpi_detection_module_struct *ndpi_str, str
|
||||
if((flow->guessed_protocol_id != NDPI_PROTOCOL_UNKNOWN) &&
|
||||
(ndpi_str->proto_defaults[flow->guessed_protocol_id].func != NULL))
|
||||
ndpi_str->proto_defaults[flow->guessed_protocol_id].func(ndpi_str, flow),
|
||||
func = ndpi_str->proto_defaults[flow->guessed_protocol_id].func;
|
||||
func = ndpi_str->proto_defaults[flow->guessed_protocol_id].func, num_calls++;
|
||||
}
|
||||
|
||||
if(flow->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN) {
|
||||
@@ -3930,30 +3929,44 @@ void check_ndpi_udp_flow_func(struct ndpi_detection_module_struct *ndpi_str, str
|
||||
NDPI_BITMASK_COMPARE(flow->excluded_protocol_bitmask,
|
||||
ndpi_str->callback_buffer_udp[a].excluded_protocol_bitmask) == 0 &&
|
||||
NDPI_BITMASK_COMPARE(ndpi_str->callback_buffer_udp[a].detection_bitmask, detection_bitmask) != 0) {
|
||||
ndpi_str->callback_buffer_udp[a].func(ndpi_str, flow);
|
||||
ndpi_str->callback_buffer_udp[a].func(ndpi_str, flow), num_calls++;
|
||||
|
||||
// NDPI_LOG_DBG(ndpi_str, "[UDP,CALL] dissector of protocol as callback_buffer idx = %d\n",a);
|
||||
|
||||
#ifdef DEBUG_UDP_CALLS
|
||||
{
|
||||
char buf[64];
|
||||
u_int16_t proto_id = ndpi_str->callback_buffer_udp[a].ndpi_protocol_id;
|
||||
ndpi_protocol proto = { proto_id, proto_id, 0 };
|
||||
printf("-> [UDP,CALL] dissector of protocol as callback_buffer idx = %d / %s\n",
|
||||
proto_id, ndpi_protocol2name(ndpi_str, proto, buf, sizeof(buf)));
|
||||
}
|
||||
#endif
|
||||
|
||||
if(flow->detected_protocol_stack[0] != NDPI_PROTOCOL_UNKNOWN)
|
||||
break; /* Stop after detecting the first protocol */
|
||||
} else if(_ndpi_debug_callbacks)
|
||||
NDPI_LOG_DBG2(ndpi_str, "[UDP,SKIP] dissector of protocol as callback_buffer idx = %d\n", a);
|
||||
}
|
||||
}
|
||||
} else
|
||||
num_calls = 1;
|
||||
|
||||
return(num_calls);
|
||||
}
|
||||
|
||||
/* ************************************************ */
|
||||
|
||||
void check_ndpi_tcp_flow_func(struct ndpi_detection_module_struct *ndpi_str,
|
||||
struct ndpi_flow_struct *flow,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_SIZE *ndpi_selection_packet) {
|
||||
static u_int32_t check_ndpi_tcp_flow_func(struct ndpi_detection_module_struct *ndpi_str,
|
||||
struct ndpi_flow_struct *flow,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_SIZE *ndpi_selection_packet) {
|
||||
void *func = NULL;
|
||||
u_int32_t a;
|
||||
u_int32_t a, num_calls = 0;
|
||||
u_int16_t proto_index = ndpi_str->proto_defaults[flow->guessed_protocol_id].protoIdx;
|
||||
int16_t proto_id = ndpi_str->proto_defaults[flow->guessed_protocol_id].protoId;
|
||||
NDPI_PROTOCOL_BITMASK detection_bitmask;
|
||||
|
||||
NDPI_SAVE_AS_BITMASK(detection_bitmask, flow->packet.detected_protocol_stack[0]);
|
||||
|
||||
|
||||
if(flow->packet.payload_packet_len != 0) {
|
||||
if((proto_id != NDPI_PROTOCOL_UNKNOWN) &&
|
||||
NDPI_BITMASK_COMPARE(flow->excluded_protocol_bitmask,
|
||||
@@ -3964,7 +3977,7 @@ void check_ndpi_tcp_flow_func(struct ndpi_detection_module_struct *ndpi_str,
|
||||
if((flow->guessed_protocol_id != NDPI_PROTOCOL_UNKNOWN) &&
|
||||
(ndpi_str->proto_defaults[flow->guessed_protocol_id].func != NULL))
|
||||
ndpi_str->proto_defaults[flow->guessed_protocol_id].func(ndpi_str, flow),
|
||||
func = ndpi_str->proto_defaults[flow->guessed_protocol_id].func;
|
||||
func = ndpi_str->proto_defaults[flow->guessed_protocol_id].func, num_calls++;
|
||||
}
|
||||
|
||||
if(flow->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN) {
|
||||
@@ -3976,15 +3989,17 @@ void check_ndpi_tcp_flow_func(struct ndpi_detection_module_struct *ndpi_str,
|
||||
ndpi_str->callback_buffer_tcp_payload[a].excluded_protocol_bitmask) == 0 &&
|
||||
NDPI_BITMASK_COMPARE(ndpi_str->callback_buffer_tcp_payload[a].detection_bitmask,
|
||||
detection_bitmask) != 0) {
|
||||
ndpi_str->callback_buffer_tcp_payload[a].func(ndpi_str, flow);
|
||||
|
||||
ndpi_str->callback_buffer_tcp_payload[a].func(ndpi_str, flow), num_calls++;
|
||||
if(flow->detected_protocol_stack[0] != NDPI_PROTOCOL_UNKNOWN)
|
||||
break; /* Stop after detecting the first protocol */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* no payload */
|
||||
|
||||
num_calls = 1;
|
||||
|
||||
if((proto_id != NDPI_PROTOCOL_UNKNOWN) &&
|
||||
NDPI_BITMASK_COMPARE(flow->excluded_protocol_bitmask,
|
||||
ndpi_str->callback_buffer[proto_index].excluded_protocol_bitmask) == 0 &&
|
||||
@@ -3996,7 +4011,7 @@ void check_ndpi_tcp_flow_func(struct ndpi_detection_module_struct *ndpi_str,
|
||||
((ndpi_str->callback_buffer[flow->guessed_protocol_id].ndpi_selection_bitmask &
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_HAS_PAYLOAD) == 0))
|
||||
ndpi_str->proto_defaults[flow->guessed_protocol_id].func(ndpi_str, flow),
|
||||
func = ndpi_str->proto_defaults[flow->guessed_protocol_id].func;
|
||||
func = ndpi_str->proto_defaults[flow->guessed_protocol_id].func, num_calls++;
|
||||
}
|
||||
|
||||
for (a = 0; a < ndpi_str->callback_buffer_size_tcp_no_payload; a++) {
|
||||
@@ -4007,25 +4022,29 @@ void check_ndpi_tcp_flow_func(struct ndpi_detection_module_struct *ndpi_str,
|
||||
ndpi_str->callback_buffer_tcp_no_payload[a].excluded_protocol_bitmask) == 0 &&
|
||||
NDPI_BITMASK_COMPARE(ndpi_str->callback_buffer_tcp_no_payload[a].detection_bitmask,
|
||||
detection_bitmask) != 0) {
|
||||
ndpi_str->callback_buffer_tcp_no_payload[a].func(ndpi_str, flow);
|
||||
|
||||
ndpi_str->callback_buffer_tcp_no_payload[a].func(ndpi_str, flow), num_calls++;
|
||||
if(flow->detected_protocol_stack[0] != NDPI_PROTOCOL_UNKNOWN)
|
||||
break; /* Stop after detecting the first protocol */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(num_calls);
|
||||
}
|
||||
|
||||
/* ********************************************************************************* */
|
||||
|
||||
void ndpi_check_flow_func(struct ndpi_detection_module_struct *ndpi_str, struct ndpi_flow_struct *flow,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_SIZE *ndpi_selection_packet) {
|
||||
if(flow->packet.tcp != NULL)
|
||||
check_ndpi_tcp_flow_func(ndpi_str, flow, ndpi_selection_packet);
|
||||
u_int32_t ndpi_check_flow_func(struct ndpi_detection_module_struct *ndpi_str,
|
||||
struct ndpi_flow_struct *flow,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_SIZE *ndpi_selection_packet) {
|
||||
if(!flow)
|
||||
return(0);
|
||||
else if(flow->packet.tcp != NULL)
|
||||
return(check_ndpi_tcp_flow_func(ndpi_str, flow, ndpi_selection_packet));
|
||||
else if(flow->packet.udp != NULL)
|
||||
check_ndpi_udp_flow_func(ndpi_str, flow, ndpi_selection_packet);
|
||||
return(check_ndpi_udp_flow_func(ndpi_str, flow, ndpi_selection_packet));
|
||||
else
|
||||
check_ndpi_other_flow_func(ndpi_str, flow, ndpi_selection_packet);
|
||||
return(check_ndpi_other_flow_func(ndpi_str, flow, ndpi_selection_packet));
|
||||
}
|
||||
|
||||
/* ********************************************************************************* */
|
||||
@@ -4478,8 +4497,8 @@ static void ndpi_reconcile_protocols(struct ndpi_detection_module_struct *ndpi_s
|
||||
struct ndpi_flow_struct *flow,
|
||||
ndpi_protocol *ret) {
|
||||
/*
|
||||
Skype for a host doing MS Teams means MS Teams
|
||||
(MS Teams uses Skype as transport protocol for voice/video)
|
||||
Skype for a host doing MS Teams means MS Teams
|
||||
(MS Teams uses Skype as transport protocol for voice/video)
|
||||
*/
|
||||
if(flow) {
|
||||
/* Do not go for DNS when there is an application protocol. Example DNS.Apple */
|
||||
@@ -4536,7 +4555,7 @@ static void ndpi_reconcile_protocols(struct ndpi_detection_module_struct *ndpi_s
|
||||
NDPI_SET_BIT(flow->risk, NDPI_UNSAFE_PROTOCOL);
|
||||
break;
|
||||
default:
|
||||
/* Nothign to do */
|
||||
/* Nothing to do */
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -4550,9 +4569,14 @@ ndpi_protocol ndpi_detection_process_packet(struct ndpi_detection_module_struct
|
||||
const unsigned short packetlen, const u_int64_t current_time_ms,
|
||||
struct ndpi_id_struct *src, struct ndpi_id_struct *dst) {
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_SIZE ndpi_selection_packet;
|
||||
u_int32_t a;
|
||||
ndpi_protocol ret = {NDPI_PROTOCOL_UNKNOWN, NDPI_PROTOCOL_UNKNOWN, NDPI_PROTOCOL_CATEGORY_UNSPECIFIED};
|
||||
|
||||
u_int32_t a, num_calls = 0;
|
||||
ndpi_protocol ret = { NDPI_PROTOCOL_UNKNOWN, NDPI_PROTOCOL_UNKNOWN, NDPI_PROTOCOL_CATEGORY_UNSPECIFIED };
|
||||
|
||||
if(flow->fail_with_unknown) {
|
||||
// printf("%s(): FAIL_WITH_UNKNOWN\n", __FUNCTION__);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
if(ndpi_str->ndpi_log_level >= NDPI_LOG_TRACE)
|
||||
NDPI_LOG(flow ? flow->detected_protocol_stack[0] : NDPI_PROTOCOL_UNKNOWN, ndpi_str, NDPI_LOG_TRACE,
|
||||
"START packet processing\n");
|
||||
@@ -4565,7 +4589,8 @@ ndpi_protocol ndpi_detection_process_packet(struct ndpi_detection_module_struct
|
||||
flow->num_processed_pkts++;
|
||||
|
||||
/* Init default */
|
||||
ret.master_protocol = flow->detected_protocol_stack[1], ret.app_protocol = flow->detected_protocol_stack[0];
|
||||
ret.master_protocol = flow->detected_protocol_stack[1],
|
||||
ret.app_protocol = flow->detected_protocol_stack[0];
|
||||
|
||||
if(flow->server_id == NULL)
|
||||
flow->server_id = dst; /* Default */
|
||||
@@ -4574,7 +4599,8 @@ ndpi_protocol ndpi_detection_process_packet(struct ndpi_detection_module_struct
|
||||
if(flow->check_extra_packets) {
|
||||
ndpi_process_extra_packet(ndpi_str, flow, packet, packetlen, current_time_ms, src, dst);
|
||||
/* Update in case of new match */
|
||||
ret.master_protocol = flow->detected_protocol_stack[1], ret.app_protocol = flow->detected_protocol_stack[0],
|
||||
ret.master_protocol = flow->detected_protocol_stack[1],
|
||||
ret.app_protocol = flow->detected_protocol_stack[0],
|
||||
ret.category = flow->category;
|
||||
goto invalidate_ptr;
|
||||
} else
|
||||
@@ -4716,13 +4742,13 @@ ndpi_protocol ndpi_detection_process_packet(struct ndpi_detection_module_struct
|
||||
/* This is a custom protocol and it has priority over everything else */
|
||||
ret.master_protocol = flow->guessed_protocol_id, ret.app_protocol = flow->guessed_host_protocol_id;
|
||||
|
||||
ndpi_check_flow_func(ndpi_str, flow, &ndpi_selection_packet);
|
||||
num_calls = ndpi_check_flow_func(ndpi_str, flow, &ndpi_selection_packet);
|
||||
ndpi_fill_protocol_category(ndpi_str, flow, &ret);
|
||||
goto invalidate_ptr;
|
||||
}
|
||||
|
||||
ndpi_check_flow_func(ndpi_str, flow, &ndpi_selection_packet);
|
||||
|
||||
num_calls = ndpi_check_flow_func(ndpi_str, flow, &ndpi_selection_packet);
|
||||
|
||||
a = flow->packet.detected_protocol_stack[0];
|
||||
if(NDPI_COMPARE_PROTOCOL_TO_BITMASK(ndpi_str->detection_bitmask, a) == 0)
|
||||
a = NDPI_PROTOCOL_UNKNOWN;
|
||||
@@ -4835,6 +4861,9 @@ ndpi_protocol ndpi_detection_process_packet(struct ndpi_detection_module_struct
|
||||
|
||||
ndpi_reconcile_protocols(ndpi_str, flow, &ret);
|
||||
|
||||
if(num_calls == 0)
|
||||
flow->fail_with_unknown = 1;
|
||||
|
||||
invalidate_ptr:
|
||||
/*
|
||||
Invalidate packet memory to avoid accessing the pointers below
|
||||
@@ -5639,7 +5668,7 @@ void ndpi_packet_dst_ip_get(const struct ndpi_packet_struct *packet, ndpi_ip_add
|
||||
u_int8_t ndpi_is_ipv6(const ndpi_ip_addr_t *ip) {
|
||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
||||
return(ip->ipv6.u6_addr.u6_addr32[1] != 0 || ip->ipv6.u6_addr.u6_addr32[2] != 0 ||
|
||||
ip->ipv6.u6_addr.u6_addr32[3] != 0);
|
||||
ip->ipv6.u6_addr.u6_addr32[3] != 0);
|
||||
#else
|
||||
return(0);
|
||||
#endif
|
||||
@@ -6213,7 +6242,7 @@ u_int16_t ndpi_match_content_subprotocol(struct ndpi_detection_module_struct *nd
|
||||
ndpi_protocol_match_result *ret_match,
|
||||
u_int16_t master_protocol_id) {
|
||||
return(ndpi_automa_match_string_subprotocol(ndpi_str, flow, string_to_match, string_to_match_len,
|
||||
master_protocol_id, ret_match, 0));
|
||||
master_protocol_id, ret_match, 0));
|
||||
}
|
||||
|
||||
/* ****************************************************** */
|
||||
|
||||
@@ -389,10 +389,8 @@ void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
|
||||
/* This is broadcast */
|
||||
if(packet->iph) {
|
||||
|
||||
if((packet->iph->saddr == 0xFFFFFFFF) || (packet->iph->daddr == 0xFFFFFFFF))
|
||||
goto exclude_bt;
|
||||
|
||||
|
||||
if(packet->udp) {
|
||||
u_int16_t sport = ntohs(packet->udp->source), dport = ntohs(packet->udp->dest);
|
||||
@@ -417,9 +415,11 @@ void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
char *bt_search = "BT-SEARCH * HTTP/1.1\r\n";
|
||||
|
||||
if((ntohs(packet->udp->source) < 1024)
|
||||
|| (ntohs(packet->udp->dest) < 1024) /* High ports only */)
|
||||
|| (ntohs(packet->udp->dest) < 1024) /* High ports only */) {
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
Check for uTP http://www.bittorrent.org/beps/bep_0029.html
|
||||
|
||||
@@ -464,7 +464,7 @@ void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
|
||||
flow->bittorrent_stage++;
|
||||
|
||||
if(flow->bittorrent_stage < 10) {
|
||||
if(flow->bittorrent_stage < 5) {
|
||||
/* We have detected bittorrent but we need to wait until we get a hash */
|
||||
|
||||
if(packet->payload_packet_len > 19 /* min size */) {
|
||||
@@ -489,6 +489,7 @@ void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ void ndpi_search_ciscovpn(struct ndpi_detection_module_struct *ndpi_struct, stru
|
||||
tsport = ntohs(packet->tcp->source), tdport = ntohs(packet->tcp->dest);
|
||||
NDPI_LOG_DBG2(ndpi_struct, "calculated CISCOVPN over tcp ports\n");
|
||||
}
|
||||
|
||||
if(packet->udp != NULL) {
|
||||
usport = ntohs(packet->udp->source), udport = ntohs(packet->udp->dest);
|
||||
NDPI_LOG_DBG2(ndpi_struct, "calculated CISCOVPN over udp ports\n");
|
||||
@@ -107,8 +108,6 @@ void ndpi_search_ciscovpn(struct ndpi_detection_module_struct *ndpi_struct, stru
|
||||
)
|
||||
)
|
||||
{
|
||||
|
||||
|
||||
/* This is a good query fe577e2b */
|
||||
NDPI_LOG_INFO(ndpi_struct, "found CISCOVPN\n");
|
||||
ndpi_int_ciscovpn_add_connection(ndpi_struct, flow);
|
||||
@@ -130,7 +129,7 @@ void ndpi_search_ciscovpn(struct ndpi_detection_module_struct *ndpi_struct, stru
|
||||
return;
|
||||
}
|
||||
|
||||
if(flow->num_processed_pkts > 10)
|
||||
if(flow->num_processed_pkts > 5)
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
}
|
||||
|
||||
|
||||
+47
-32
@@ -29,8 +29,8 @@
|
||||
void ndpi_search_csgo(struct ndpi_detection_module_struct* ndpi_struct, struct ndpi_flow_struct* flow) {
|
||||
struct ndpi_packet_struct* packet = &flow->packet;
|
||||
|
||||
if (packet->udp != NULL) {
|
||||
if (packet->payload_packet_len < sizeof(uint32_t)) {
|
||||
if(packet->udp != NULL) {
|
||||
if(packet->payload_packet_len < sizeof(uint32_t)) {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "Short csgo packet\n");
|
||||
return;
|
||||
}
|
||||
@@ -38,58 +38,65 @@ void ndpi_search_csgo(struct ndpi_detection_module_struct* ndpi_struct, struct n
|
||||
uint32_t w = htonl(get_u_int32_t(packet->payload, 0));
|
||||
NDPI_LOG_DBG2(ndpi_struct, "CSGO: word %08x\n", w);
|
||||
|
||||
if (!flow->csgo_state && packet->payload_packet_len == 23 && w == 0xfffffffful) {
|
||||
if (!memcmp(packet->payload + 5, "connect0x", 9)) {
|
||||
if(!flow->csgo_state && packet->payload_packet_len == 23 && w == 0xfffffffful) {
|
||||
if(!memcmp(packet->payload + 5, "connect0x", 9)) {
|
||||
flow->csgo_state++;
|
||||
memcpy(flow->csgo_strid, packet->payload + 5, 18);
|
||||
NDPI_LOG_DBG2(ndpi_struct, "Found csgo connect0x\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (flow->csgo_state == 1 && packet->payload_packet_len >= 42 && w == 0xfffffffful) {
|
||||
if (!memcmp(packet->payload + 24, flow->csgo_strid, 18)) {
|
||||
|
||||
if(flow->csgo_state == 1 && packet->payload_packet_len >= 42 && w == 0xfffffffful) {
|
||||
if(!memcmp(packet->payload + 24, flow->csgo_strid, 18)) {
|
||||
flow->csgo_state++;
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
|
||||
NDPI_LOG_INFO( ndpi_struct, "found csgo connect0x reply\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (packet->payload_packet_len == 8 && ( w == 0x3a180000 || w == 0x39180000) ) {
|
||||
|
||||
if(packet->payload_packet_len == 8 && ( w == 0x3a180000 || w == 0x39180000) ) {
|
||||
NDPI_LOG_INFO( ndpi_struct, "found csgo udp 8b\n");
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
}
|
||||
if (packet->payload_packet_len >= 36 && w == 0x56533031ul) {
|
||||
|
||||
if(packet->payload_packet_len >= 36 && w == 0x56533031ul) {
|
||||
NDPI_LOG_INFO( ndpi_struct, "found csgo udp\n");
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
}
|
||||
if (packet->payload_packet_len >= 36 && w == 0x01007364) {
|
||||
|
||||
if(packet->payload_packet_len >= 36 && w == 0x01007364) {
|
||||
uint32_t w2 = htonl(get_u_int32_t(packet->payload, 4));
|
||||
if (w2 == 0x70696e67) {
|
||||
if(w2 == 0x70696e67) {
|
||||
NDPI_LOG_INFO( ndpi_struct, "found csgo udp ping\n");
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (flow->csgo_s2 < 3 && (w & 0xffff0000ul) == 0x0d1d0000) {
|
||||
|
||||
if(flow->csgo_s2 < 3 && (w & 0xffff0000ul) == 0x0d1d0000) {
|
||||
uint32_t w2 = get_u_int32_t(packet->payload, 2);
|
||||
if (packet->payload_packet_len == 13) {
|
||||
if (!flow->csgo_s2) {
|
||||
if(packet->payload_packet_len == 13) {
|
||||
if(!flow->csgo_s2) {
|
||||
flow->csgo_id2 = w2;
|
||||
flow->csgo_s2 = 1;
|
||||
NDPI_LOG_DBG2( ndpi_struct, "Found csgo udp 0d1d step1\n");
|
||||
return;
|
||||
}
|
||||
if (flow->csgo_s2 == 1 && flow->csgo_id2 == w2) {
|
||||
|
||||
if(flow->csgo_s2 == 1 && flow->csgo_id2 == w2) {
|
||||
NDPI_LOG_DBG2( ndpi_struct, "Found csgo udp 0d1d step1 DUP\n");
|
||||
return;
|
||||
}
|
||||
flow->csgo_s2 = 3;
|
||||
return;
|
||||
}
|
||||
if (packet->payload_packet_len == 15) {
|
||||
if (flow->csgo_s2 == 1 && flow->csgo_id2 == w2) {
|
||||
|
||||
if(packet->payload_packet_len == 15) {
|
||||
if(flow->csgo_s2 == 1 && flow->csgo_id2 == w2) {
|
||||
NDPI_LOG_INFO( ndpi_struct, "found csgo udp 0d1d\n");
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
@@ -97,31 +104,39 @@ void ndpi_search_csgo(struct ndpi_detection_module_struct* ndpi_struct, struct n
|
||||
}
|
||||
flow->csgo_s2 = 3;
|
||||
}
|
||||
if (packet->payload_packet_len >= 140 && (w == 0x02124c6c || w == 0x02125c6c) &&
|
||||
|
||||
if(packet->payload_packet_len >= 140 && (w == 0x02124c6c || w == 0x02125c6c) &&
|
||||
!memcmp(&packet->payload[3], "lta\000mob\000tpc\000bhj\000bxd\000tae\000urg\000gkh\000", 32)) {
|
||||
NDPI_LOG_INFO( ndpi_struct, "found csgo dictionary udp\n");
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
NDPI_LOG_INFO( ndpi_struct, "found csgo dictionary udp\n");
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
}
|
||||
if (packet->payload_packet_len >= 33 && packet->iph && packet->iph->daddr == 0xffffffff &&
|
||||
|
||||
if(packet->payload_packet_len >= 33 && packet->iph && packet->iph->daddr == 0xffffffff &&
|
||||
!memcmp(&packet->payload[17], "LanSearch", 9)) {
|
||||
NDPI_LOG_INFO( ndpi_struct, "found csgo LanSearch udp\n");
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
NDPI_LOG_INFO( ndpi_struct, "found csgo LanSearch udp\n");
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
}
|
||||
|
||||
if(w == 0) {
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (flow->packet_counter > 20)
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
|
||||
if(flow->packet_counter > 5)
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
}
|
||||
|
||||
void init_csgo_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("CSGO", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_CSGO,
|
||||
ndpi_search_csgo,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
ndpi_set_bitmask_protocol_detection("CSGO", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_CSGO,
|
||||
ndpi_search_csgo,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
@@ -486,6 +486,9 @@ static void ndpi_search_dns(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
}
|
||||
}
|
||||
|
||||
if(flow->packet_counter > 3)
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
}
|
||||
|
||||
void init_dns_dissector(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
|
||||
@@ -165,8 +165,11 @@ static void ndpi_check_edonkey(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
return;
|
||||
}
|
||||
|
||||
if(payload_len == 0) return;
|
||||
|
||||
if(payload_len == 0) {
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Check if we so far detected the protocol in the request or not. */
|
||||
if(flow->edonkey_stage == 0) {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "EDONKEY stage 0: \n");
|
||||
@@ -176,7 +179,8 @@ static void ndpi_check_edonkey(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
|
||||
/* Encode the direction of the packet in the stage, so we will know when we need to look for the response packet. */
|
||||
flow->edonkey_stage = packet->packet_direction + 1;
|
||||
}
|
||||
} else
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
} else {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "EDONKEY stage %u: \n", flow->edonkey_stage);
|
||||
|
||||
@@ -193,8 +197,10 @@ static void ndpi_check_edonkey(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
NDPI_LOG_DBG2(ndpi_struct, "The reply did not seem to belong to EDONKEY, resetting the stage to 0\n");
|
||||
flow->edonkey_stage = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(flow->packet_counter > 5)
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
}
|
||||
|
||||
void ndpi_search_edonkey(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
|
||||
|
||||
@@ -4,6 +4,19 @@
|
||||
* Copyright (C) 2015-20 ntop.org
|
||||
* Copyright (C) 2013 Remy Mudingay <mudingay@ill.fr>
|
||||
*
|
||||
* nDPI is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* nDPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ndpi_protocol_ids.h"
|
||||
@@ -99,6 +112,9 @@ void ndpi_search_h323(struct ndpi_detection_module_struct *ndpi_struct, struct n
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(flow->packet_counter > 5)
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
}
|
||||
|
||||
void init_h323_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
|
||||
@@ -59,7 +59,7 @@ void ndpi_search_imo(struct ndpi_detection_module_struct *ndpi_struct, struct nd
|
||||
NDPI_LOG_INFO(ndpi_struct, "found IMO\n");
|
||||
ndpi_int_imo_add_connection(ndpi_struct, flow);
|
||||
} else {
|
||||
if(flow->num_processed_pkts > 7)
|
||||
if(flow->num_processed_pkts > 5)
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
else
|
||||
flow->protos.imo.last_one_byte_pkt = 0;
|
||||
|
||||
@@ -117,19 +117,24 @@ void ndpi_search_netflow(struct ndpi_detection_module_struct *ndpi_struct, struc
|
||||
case 5:
|
||||
case 7:
|
||||
case 9:
|
||||
if((n == 0) || (n > 30))
|
||||
if((n == 0) || (n > 30)) {
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
switch(version) {
|
||||
case 1:
|
||||
expected_len = n * sizeof(struct flow_ver1_rec) + 16 /* header */;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
expected_len = n * sizeof(struct flow_ver5_rec) + 24 /* header */;
|
||||
break;
|
||||
|
||||
case 7:
|
||||
expected_len = n * sizeof(struct flow_ver7_rec) + 24 /* header */;
|
||||
break;
|
||||
|
||||
case 9:
|
||||
/* We need to check the template */
|
||||
break;
|
||||
@@ -142,16 +147,21 @@ void ndpi_search_netflow(struct ndpi_detection_module_struct *ndpi_struct, struc
|
||||
|
||||
uptime_offset = 8;
|
||||
break;
|
||||
|
||||
case 10: /* IPFIX */
|
||||
{
|
||||
u_int16_t ipfix_len = n;
|
||||
|
||||
if(ipfix_len != payload_len)
|
||||
if(ipfix_len != payload_len) {
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
}
|
||||
uptime_offset = 4;
|
||||
break;
|
||||
|
||||
default:
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -167,7 +177,8 @@ void ndpi_search_netflow(struct ndpi_detection_module_struct *ndpi_struct, struc
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_NETFLOW, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
}
|
||||
|
||||
void init_netflow_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
|
||||
+20
-3
@@ -2,6 +2,23 @@
|
||||
* noe.c (Alcatel new office environment)
|
||||
*
|
||||
* Copyright (C) 2013 Remy Mudingay <mudingay@ill.fr>
|
||||
* Copyright (C) 2011-20 - 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
|
||||
*
|
||||
* nDPI is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* nDPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -47,9 +64,9 @@ void ndpi_search_noe(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
ndpi_int_noe_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
}
|
||||
}
|
||||
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+33
-15
@@ -3,6 +3,29 @@
|
||||
*
|
||||
* Copyright (C) 2011-20 - ntop.org
|
||||
*
|
||||
*
|
||||
* nDPI is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* nDPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ndpi_protocol_ids.h"
|
||||
|
||||
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_OPENVPN
|
||||
|
||||
#include "ndpi_api.h"
|
||||
|
||||
/*
|
||||
* OpenVPN TCP / UDP Detection - 128/160 hmac
|
||||
*
|
||||
* Detection based upon these openvpn protocol properties:
|
||||
@@ -21,13 +44,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ndpi_protocol_ids.h"
|
||||
|
||||
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_OPENVPN
|
||||
|
||||
#include "ndpi_api.h"
|
||||
|
||||
|
||||
#define P_CONTROL_HARD_RESET_CLIENT_V1 (0x01 << 3)
|
||||
#define P_CONTROL_HARD_RESET_CLIENT_V2 (0x07 << 3)
|
||||
#define P_CONTROL_HARD_RESET_SERVER_V1 (0x02 << 3)
|
||||
@@ -105,17 +121,17 @@ void ndpi_search_openvpn(struct ndpi_detection_module_struct* ndpi_struct,
|
||||
}
|
||||
|
||||
if(flow->ovpn_counter < P_HARD_RESET_CLIENT_MAX_COUNT && (opcode == P_CONTROL_HARD_RESET_CLIENT_V1 ||
|
||||
opcode == P_CONTROL_HARD_RESET_CLIENT_V2)) {
|
||||
opcode == P_CONTROL_HARD_RESET_CLIENT_V2)) {
|
||||
if(check_pkid_and_detect_hmac_size(ovpn_payload) > 0) {
|
||||
memcpy(flow->ovpn_session_id, ovpn_payload+1, 8);
|
||||
|
||||
NDPI_LOG_DBG2(ndpi_struct,
|
||||
"session key: %02x%02x%02x%02x%02x%02x%02x%02x\n",
|
||||
flow->ovpn_session_id[0], flow->ovpn_session_id[1], flow->ovpn_session_id[2], flow->ovpn_session_id[3],
|
||||
flow->ovpn_session_id[4], flow->ovpn_session_id[5], flow->ovpn_session_id[6], flow->ovpn_session_id[7]);
|
||||
"session key: %02x%02x%02x%02x%02x%02x%02x%02x\n",
|
||||
flow->ovpn_session_id[0], flow->ovpn_session_id[1], flow->ovpn_session_id[2], flow->ovpn_session_id[3],
|
||||
flow->ovpn_session_id[4], flow->ovpn_session_id[5], flow->ovpn_session_id[6], flow->ovpn_session_id[7]);
|
||||
}
|
||||
} else if(flow->ovpn_counter >= 1 && flow->ovpn_counter <= P_HARD_RESET_CLIENT_MAX_COUNT &&
|
||||
(opcode == P_CONTROL_HARD_RESET_SERVER_V1 || opcode == P_CONTROL_HARD_RESET_SERVER_V2)) {
|
||||
(opcode == P_CONTROL_HARD_RESET_SERVER_V1 || opcode == P_CONTROL_HARD_RESET_SERVER_V2)) {
|
||||
|
||||
hmac_size = check_pkid_and_detect_hmac_size(ovpn_payload);
|
||||
|
||||
@@ -152,10 +168,12 @@ void ndpi_search_openvpn(struct ndpi_detection_module_struct* ndpi_struct,
|
||||
|
||||
flow->ovpn_counter++;
|
||||
|
||||
if(failed) {
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
}
|
||||
if(failed)
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
}
|
||||
|
||||
if(flow->packet_counter > 5)
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
}
|
||||
|
||||
void init_openvpn_dissector(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
|
||||
@@ -1,167 +0,0 @@
|
||||
/*
|
||||
* pando.c
|
||||
*
|
||||
* Copyright (C) 2014 Tomasz Bujlow <tomasz@skatnet.dk>
|
||||
*
|
||||
* The signature is based on the Libprotoident library.
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
*
|
||||
* nDPI is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* nDPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ndpi_protocol_ids.h"
|
||||
|
||||
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_PANDO
|
||||
|
||||
#include "ndpi_api.h"
|
||||
|
||||
static void ndpi_int_pando_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_PANDO, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
static void ndpi_check_pando_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
u_int32_t payload_len = packet->payload_packet_len;
|
||||
|
||||
if (ndpi_match_strprefix(packet->payload, payload_len, "\x0ePan")) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "Found PANDO\n");
|
||||
ndpi_int_pando_add_connection(ndpi_struct, flow);
|
||||
}
|
||||
}
|
||||
|
||||
static void ndpi_check_pando_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
u_int32_t payload_len = packet->payload_packet_len;
|
||||
|
||||
/* Check if we so far detected the protocol in the request or not. */
|
||||
NDPI_LOG_DBG2(ndpi_struct, "PANDO stage %u: \n", flow->pando_stage);
|
||||
if (flow->pando_stage == 0) {
|
||||
|
||||
if ((payload_len >= 4) && (packet->payload[0] == 0x00) && (packet->payload[1] == 0x00) && (packet->payload[2] == 0x00) && (packet->payload[3] == 0x09)) {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "Possible PANDO request detected, we will look further for the response..\n");
|
||||
|
||||
/* Encode the direction of the packet in the stage, so we will know when we need to look for the response packet. */
|
||||
flow->pando_stage = packet->packet_direction + 1; // packet_direction 0: stage 1, packet_direction 1: stage 2
|
||||
return;
|
||||
}
|
||||
|
||||
if (ndpi_match_strprefix(packet->payload, payload_len, "UDPA")) {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "Possible PANDO request detected, we will look further for the response..\n");
|
||||
|
||||
/* Encode the direction of the packet in the stage, so we will know when we need to look for the response packet. */
|
||||
flow->pando_stage = packet->packet_direction + 3; // packet_direction 0: stage 3, packet_direction 1: stage 4
|
||||
return;
|
||||
}
|
||||
|
||||
if (ndpi_match_strprefix(packet->payload, payload_len, "UDPR") || ndpi_match_strprefix(packet->payload, payload_len, "UDPE")) {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "Possible PANDO request detected, we will look further for the response..\n");
|
||||
|
||||
/* Encode the direction of the packet in the stage, so we will know when we need to look for the response packet. */
|
||||
flow->pando_stage = packet->packet_direction + 5; // packet_direction 0: stage 5, packet_direction 1: stage 6
|
||||
return;
|
||||
}
|
||||
|
||||
} else if ((flow->pando_stage == 1) || (flow->pando_stage == 2)) {
|
||||
|
||||
/* At first check, if this is for sure a response packet (in another direction. If not, do nothing now and return. */
|
||||
if ((flow->pando_stage - packet->packet_direction) == 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* This is a packet in another direction. Check if we find the proper response. */
|
||||
if ((payload_len == 0) || ((payload_len >= 4) && (packet->payload[0] == 0x00) && (packet->payload[1] == 0x00) && (packet->payload[2] == 0x00) && (packet->payload[3] == 0x09))) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found PANDO\n");
|
||||
ndpi_int_pando_add_connection(ndpi_struct, flow);
|
||||
} else {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "The reply did not seem to belong to PANDO, resetting the stage to 0..\n");
|
||||
flow->pando_stage = 0;
|
||||
}
|
||||
|
||||
} else if ((flow->pando_stage == 3) || (flow->pando_stage == 4)) {
|
||||
|
||||
/* At first check, if this is for sure a response packet (in another direction. If not, do nothing now and return. */
|
||||
if ((flow->pando_stage - packet->packet_direction) == 3) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* This is a packet in another direction. Check if we find the proper response. */
|
||||
if ((payload_len == 0) || (ndpi_match_strprefix(packet->payload, payload_len, "UDPR") || ndpi_match_strprefix(packet->payload, payload_len, "UDPE"))) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found PANDO\n");
|
||||
ndpi_int_pando_add_connection(ndpi_struct, flow);
|
||||
} else {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "The reply did not seem to belong to PANDO, resetting the stage to 0..\n");
|
||||
flow->pando_stage = 0;
|
||||
}
|
||||
|
||||
} else if ((flow->pando_stage == 5) || (flow->pando_stage == 6)) {
|
||||
|
||||
/* At first check, if this is for sure a response packet (in another direction. If not, do nothing now and return. */
|
||||
if ((flow->pando_stage - packet->packet_direction) == 5) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* This is a packet in another direction. Check if we find the proper response. */
|
||||
if (ndpi_match_strprefix(packet->payload, payload_len, "UDPA")) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found PANDO\n");
|
||||
ndpi_int_pando_add_connection(ndpi_struct, flow);
|
||||
} else {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "The reply did not seem to belong to PANDO, resetting the stage to 0\n");
|
||||
flow->pando_stage = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ndpi_search_pando(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
|
||||
NDPI_LOG_DBG(ndpi_struct, "search PANDO\n");
|
||||
/* Break after 20 packets. */
|
||||
if (flow->packet_counter > 20) {
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
|
||||
/* skip marked or retransmitted packets */
|
||||
if (packet->tcp_retransmission != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (packet->detected_protocol_stack[0] == NDPI_PROTOCOL_PANDO) {
|
||||
return;
|
||||
}
|
||||
|
||||
ndpi_check_pando_tcp(ndpi_struct, flow);
|
||||
|
||||
if (packet->detected_protocol_stack[0] == NDPI_PROTOCOL_PANDO) {
|
||||
return;
|
||||
}
|
||||
|
||||
ndpi_check_pando_udp(ndpi_struct, flow);
|
||||
}
|
||||
|
||||
|
||||
void init_pando_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("Pando_Media_Booster", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_PANDO,
|
||||
ndpi_search_pando,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITHOUT_RETRANSMISSION,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
@@ -1,232 +0,0 @@
|
||||
/*
|
||||
* pplive.c
|
||||
*
|
||||
* Copyright (C) 2014 Tomasz Bujlow <tomasz@skatnet.dk>
|
||||
*
|
||||
* The signature is mostly based on the Libprotoident library
|
||||
* except the detection of HTTP Steam flows.
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
*
|
||||
* nDPI is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* nDPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ndpi_protocol_ids.h"
|
||||
|
||||
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_PPLIVE
|
||||
|
||||
#include "ndpi_api.h"
|
||||
|
||||
static void ndpi_int_pplive_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_PPLIVE, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
static void ndpi_check_pplive_udp1(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
u_int32_t payload_len = packet->payload_packet_len;
|
||||
|
||||
/* Check if we so far detected the protocol in the request or not. */
|
||||
if (flow->pplive_stage1 == 0) {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "PPLIVE stage 0: \n");
|
||||
|
||||
if (ndpi_match_strprefix(packet->payload, payload_len, "\xe9\x03\x41\x01")) {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "Possible PPLIVE request detected, we will look further for the response..\n");
|
||||
|
||||
/* Encode the direction of the packet in the stage, so we will know when we need to look for the response packet. */
|
||||
flow->pplive_stage1 = packet->packet_direction + 1; // packet_direction 0: stage 1, packet_direction 1: stage 2
|
||||
return;
|
||||
}
|
||||
|
||||
if (ndpi_match_strprefix(packet->payload, payload_len, "\xe9\x03\x42\x01")) {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "Possible PPLIVE request detected, we will look further for the response..\n");
|
||||
|
||||
/* Encode the direction of the packet in the stage, so we will know when we need to look for the response packet. */
|
||||
flow->pplive_stage1 = packet->packet_direction + 3; // packet_direction 0: stage 3, packet_direction 1: stage 4
|
||||
return;
|
||||
}
|
||||
|
||||
if (ndpi_match_strprefix(packet->payload, payload_len, "\x1c\x1c\x32\x01")) {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "Possible PPLIVE request detected, we will look further for the response..\n");
|
||||
|
||||
/* Encode the direction of the packet in the stage, so we will know when we need to look for the response packet. */
|
||||
flow->pplive_stage1 = packet->packet_direction + 5; // packet_direction 0: stage 5, packet_direction 1: stage 6
|
||||
return;
|
||||
}
|
||||
|
||||
} else if ((flow->pplive_stage1 == 1) || (flow->pplive_stage1 == 2)) {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "PPLIVE stage %u: \n", flow->pplive_stage1);
|
||||
|
||||
/* At first check, if this is for sure a response packet (in another direction. If not, do nothing now and return. */
|
||||
if ((flow->pplive_stage1 - packet->packet_direction) == 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* This is a packet in another direction. Check if we find the proper response. */
|
||||
if (ndpi_match_strprefix(packet->payload, payload_len, "\xe9\x03\x42\x01") || ndpi_match_strprefix(packet->payload, payload_len, "\xe9\x03\x41\x01")) {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "Found PPLIVE\n");
|
||||
ndpi_int_pplive_add_connection(ndpi_struct, flow);
|
||||
} else {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "The reply did not seem to belong to PPLIVE, resetting the stage to 0..\n");
|
||||
flow->pplive_stage1 = 0;
|
||||
}
|
||||
|
||||
} else if ((flow->pplive_stage1 == 3) || (flow->pplive_stage1 == 4)) {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "PPLIVE stage %u: \n", flow->pplive_stage1);
|
||||
|
||||
/* At first check, if this is for sure a response packet (in another direction. If not, do nothing now and return. */
|
||||
if ((flow->pplive_stage1 - packet->packet_direction) == 3) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* This is a packet in another direction. Check if we find the proper response. */
|
||||
if (ndpi_match_strprefix(packet->payload, payload_len, "\xe9\x03\x41\x01")) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found PPLIVE\n");
|
||||
ndpi_int_pplive_add_connection(ndpi_struct, flow);
|
||||
} else {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "The reply did not seem to belong to PPLIVE, resetting the stage to 0..\n");
|
||||
flow->pplive_stage1 = 0;
|
||||
}
|
||||
} else if ((flow->pplive_stage1 == 5) || (flow->pplive_stage1 == 6)) {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "PPLIVE stage %u: \n", flow->pplive_stage1);
|
||||
|
||||
/* At first check, if this is for sure a response packet (in another direction. If not, do nothing now and return. */
|
||||
if ((flow->pplive_stage1 - packet->packet_direction) == 5) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* This is a packet in another direction. Check if we find the proper response. */
|
||||
if (ndpi_match_strprefix(packet->payload, payload_len, "\x1c\x1c\x32\x01")) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "Found PPLIVE\n");
|
||||
ndpi_int_pplive_add_connection(ndpi_struct, flow);
|
||||
} else {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "The reply did not seem to belong to PPLIVE, resetting the stage to 0..\n");
|
||||
flow->pplive_stage1 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void ndpi_check_pplive_udp2(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
u_int32_t payload_len = packet->payload_packet_len;
|
||||
|
||||
/* Check if we so far detected the protocol in the request or not. */
|
||||
NDPI_LOG_DBG2(ndpi_struct, "PPLIVE stage %u: \n", flow->pplive_stage2);
|
||||
if (flow->pplive_stage2 == 0) {
|
||||
|
||||
if ((payload_len == 57) && ndpi_match_strprefix(packet->payload, payload_len, "\xe9\x03\x41\x01")) {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "Possible PPLIVE request detected, we will look further for the response..\n");
|
||||
|
||||
/* Encode the direction of the packet in the stage, so we will know when we need to look for the response packet. */
|
||||
flow->pplive_stage2 = packet->packet_direction + 1; // packet_direction 0: stage 1, packet_direction 1: stage 2
|
||||
}
|
||||
|
||||
} else {
|
||||
/* At first check, if this is for sure a response packet (in another direction. If not, do nothing now and return. */
|
||||
if ((flow->pplive_stage2 - packet->packet_direction) == 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* This is a packet in another direction. Check if we find the proper response. */
|
||||
if (payload_len == 0) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found PPLIVE\n");
|
||||
ndpi_int_pplive_add_connection(ndpi_struct, flow);
|
||||
} else {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "The reply did not seem to belong to PPLIVE, resetting the stage to 0..\n");
|
||||
flow->pplive_stage2 = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static void ndpi_check_pplive_udp3(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
u_int32_t payload_len = packet->payload_packet_len;
|
||||
|
||||
/* Check if we so far detected the protocol in the request or not. */
|
||||
NDPI_LOG_DBG(ndpi_struct, "PPLIVE stage %u: \n", flow->pplive_stage3);
|
||||
if (flow->pplive_stage3 == 0) {
|
||||
|
||||
if ((payload_len == 94) && (packet->udp->dest == htons(5041) || packet->udp->source == htons(5041) || packet->udp->dest == htons(8303) || packet->udp->source == htons(8303))) {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "Possible PPLIVE request detected, we will look further for the response..\n");
|
||||
|
||||
/* Encode the direction of the packet in the stage, so we will know when we need to look for the response packet. */
|
||||
flow->pplive_stage3 = packet->packet_direction + 1; // packet_direction 0: stage 1, packet_direction 1: stage 2
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
/* At first check, if this is for sure a response packet (in another direction. If not, do nothing now and return. */
|
||||
if ((flow->pplive_stage3 - packet->packet_direction) == 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* This is a packet in another direction. Check if we find the proper response. */
|
||||
if ((payload_len == 0) || (payload_len == 49) ||(payload_len == 94)) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found PPLIVE\n");
|
||||
ndpi_int_pplive_add_connection(ndpi_struct, flow);
|
||||
} else {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "The reply did not seem to belong to PPLIVE, resetting the stage to 0..\n");
|
||||
flow->pplive_stage3 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ndpi_search_pplive(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
|
||||
NDPI_LOG_DBG(ndpi_struct, "search PPLIVE\n");
|
||||
|
||||
/* Break after 20 packets. */
|
||||
if (flow->packet_counter > 20) {
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
|
||||
if (packet->detected_protocol_stack[0] == NDPI_PROTOCOL_PPLIVE) {
|
||||
return;
|
||||
}
|
||||
|
||||
ndpi_check_pplive_udp1(ndpi_struct, flow);
|
||||
|
||||
if (packet->detected_protocol_stack[0] == NDPI_PROTOCOL_PPLIVE) {
|
||||
return;
|
||||
}
|
||||
|
||||
ndpi_check_pplive_udp2(ndpi_struct, flow);
|
||||
|
||||
if (packet->detected_protocol_stack[0] == NDPI_PROTOCOL_PPLIVE) {
|
||||
return;
|
||||
}
|
||||
|
||||
ndpi_check_pplive_udp3(ndpi_struct, flow);
|
||||
}
|
||||
|
||||
|
||||
void init_pplive_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("PPLive", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_PPLIVE,
|
||||
ndpi_search_pplive,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
@@ -40,9 +40,11 @@ static void ndpi_check_radius(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
if(packet->udp != NULL) {
|
||||
struct radius_header *h = (struct radius_header*)packet->payload;
|
||||
/* RFC2865: The minimum length is 20 and maximum length is 4096. */
|
||||
if((payload_len < 20) || (payload_len > 4096))
|
||||
return;
|
||||
|
||||
if((payload_len < 20) || (payload_len > 4096)) {
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
|
||||
if((h->code > 0)
|
||||
&& (h->code <= 13)
|
||||
&& (ntohs(h->len) == payload_len)) {
|
||||
|
||||
@@ -45,7 +45,7 @@ void ndpi_search_rtcp(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
len = packet->payload[2+offset] * 256 + packet->payload[2+offset+1];
|
||||
rtcp_section_len = (len + 1) * 4;
|
||||
|
||||
if(((offset+rtcp_section_len) > packet->payload_packet_len) || (rtcp_section_len == 0))
|
||||
if(((offset+rtcp_section_len) > packet->payload_packet_len) || (rtcp_section_len == 0) || (len == 0))
|
||||
goto exclude_rtcp;
|
||||
else
|
||||
offset += rtcp_section_len;
|
||||
@@ -60,6 +60,9 @@ void ndpi_search_rtcp(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
NDPI_LOG_INFO(ndpi_struct, "found rtcp\n");
|
||||
ndpi_int_rtcp_add_connection(ndpi_struct, flow);
|
||||
}
|
||||
|
||||
if(flow->packet_counter > 3)
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
} else {
|
||||
exclude_rtcp:
|
||||
|
||||
|
||||
+4
-10
@@ -76,6 +76,8 @@ static u_int8_t isValidMSRTPType(u_int8_t payloadType) {
|
||||
static void ndpi_rtp_search(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow,
|
||||
const u_int8_t * payload, const u_int16_t payload_len) {
|
||||
u_int8_t payloadType, payload_type = payload[1] & 0x7F;
|
||||
|
||||
NDPI_LOG_DBG(ndpi_struct, "search RTP\n");
|
||||
|
||||
if((payload_len < 2) || flow->protos.stun_ssl.stun.num_binding_requests) {
|
||||
@@ -83,9 +85,6 @@ static void ndpi_rtp_search(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
return;
|
||||
}
|
||||
|
||||
//struct ndpi_packet_struct *packet = &flow->packet;
|
||||
u_int8_t payloadType, payload_type = payload[1] & 0x7F;
|
||||
|
||||
/* Check whether this is an RTP flow */
|
||||
if((payload_len >= 12)
|
||||
&& (((payload[0] & 0xFF) == 0x80) || ((payload[0] & 0xFF) == 0xA0)) /* RTP magic byte[1] */
|
||||
@@ -105,13 +104,6 @@ static void ndpi_rtp_search(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
NDPI_LOG_INFO(ndpi_struct, "Found Skype for Business (former MS Lync)\n");
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_SKYPE, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
} else /* RTCP */ {
|
||||
#if 0
|
||||
/* If it's RTCP the RTCP decoder will catch it */
|
||||
NDPI_LOG_INFO(ndpi_struct, "Found MS RTCP\n");
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_RTCP, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,6 +128,8 @@ void ndpi_search_rtp(struct ndpi_detection_module_struct *ndpi_struct, struct nd
|
||||
&& (dest > 1023)
|
||||
)
|
||||
ndpi_rtp_search(ndpi_struct, flow, packet->payload, packet->payload_packet_len);
|
||||
else
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
}
|
||||
|
||||
/* *************************************************************** */
|
||||
|
||||
+102
-110
@@ -48,142 +48,131 @@ void ndpi_search_sip_handshake(struct ndpi_detection_module_struct
|
||||
const u_int8_t *packet_payload = packet->payload;
|
||||
u_int32_t payload_len = packet->payload_packet_len;
|
||||
|
||||
if (payload_len > 4) {
|
||||
if(payload_len > 4) {
|
||||
/* search for STUN Turn ChannelData Prefix */
|
||||
u_int16_t message_len = ntohs(get_u_int16_t(packet->payload, 2));
|
||||
if (payload_len - 4 == message_len) {
|
||||
|
||||
if(payload_len - 4 == message_len) {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "found STUN TURN ChannelData prefix\n");
|
||||
payload_len -= 4;
|
||||
packet_payload += 4;
|
||||
}
|
||||
}
|
||||
|
||||
if (payload_len >= 14)
|
||||
{
|
||||
if(payload_len >= 14) {
|
||||
if((memcmp(packet_payload, "NOTIFY ", 7) == 0 || memcmp(packet_payload, "notify ", 7) == 0)
|
||||
&& (memcmp(&packet_payload[7], "SIP:", 4) == 0 || memcmp(&packet_payload[7], "sip:", 4) == 0)) {
|
||||
|
||||
if ((memcmp(packet_payload, "NOTIFY ", 7) == 0 || memcmp(packet_payload, "notify ", 7) == 0)
|
||||
&& (memcmp(&packet_payload[7], "SIP:", 4) == 0 || memcmp(&packet_payload[7], "sip:", 4) == 0)) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found sip NOTIFY\n");
|
||||
ndpi_int_sip_add_connection(ndpi_struct, flow, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
NDPI_LOG_INFO(ndpi_struct, "found sip NOTIFY\n");
|
||||
ndpi_int_sip_add_connection(ndpi_struct, flow, 0);
|
||||
return;
|
||||
}
|
||||
if((memcmp(packet_payload, "REGISTER ", 9) == 0 || memcmp(packet_payload, "register ", 9) == 0)
|
||||
&& (memcmp(&packet_payload[9], "SIP:", 4) == 0 || memcmp(&packet_payload[9], "sip:", 4) == 0)) {
|
||||
|
||||
if ((memcmp(packet_payload, "REGISTER ", 9) == 0 || memcmp(packet_payload, "register ", 9) == 0)
|
||||
&& (memcmp(&packet_payload[9], "SIP:", 4) == 0 || memcmp(&packet_payload[9], "sip:", 4) == 0)) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found sip REGISTER\n");
|
||||
ndpi_int_sip_add_connection(ndpi_struct, flow, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
NDPI_LOG_INFO(ndpi_struct, "found sip REGISTER\n");
|
||||
ndpi_int_sip_add_connection(ndpi_struct, flow, 0);
|
||||
return;
|
||||
}
|
||||
if((memcmp(packet_payload, "INVITE ", 7) == 0 || memcmp(packet_payload, "invite ", 7) == 0)
|
||||
&& (memcmp(&packet_payload[7], "SIP:", 4) == 0 || memcmp(&packet_payload[7], "sip:", 4) == 0)) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found sip INVITE\n");
|
||||
ndpi_int_sip_add_connection(ndpi_struct, flow, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((memcmp(packet_payload, "INVITE ", 7) == 0 || memcmp(packet_payload, "invite ", 7) == 0)
|
||||
&& (memcmp(&packet_payload[7], "SIP:", 4) == 0 || memcmp(&packet_payload[7], "sip:", 4) == 0)) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found sip INVITE\n");
|
||||
ndpi_int_sip_add_connection(ndpi_struct, flow, 0);
|
||||
return;
|
||||
}
|
||||
/* seen this in second direction on the third position,
|
||||
* maybe it could be deleted, if somebody sees it in the first direction,
|
||||
* please delete this comment.
|
||||
*/
|
||||
|
||||
/* seen this in second direction on the third position,
|
||||
* maybe it could be deleted, if somebody sees it in the first direction,
|
||||
* please delete this comment.
|
||||
*/
|
||||
|
||||
/*
|
||||
if (memcmp(packet_payload, "SIP/2.0 200 OK", 14) == 0 || memcmp(packet_payload, "sip/2.0 200 OK", 14) == 0) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found sip SIP/2.0 0K\n");
|
||||
ndpi_int_sip_add_connection(ndpi_struct, flow, 0);
|
||||
return;
|
||||
}
|
||||
*/
|
||||
if (memcmp(packet_payload, "SIP/2.0 ", 8) == 0 || memcmp(packet_payload, "sip/2.0 ", 8) == 0) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found sip SIP/2.0 *\n");
|
||||
ndpi_int_sip_add_connection(ndpi_struct, flow, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((memcmp(packet_payload, "BYE ", 4) == 0 || memcmp(packet_payload, "bye ", 4) == 0)
|
||||
&& (memcmp(&packet_payload[4], "SIP:", 4) == 0 || memcmp(&packet_payload[4], "sip:", 4) == 0)) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found sip BYE\n");
|
||||
ndpi_int_sip_add_connection(ndpi_struct, flow, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((memcmp(packet_payload, "ACK ", 4) == 0 || memcmp(packet_payload, "ack ", 4) == 0)
|
||||
&& (memcmp(&packet_payload[4], "SIP:", 4) == 0 || memcmp(&packet_payload[4], "sip:", 4) == 0)) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found sip ACK\n");
|
||||
ndpi_int_sip_add_connection(ndpi_struct, flow, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((memcmp(packet_payload, "CANCEL ", 7) == 0 || memcmp(packet_payload, "cancel ", 7) == 0)
|
||||
&& (memcmp(&packet_payload[7], "SIP:", 4) == 0 || memcmp(&packet_payload[7], "sip:", 4) == 0)) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found sip CANCEL\n");
|
||||
ndpi_int_sip_add_connection(ndpi_struct, flow, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((memcmp(packet_payload, "PUBLISH ", 8) == 0 || memcmp(packet_payload, "publish ", 8) == 0)
|
||||
&& (memcmp(&packet_payload[8], "SIP:", 4) == 0 || memcmp(&packet_payload[8], "sip:", 4) == 0)) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found sip PUBLISH\n");
|
||||
ndpi_int_sip_add_connection(ndpi_struct, flow, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((memcmp(packet_payload, "SUBSCRIBE ", 10) == 0 || memcmp(packet_payload, "subscribe ", 10) == 0)
|
||||
&& (memcmp(&packet_payload[10], "SIP:", 4) == 0 || memcmp(&packet_payload[10], "sip:", 4) == 0)) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found sip SUBSCRIBE\n");
|
||||
ndpi_int_sip_add_connection(ndpi_struct, flow, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
/* SIP message extension RFC 3248 */
|
||||
if ((memcmp(packet_payload, "MESSAGE ", 8) == 0 || memcmp(packet_payload, "message ", 8) == 0)
|
||||
&& (memcmp(&packet_payload[8], "SIP:", 4) == 0 || memcmp(&packet_payload[8], "sip:", 4) == 0)) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found sip MESSAGE\n");
|
||||
ndpi_int_sip_add_connection(ndpi_struct, flow, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Courtesy of Miguel Quesada <mquesadab@gmail.com> */
|
||||
if ((memcmp(packet_payload, "OPTIONS ", 8) == 0
|
||||
|| memcmp(packet_payload, "options ", 8) == 0)
|
||||
&& (memcmp(&packet_payload[8], "SIP:", 4) == 0
|
||||
|| memcmp(&packet_payload[8], "sip:", 4) == 0)) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found sip OPTIONS\n");
|
||||
ndpi_int_sip_add_connection(ndpi_struct, flow, 0);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
if(memcmp(packet_payload, "SIP/2.0 200 OK", 14) == 0 || memcmp(packet_payload, "sip/2.0 200 OK", 14) == 0) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found sip SIP/2.0 0K\n");
|
||||
ndpi_int_sip_add_connection(ndpi_struct, flow, 0);
|
||||
return;
|
||||
}
|
||||
*/
|
||||
if(memcmp(packet_payload, "SIP/2.0 ", 8) == 0 || memcmp(packet_payload, "sip/2.0 ", 8) == 0) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found sip SIP/2.0 *\n");
|
||||
ndpi_int_sip_add_connection(ndpi_struct, flow, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if((memcmp(packet_payload, "BYE ", 4) == 0 || memcmp(packet_payload, "bye ", 4) == 0)
|
||||
&& (memcmp(&packet_payload[4], "SIP:", 4) == 0 || memcmp(&packet_payload[4], "sip:", 4) == 0)) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found sip BYE\n");
|
||||
ndpi_int_sip_add_connection(ndpi_struct, flow, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if((memcmp(packet_payload, "ACK ", 4) == 0 || memcmp(packet_payload, "ack ", 4) == 0)
|
||||
&& (memcmp(&packet_payload[4], "SIP:", 4) == 0 || memcmp(&packet_payload[4], "sip:", 4) == 0)) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found sip ACK\n");
|
||||
ndpi_int_sip_add_connection(ndpi_struct, flow, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if((memcmp(packet_payload, "CANCEL ", 7) == 0 || memcmp(packet_payload, "cancel ", 7) == 0)
|
||||
&& (memcmp(&packet_payload[7], "SIP:", 4) == 0 || memcmp(&packet_payload[7], "sip:", 4) == 0)) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found sip CANCEL\n");
|
||||
ndpi_int_sip_add_connection(ndpi_struct, flow, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if((memcmp(packet_payload, "PUBLISH ", 8) == 0 || memcmp(packet_payload, "publish ", 8) == 0)
|
||||
&& (memcmp(&packet_payload[8], "SIP:", 4) == 0 || memcmp(&packet_payload[8], "sip:", 4) == 0)) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found sip PUBLISH\n");
|
||||
ndpi_int_sip_add_connection(ndpi_struct, flow, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if((memcmp(packet_payload, "SUBSCRIBE ", 10) == 0 || memcmp(packet_payload, "subscribe ", 10) == 0)
|
||||
&& (memcmp(&packet_payload[10], "SIP:", 4) == 0 || memcmp(&packet_payload[10], "sip:", 4) == 0)) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found sip SUBSCRIBE\n");
|
||||
ndpi_int_sip_add_connection(ndpi_struct, flow, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
/* SIP message extension RFC 3248 */
|
||||
if((memcmp(packet_payload, "MESSAGE ", 8) == 0 || memcmp(packet_payload, "message ", 8) == 0)
|
||||
&& (memcmp(&packet_payload[8], "SIP:", 4) == 0 || memcmp(&packet_payload[8], "sip:", 4) == 0)) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found sip MESSAGE\n");
|
||||
ndpi_int_sip_add_connection(ndpi_struct, flow, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Courtesy of Miguel Quesada <mquesadab@gmail.com> */
|
||||
if((memcmp(packet_payload, "OPTIONS ", 8) == 0
|
||||
|| memcmp(packet_payload, "options ", 8) == 0)
|
||||
&& (memcmp(&packet_payload[8], "SIP:", 4) == 0
|
||||
|| memcmp(&packet_payload[8], "sip:", 4) == 0)) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found sip OPTIONS\n");
|
||||
ndpi_int_sip_add_connection(ndpi_struct, flow, 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* add bitmask for tcp only, some stupid udp programs
|
||||
* send a very few (< 10 ) packets before invite (mostly a 0x0a0x0d, but just search the first 3 payload_packets here */
|
||||
if (packet->udp != NULL && flow->packet_counter < 20) {
|
||||
if(packet->udp != NULL && flow->packet_counter < 20) {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "need next packet\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* for STUN flows we need some more packets */
|
||||
if (packet->udp != NULL && flow->detected_protocol_stack[0] == NDPI_PROTOCOL_STUN && flow->packet_counter < 40) {
|
||||
if(packet->udp != NULL && flow->detected_protocol_stack[0] == NDPI_PROTOCOL_STUN && flow->packet_counter < 40) {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "need next STUN packet\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (payload_len == 4 && get_u_int32_t(packet_payload, 0) == 0) {
|
||||
if(payload_len == 4 && get_u_int32_t(packet_payload, 0) == 0) {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "maybe sip. need next packet\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (payload_len > 30 && packet_payload[0] == 0x90
|
||||
&& packet_payload[3] == payload_len - 20 && get_u_int32_t(packet_payload, 4) == 0
|
||||
&& get_u_int32_t(packet_payload, 8) == 0) {
|
||||
flow->sip_yahoo_voice = 1;
|
||||
NDPI_LOG_DBG2(ndpi_struct, "maybe sip yahoo. need next packet\n");
|
||||
}
|
||||
if (flow->sip_yahoo_voice && flow->packet_counter < 10) {
|
||||
return;
|
||||
}
|
||||
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
}
|
||||
|
||||
@@ -193,15 +182,18 @@ void ndpi_search_sip(struct ndpi_detection_module_struct *ndpi_struct, struct nd
|
||||
|
||||
NDPI_LOG_DBG(ndpi_struct, "search sip\n");
|
||||
|
||||
/* skip marked packets */
|
||||
if (packet->detected_protocol_stack[0] != NDPI_PROTOCOL_SIP) {
|
||||
if (packet->tcp_retransmission == 0) {
|
||||
ndpi_search_sip_handshake(ndpi_struct, flow);
|
||||
if(flow->packet_counter > 5)
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
else {
|
||||
/* skip marked packets */
|
||||
if(packet->detected_protocol_stack[0] != NDPI_PROTOCOL_SIP) {
|
||||
if(packet->tcp_retransmission == 0) {
|
||||
ndpi_search_sip_handshake(ndpi_struct, flow);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void init_sip_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("SIP", ndpi_struct, detection_bitmask, *id,
|
||||
|
||||
@@ -267,7 +267,6 @@ void ndpi_search_steam(struct ndpi_detection_module_struct *ndpi_struct, struct
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* skip marked or retransmitted packets */
|
||||
if(packet->tcp_retransmission != 0) {
|
||||
return;
|
||||
|
||||
+55
-61
@@ -27,7 +27,7 @@
|
||||
|
||||
#include "ndpi_api.h"
|
||||
|
||||
#define MAX_NUM_STUN_PKTS 8
|
||||
#define MAX_NUM_STUN_PKTS 3
|
||||
|
||||
// #define DEBUG_STUN 1
|
||||
// #define DEBUG_LRU 1
|
||||
@@ -122,15 +122,15 @@ static int is_google_ip_address(u_int32_t host) {
|
||||
/* ************************************************************ */
|
||||
|
||||
/*
|
||||
WhatsApp
|
||||
31.13.86.48
|
||||
31.13.92.50
|
||||
157.240.20.51
|
||||
157.240.21.51
|
||||
185.60.216.51
|
||||
WhatsApp
|
||||
31.13.86.48
|
||||
31.13.92.50
|
||||
157.240.20.51
|
||||
157.240.21.51
|
||||
185.60.216.51
|
||||
|
||||
Messenger
|
||||
31.13.86.5
|
||||
Messenger
|
||||
31.13.86.5
|
||||
*/
|
||||
|
||||
static int is_messenger_ip_address(u_int32_t host) {
|
||||
@@ -149,14 +149,10 @@ static ndpi_int_stun_t ndpi_int_check_stun(struct ndpi_detection_module_struct *
|
||||
u_int16_t msg_type, msg_len;
|
||||
int rc;
|
||||
|
||||
/* STUN over TCP does not look good */
|
||||
if(flow->packet.tcp)
|
||||
return(NDPI_IS_NOT_STUN);
|
||||
|
||||
/* No need to do ntohl() with 0xFFFFFFFF */
|
||||
if(flow->packet.iph && (flow->packet.iph->daddr == 0xFFFFFFFF /* 255.255.255.255 */)) {
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
return(NDPI_IS_NOT_STUN);;
|
||||
return(NDPI_IS_NOT_STUN);
|
||||
}
|
||||
|
||||
if(payload_length >= 512) {
|
||||
@@ -190,25 +186,25 @@ static ndpi_int_stun_t ndpi_int_check_stun(struct ndpi_detection_module_struct *
|
||||
#endif
|
||||
|
||||
/*
|
||||
If we're here it's because this does not look like STUN anymore
|
||||
as this was a flow that started as STUN and turned into something
|
||||
else. Let's investigate what is that about
|
||||
*/
|
||||
If we're here it's because this does not look like STUN anymore
|
||||
as this was a flow that started as STUN and turned into something
|
||||
else. Let's investigate what is that about
|
||||
*/
|
||||
if(payload[0] == 0x16) {
|
||||
/* Let's check if this is DTLS used by some socials */
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
u_int16_t total_len, version = htons(*((u_int16_t*) &packet->payload[1]));
|
||||
|
||||
switch (version) {
|
||||
case 0xFEFF: /* DTLS 1.0 */
|
||||
case 0xFEFD: /* DTLS 1.2 */
|
||||
total_len = ntohs(*((u_int16_t*) &packet->payload[11])) + 13;
|
||||
case 0xFEFF: /* DTLS 1.0 */
|
||||
case 0xFEFD: /* DTLS 1.2 */
|
||||
total_len = ntohs(*((u_int16_t*) &packet->payload[11])) + 13;
|
||||
|
||||
if(payload_length == total_len) {
|
||||
/* This is DTLS and the only protocol we know behaves like this is signal */
|
||||
flow->guessed_host_protocol_id = NDPI_PROTOCOL_SIGNAL;
|
||||
return(NDPI_IS_STUN);
|
||||
}
|
||||
if(payload_length == total_len) {
|
||||
/* This is DTLS and the only protocol we know behaves like this is signal */
|
||||
flow->guessed_host_protocol_id = NDPI_PROTOCOL_SIGNAL;
|
||||
return(NDPI_IS_STUN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,7 +214,7 @@ static ndpi_int_stun_t ndpi_int_check_stun(struct ndpi_detection_module_struct *
|
||||
#if 0
|
||||
if((flow->packet.udp->dest == htons(3480)) ||
|
||||
(flow->packet.udp->source == htons(3480))
|
||||
)
|
||||
)
|
||||
printf("[STUN] Here we go\n");;
|
||||
#endif
|
||||
|
||||
@@ -285,7 +281,7 @@ static ndpi_int_stun_t ndpi_int_check_stun(struct ndpi_detection_module_struct *
|
||||
flow->guessed_host_protocol_id = NDPI_PROTOCOL_WHATSAPP_CALL;
|
||||
return(NDPI_IS_STUN); /* This is WhatsApp Call */
|
||||
} else if((payload[0] == 0x90) && (((msg_len+11) == payload_length) ||
|
||||
(flow->protos.stun_ssl.stun.num_binding_requests >= 4))) {
|
||||
(flow->protos.stun_ssl.stun.num_binding_requests >= 4))) {
|
||||
flow->guessed_host_protocol_id = NDPI_PROTOCOL_WHATSAPP_CALL;
|
||||
return(NDPI_IS_STUN); /* This is WhatsApp Call */
|
||||
}
|
||||
@@ -311,13 +307,13 @@ static ndpi_int_stun_t ndpi_int_check_stun(struct ndpi_detection_module_struct *
|
||||
u_int offset = 20;
|
||||
|
||||
/*
|
||||
This can either be the standard RTCP or Ms Lync RTCP that
|
||||
later will become Ms Lync RTP. In this case we need to
|
||||
be careful before deciding about the protocol before dissecting the packet
|
||||
This can either be the standard RTCP or Ms Lync RTCP that
|
||||
later will become Ms Lync RTP. In this case we need to
|
||||
be careful before deciding about the protocol before dissecting the packet
|
||||
|
||||
MS Lync = Skype
|
||||
https://en.wikipedia.org/wiki/Skype_for_Business
|
||||
*/
|
||||
MS Lync = Skype
|
||||
https://en.wikipedia.org/wiki/Skype_for_Business
|
||||
*/
|
||||
|
||||
while((offset+4) < payload_length) {
|
||||
u_int16_t attribute = ntohs(*((u_int16_t*)&payload[offset]));
|
||||
@@ -346,36 +342,36 @@ static ndpi_int_stun_t ndpi_int_check_stun(struct ndpi_detection_module_struct *
|
||||
break;
|
||||
|
||||
case 0x0014: /* Realm */
|
||||
{
|
||||
u_int16_t realm_len = ntohs(*((u_int16_t*)&payload[offset+2]));
|
||||
{
|
||||
u_int16_t realm_len = ntohs(*((u_int16_t*)&payload[offset+2]));
|
||||
|
||||
if(flow->host_server_name[0] == '\0') {
|
||||
u_int j, i = (realm_len > sizeof(flow->host_server_name)) ? sizeof(flow->host_server_name) : realm_len;
|
||||
u_int k = offset+4;
|
||||
if(flow->host_server_name[0] == '\0') {
|
||||
u_int j, i = (realm_len > sizeof(flow->host_server_name)) ? sizeof(flow->host_server_name) : realm_len;
|
||||
u_int k = offset+4;
|
||||
|
||||
memset(flow->host_server_name, 0, sizeof(flow->host_server_name));
|
||||
memset(flow->host_server_name, 0, sizeof(flow->host_server_name));
|
||||
|
||||
for(j=0; j<i; j++) {
|
||||
if((k+i) < payload_length)
|
||||
flow->host_server_name[j] = payload[k++];
|
||||
else
|
||||
break;
|
||||
}
|
||||
for(j=0; j<i; j++) {
|
||||
if((k+i) < payload_length)
|
||||
flow->host_server_name[j] = payload[k++];
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_STUN
|
||||
printf("==> [%s]\n", flow->host_server_name);
|
||||
printf("==> [%s]\n", flow->host_server_name);
|
||||
#endif
|
||||
|
||||
if(strstr((char*) flow->host_server_name, "google.com") != NULL) {
|
||||
if(strstr((char*) flow->host_server_name, "google.com") != NULL) {
|
||||
flow->guessed_host_protocol_id = NDPI_PROTOCOL_HANGOUT_DUO;
|
||||
return(NDPI_IS_STUN);
|
||||
} else if(strstr((char*) flow->host_server_name, "whispersystems.org") != NULL) {
|
||||
flow->guessed_host_protocol_id = NDPI_PROTOCOL_SIGNAL;
|
||||
return(NDPI_IS_STUN);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
} else if(strstr((char*) flow->host_server_name, "whispersystems.org") != NULL) {
|
||||
flow->guessed_host_protocol_id = NDPI_PROTOCOL_SIGNAL;
|
||||
return(NDPI_IS_STUN);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 0xC057: /* Messeger */
|
||||
if(msg_type == 0x0001) {
|
||||
@@ -470,7 +466,7 @@ static ndpi_int_stun_t ndpi_int_check_stun(struct ndpi_detection_module_struct *
|
||||
} else
|
||||
return(NDPI_IS_NOT_STUN);
|
||||
|
||||
udp_stun_found:
|
||||
udp_stun_found:
|
||||
flow->protos.stun_ssl.stun.num_processed_pkts++;
|
||||
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
@@ -489,7 +485,6 @@ udp_stun_found:
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
void ndpi_search_stun(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
@@ -535,13 +530,12 @@ void ndpi_search_stun(struct ndpi_detection_module_struct *ndpi_struct, struct n
|
||||
return;
|
||||
}
|
||||
|
||||
if(flow->protos.stun_ssl.stun.num_udp_pkts >= MAX_NUM_STUN_PKTS)
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
|
||||
if(flow->packet_counter > 0) {
|
||||
/* This might be a RTP stream: let's make sure we check it */
|
||||
NDPI_CLR(&flow->excluded_protocol_bitmask, NDPI_PROTOCOL_RTP);
|
||||
}
|
||||
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
}
|
||||
|
||||
|
||||
@@ -550,7 +544,7 @@ void init_stun_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int
|
||||
ndpi_set_bitmask_protocol_detection("STUN", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_STUN,
|
||||
ndpi_search_stun,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP_WITH_PAYLOAD,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
|
||||
+19
-14
@@ -41,26 +41,31 @@ void ndpi_search_tftp(struct ndpi_detection_module_struct
|
||||
|
||||
NDPI_LOG_DBG(ndpi_struct, "search TFTP\n");
|
||||
|
||||
if (packet->payload_packet_len > 3 && flow->l4.udp.tftp_stage == 0
|
||||
&& ntohl(get_u_int32_t(packet->payload, 0)) == 0x00030001) {
|
||||
if ((packet->payload_packet_len > 3)
|
||||
&& (flow->l4.udp.tftp_stage == 0)
|
||||
&& (ntohl(get_u_int32_t(packet->payload, 0)) == 0x00030001)) {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "maybe tftp. need next packet\n");
|
||||
flow->l4.udp.tftp_stage = 1;
|
||||
return;
|
||||
}
|
||||
if (packet->payload_packet_len > 3 && (flow->l4.udp.tftp_stage == 1)
|
||||
&& ntohl(get_u_int32_t(packet->payload, 0)) == 0x00040001) {
|
||||
|
||||
NDPI_LOG_INFO(ndpi_struct, "found tftp\n");
|
||||
ndpi_int_tftp_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
if (packet->payload_packet_len > 1
|
||||
&& ((packet->payload[0] == 0 && packet->payload[packet->payload_packet_len - 1] == 0)
|
||||
|| (packet->payload_packet_len == 4 && ntohl(get_u_int32_t(packet->payload, 0)) == 0x00040000))) {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "skip initial packet\n");
|
||||
return;
|
||||
}
|
||||
if(flow->l4.udp.tftp_stage == 1) {
|
||||
if (packet->payload_packet_len > 3 && (flow->l4.udp.tftp_stage == 1)
|
||||
&& ntohl(get_u_int32_t(packet->payload, 0)) == 0x00040001) {
|
||||
|
||||
NDPI_LOG_INFO(ndpi_struct, "found tftp\n");
|
||||
ndpi_int_tftp_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
|
||||
if (packet->payload_packet_len > 1
|
||||
&& ((packet->payload[0] == 0 && packet->payload[packet->payload_packet_len - 1] == 0)
|
||||
|| (packet->payload_packet_len == 4 && ntohl(get_u_int32_t(packet->payload, 0)) == 0x00040000))) {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "skip initial packet\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
}
|
||||
|
||||
|
||||
@@ -58,9 +58,9 @@ static void ndpi_check_tinc(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_TINC, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
return;
|
||||
|
||||
} else if(packet->tcp != NULL) {
|
||||
if(payload_len == 0) {
|
||||
if(packet->tcp->syn == 1 && packet->tcp->ack == 0) {
|
||||
|
||||
Reference in New Issue
Block a user