deleted useless or not used functions and #ifdef

This commit is contained in:
Campus
2015-11-10 01:12:00 +01:00
parent 0cd8d939f1
commit 78eceb43a1
5 changed files with 67 additions and 136 deletions
+2 -2
View File
@@ -994,8 +994,8 @@ static void setupDetection(u_int16_t thread_id) {
ndpi_set_protocol_detection_bitmask2(ndpi_thread_info[thread_id].ndpi_struct, &all); ndpi_set_protocol_detection_bitmask2(ndpi_thread_info[thread_id].ndpi_struct, &all);
// allocate memory for id and flow tracking // allocate memory for id and flow tracking
size_id_struct = ndpi_detection_get_sizeof_ndpi_id_struct(); size_id_struct = sizeof(struct ndpi_id_struct);
size_flow_struct = ndpi_detection_get_sizeof_ndpi_flow_struct(); size_flow_struct = sizeof(struct ndpi_flow_struct);
// clear memory for results // clear memory for results
memset(ndpi_thread_info[thread_id].stats.protocol_counter, 0, sizeof(ndpi_thread_info[thread_id].stats.protocol_counter)); memset(ndpi_thread_info[thread_id].stats.protocol_counter, 0, sizeof(ndpi_thread_info[thread_id].stats.protocol_counter));
+2 -22
View File
@@ -32,26 +32,14 @@
extern "C" { extern "C" {
#endif #endif
/**
* This function returns the size of the flow struct
* @return the size of the flow struct
*/
u_int32_t ndpi_detection_get_sizeof_ndpi_flow_struct(void);
/**
* This function returns the size of the id struct
* @return the size of the id struct
*/
u_int32_t ndpi_detection_get_sizeof_ndpi_id_struct(void);
/* Public malloc/free */ /* Public malloc/free */
void* ndpi_malloc(unsigned long size); void* ndpi_malloc(unsigned long size);
void* ndpi_calloc(unsigned long count, unsigned long size); void* ndpi_calloc(unsigned long count, unsigned long size);
void ndpi_free(void *ptr); void ndpi_free(void *ptr);
void *ndpi_realloc(void *ptr, size_t old_size, size_t new_size); void *ndpi_realloc(void *ptr, size_t old_size, size_t new_size);
char *ndpi_strdup(const char *s); char *ndpi_strdup(const char *s);
/*
/**
* Find the first occurrence of find in s, where the search is limited to the * Find the first occurrence of find in s, where the search is limited to the
* first slen characters of s. * first slen characters of s.
*/ */
@@ -150,14 +138,6 @@ extern "C" {
*/ */
u_int8_t ndpi_detection_get_l4(const u_int8_t * l3, u_int16_t l3_len, const u_int8_t ** l4_return, u_int16_t * l4_len_return, u_int8_t ndpi_detection_get_l4(const u_int8_t * l3, u_int16_t l3_len, const u_int8_t ** l4_return, u_int16_t * l4_len_return,
u_int8_t * l4_protocol_return, u_int32_t flags); u_int8_t * l4_protocol_return, u_int32_t flags);
/**
* returns the real protocol for the flow of the last packet given to the detection.
* if no real protocol could be found, the unknown protocol will be returned.
*
* @param ndpi_struct the detection module
* @return the protocol id of the last real protocol found in the protocol history of the flow
*/
/* u_int16_t ndpi_detection_get_real_protocol_of_flow(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); */
/** /**
* returns true if the protocol history of the flow of the last packet given to the detection * returns true if the protocol history of the flow of the last packet given to the detection
+15 -19
View File
@@ -55,6 +55,7 @@
#include "ndpi_protocol_ids.h" #include "ndpi_protocol_ids.h"
#include "ndpi_typedefs.h" #include "ndpi_typedefs.h"
#include "ndpi_protocols.h" #include "ndpi_protocols.h"
#include "ndpi_api.h"
void *ndpi_tdelete(const void * __restrict, void ** __restrict, void *ndpi_tdelete(const void * __restrict, void ** __restrict,
@@ -89,43 +90,40 @@ void ndpi_set_detected_protocol(struct ndpi_detection_module_struct *ndpi_struct
u_int16_t upper_detected_protocol, u_int16_t upper_detected_protocol,
u_int16_t lower_detected_protocol); u_int16_t lower_detected_protocol);
/* function to parse a packet which has line based information into a line based structure
* this function will also set some well known line pointers like:
* - host, user agent, empty line,....
*/
extern void ndpi_parse_packet_line_info(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); extern void ndpi_parse_packet_line_info(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
extern void ndpi_parse_packet_line_info_any(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); extern void ndpi_parse_packet_line_info_any(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
extern u_int16_t ndpi_check_for_email_address(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow, u_int16_t counter); extern u_int16_t ndpi_check_for_email_address(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow, u_int16_t counter);
extern void ndpi_int_change_packet_protocol(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow, extern void ndpi_int_change_packet_protocol(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow,
u_int16_t upper_detected_protocol, u_int16_t upper_detected_protocol,
u_int16_t lower_detected_protocol); u_int16_t lower_detected_protocol);
extern void ndpi_int_change_protocol(struct ndpi_detection_module_struct *ndpi_struct, extern void ndpi_int_change_protocol(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow,
struct ndpi_flow_struct *flow,
u_int16_t upper_detected_protocol, u_int16_t upper_detected_protocol,
u_int16_t lower_detected_protocol); u_int16_t lower_detected_protocol);
extern void ndpi_set_proto_defaults(struct ndpi_detection_module_struct *ndpi_mod, extern void ndpi_set_proto_defaults(struct ndpi_detection_module_struct *ndpi_mod, ndpi_protocol_breed_t protoBreed, u_int16_t protoId,
ndpi_protocol_breed_t protoBreed, u_int16_t protoId, u_int16_t tcp_alias_protoId[2], u_int16_t udp_alias_protoId[2], char *protoName,
u_int16_t tcp_alias_protoId[2], u_int16_t udp_alias_protoId[2],
char *protoName,
ndpi_port_range *tcpDefPorts, ndpi_port_range *udpDefPorts); ndpi_port_range *tcpDefPorts, ndpi_port_range *udpDefPorts);
extern void ndpi_int_reset_packet_protocol(struct ndpi_packet_struct *packet); extern void ndpi_int_reset_packet_protocol(struct ndpi_packet_struct *packet);
extern void ndpi_int_reset_protocol(struct ndpi_flow_struct *flow); extern void ndpi_int_reset_protocol(struct ndpi_flow_struct *flow);
extern int ndpi_packet_src_ip_eql(const struct ndpi_packet_struct *packet, const ndpi_ip_addr_t * ip); extern int ndpi_packet_src_ip_eql(const struct ndpi_packet_struct *packet, const ndpi_ip_addr_t * ip);
extern int ndpi_packet_dst_ip_eql(const struct ndpi_packet_struct *packet, const ndpi_ip_addr_t * ip); extern int ndpi_packet_dst_ip_eql(const struct ndpi_packet_struct *packet, const ndpi_ip_addr_t * ip);
extern void ndpi_packet_src_ip_get(const struct ndpi_packet_struct *packet, ndpi_ip_addr_t * ip); extern void ndpi_packet_src_ip_get(const struct ndpi_packet_struct *packet, ndpi_ip_addr_t * ip);
extern void ndpi_packet_dst_ip_get(const struct ndpi_packet_struct *packet, ndpi_ip_addr_t * ip); extern void ndpi_packet_dst_ip_get(const struct ndpi_packet_struct *packet, ndpi_ip_addr_t * ip);
extern char *ndpi_get_ip_string(struct ndpi_detection_module_struct *ndpi_struct, const ndpi_ip_addr_t * ip); extern char *ndpi_get_ip_string(struct ndpi_detection_module_struct *ndpi_struct, const ndpi_ip_addr_t * ip);
extern char *ndpi_get_packet_src_ip_string(struct ndpi_detection_module_struct *ndpi_struct, extern char *ndpi_get_packet_src_ip_string(struct ndpi_detection_module_struct *ndpi_struct, const struct ndpi_packet_struct *packet);
const struct ndpi_packet_struct *packet);
extern char* ndpi_get_proto_by_id(struct ndpi_detection_module_struct *ndpi_mod, u_int id); extern char* ndpi_get_proto_by_id(struct ndpi_detection_module_struct *ndpi_mod, u_int id);
extern u_int16_t ndpi_guess_protocol_id(struct ndpi_detection_module_struct *ndpi_struct, extern u_int16_t ndpi_guess_protocol_id(struct ndpi_detection_module_struct *ndpi_struct,
u_int8_t proto, u_int16_t sport, u_int16_t dport); u_int8_t proto, u_int16_t sport, u_int16_t dport);
extern u_int8_t ndpi_is_proto(ndpi_protocol p, u_int16_t proto); extern u_int8_t ndpi_is_proto(ndpi_protocol p, u_int16_t proto);
extern u_int16_t ndpi_get_lower_proto(ndpi_protocol p); extern u_int16_t ndpi_get_lower_proto(ndpi_protocol p);
extern int ndpi_get_protocol_id_master_proto(struct ndpi_detection_module_struct *ndpi_struct, extern int ndpi_get_protocol_id_master_proto(struct ndpi_detection_module_struct *ndpi_struct, u_int16_t protocol_id,
u_int16_t protocol_id,
u_int16_t** tcp_master_proto, u_int16_t** tcp_master_proto,
u_int16_t** udp_master_proto); u_int16_t** udp_master_proto);
@@ -134,6 +132,4 @@ void ndpi_debug_get_last_log_function_line(struct ndpi_detection_module_struct *
const char **file, const char **func, u_int32_t * line); const char **file, const char **func, u_int32_t * line);
#endif #endif
#include "ndpi_api.h"
#endif /* __NDPI_MAIN_INCLUDE_FILE__ */ #endif /* __NDPI_MAIN_INCLUDE_FILE__ */
+7 -10
View File
@@ -314,16 +314,13 @@ typedef enum {
} ndpi_http_method; } ndpi_http_method;
typedef struct ndpi_id_struct { typedef struct ndpi_id_struct {
/* detected_protocol_bitmask:
* access this bitmask to find out whether an id has used skype or not /**
* if a flag is set here, it will not be resetted detected_protocol_bitmask:
* to compare this, use: access this bitmask to find out whether an id has used skype or not
* if (NDPI_BITMASK_COMPARE(id->detected_protocol_bitmask, if a flag is set here, it will not be resetted
* NDPI_PROTOCOL_BITMASK_XXX) != 0) to compare this, use:
* { **/
* // protocol XXX detected on this id
* }
*/
NDPI_PROTOCOL_BITMASK detected_protocol_bitmask; NDPI_PROTOCOL_BITMASK detected_protocol_bitmask;
#ifdef NDPI_PROTOCOL_RTSP #ifdef NDPI_PROTOCOL_RTSP
ndpi_ip_addr_t rtsp_ip_address; ndpi_ip_addr_t rtsp_ip_address;
+41 -83
View File
@@ -29,8 +29,6 @@
#include "ndpi_api.h" #include "ndpi_api.h"
#include "../../config.h" #include "../../config.h"
// #define DEBUG
#include <time.h> #include <time.h>
#ifndef WIN32 #ifndef WIN32
#include <unistd.h> #include <unistd.h>
@@ -40,12 +38,9 @@
#include "third_party/include/ndpi_patricia.h" #include "third_party/include/ndpi_patricia.h"
#include "third_party/src/ndpi_patricia.c" #include "third_party/src/ndpi_patricia.c"
#ifdef WIN32 /* #ifndef strtok_r */
/* http://social.msdn.microsoft.com/Forums/uk/vcgeneral/thread/963aac07-da1a-4612-be4a-faac3f1d65ca */ /* #define strtok_r(a,b,c) strtok(a,b) */
#ifndef strtok_r /* #endif */
#define strtok_r(a,b,c) strtok(a,b)
#endif
#endif
/* ftp://ftp.cc.uoc.gr/mirrors/OpenBSD/src/lib/libc/stdlib/tsearch.c */ /* ftp://ftp.cc.uoc.gr/mirrors/OpenBSD/src/lib/libc/stdlib/tsearch.c */
/* find or insert datum into search tree */ /* find or insert datum into search tree */
@@ -344,19 +339,6 @@ char *ndpi_strdup(const char *s) {
return(m); return(m);
} }
/* ****************************************** */
u_int32_t ndpi_detection_get_sizeof_ndpi_flow_struct(void)
{
return sizeof(struct ndpi_flow_struct);
}
/* ****************************************** */
u_int32_t ndpi_detection_get_sizeof_ndpi_id_struct(void)
{
return sizeof(struct ndpi_id_struct);
}
/* ******************************************************************** */ /* ******************************************************************** */
@@ -439,15 +421,6 @@ void ndpi_set_proto_defaults(struct ndpi_detection_module_struct *ndpi_mod,
if(udpDefPorts[j].port_low != 0) addDefaultPort(&udpDefPorts[j], &ndpi_mod->proto_defaults[protoId], &ndpi_mod->udpRoot); if(udpDefPorts[j].port_low != 0) addDefaultPort(&udpDefPorts[j], &ndpi_mod->proto_defaults[protoId], &ndpi_mod->udpRoot);
if(tcpDefPorts[j].port_low != 0) addDefaultPort(&tcpDefPorts[j], &ndpi_mod->proto_defaults[protoId], &ndpi_mod->tcpRoot); if(tcpDefPorts[j].port_low != 0) addDefaultPort(&tcpDefPorts[j], &ndpi_mod->proto_defaults[protoId], &ndpi_mod->tcpRoot);
} }
#if 0
printf("%s(%d, %s, %p) [%s]\n",
__FUNCTION__,
protoId,
ndpi_mod->proto_defaults[protoId].protoName,
ndpi_mod,
ndpi_mod->proto_defaults[1].protoName);
#endif
} }
/* ******************************************************************** */ /* ******************************************************************** */
@@ -2547,8 +2520,7 @@ void ndpi_set_protocol_detection_bitmask2(struct ndpi_detection_module_struct *n
* nxt_hdr: protocol of the actual payload * nxt_hdr: protocol of the actual payload
* returns 0 upon success and 1 upon failure * returns 0 upon success and 1 upon failure
*/ */
static int ndpi_handle_ipv6_extension_headers(struct ndpi_detection_module_struct *ndpi_struct, static int ndpi_handle_ipv6_extension_headers(struct ndpi_detection_module_struct *ndpi_struct, const u_int8_t ** l4ptr, u_int16_t * l4len, u_int8_t * nxt_hdr)
const u_int8_t ** l4ptr, u_int16_t * l4len, u_int8_t * nxt_hdr)
{ {
while ((*nxt_hdr == 0 || *nxt_hdr == 43 || *nxt_hdr == 44 || *nxt_hdr == 60 || *nxt_hdr == 135 || *nxt_hdr == 59)) { while ((*nxt_hdr == 0 || *nxt_hdr == 43 || *nxt_hdr == 44 || *nxt_hdr == 60 || *nxt_hdr == 135 || *nxt_hdr == 59)) {
u_int16_t ehdr_len; u_int16_t ehdr_len;
@@ -2683,11 +2655,6 @@ static u_int8_t ndpi_detection_get_l4_internal(struct ndpi_detection_module_stru
return 0; return 0;
} }
#if !defined(WIN32)
#define ATTRIBUTE_ALWAYS_INLINE static inline
#else
__forceinline static
#endif
void ndpi_apply_flow_protocol_to_packet(struct ndpi_flow_struct *flow, void ndpi_apply_flow_protocol_to_packet(struct ndpi_flow_struct *flow,
struct ndpi_packet_struct *packet) struct ndpi_packet_struct *packet)
{ {
@@ -2813,12 +2780,6 @@ static int ndpi_init_packet_header(struct ndpi_detection_module_struct *ndpi_str
return 0; return 0;
} }
#if !defined(WIN32)
static inline
#else
__forceinline static
#endif
void ndpi_connection_tracking(struct ndpi_detection_module_struct *ndpi_struct, void ndpi_connection_tracking(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow) struct ndpi_flow_struct *flow)
{ {
@@ -2831,9 +2792,6 @@ void ndpi_connection_tracking(struct ndpi_detection_module_struct *ndpi_struct,
const struct ndpi_tcphdr *tcph = packet->tcp; const struct ndpi_tcphdr *tcph = packet->tcp;
const struct ndpi_udphdr *udph = flow->packet.udp; const struct ndpi_udphdr *udph = flow->packet.udp;
//struct ndpi_unique_flow_struct unique_flow;
//uint8_t new_connection;
u_int8_t proxy_enabled = 0; u_int8_t proxy_enabled = 0;
packet->tcp_retransmission = 0, packet->packet_direction = 0; packet->tcp_retransmission = 0, packet->packet_direction = 0;
@@ -4418,44 +4376,44 @@ void NDPI_DUMP_BITMASK(NDPI_PROTOCOL_BITMASK a) {
} }
#ifdef WIN32 /* #ifdef WIN32 */
/* http://www.opensource.apple.com/source/xnu/xnu-1456.1.26/bsd/libkern/strsep.c */ /* /\* http://www.opensource.apple.com/source/xnu/xnu-1456.1.26/bsd/libkern/strsep.c *\/ */
/* /* /\* */
* Get next token from string *stringp, where tokens are possibly-empty /* * Get next token from string *stringp, where tokens are possibly-empty */
* strings separated by characters from delim. /* * strings separated by characters from delim. */
* /* * */
* Writes NULs into the string at *stringp to end tokens. /* * Writes NULs into the string at *stringp to end tokens. */
* delim need not remain constant from call to call. /* * delim need not remain constant from call to call. */
* On return, *stringp points past the last NUL written (if there might /* * On return, *stringp points past the last NUL written (if there might */
* be further tokens), or is NULL (if there are definitely no more tokens). /* * be further tokens), or is NULL (if there are definitely no more tokens). */
* /* * */
* If *stringp is NULL, strsep returns NULL. /* * If *stringp is NULL, strsep returns NULL. */
*/ /* *\/ */
char* strsep(char **stringp, const char *delim) { /* char* strsep(char **stringp, const char *delim) { */
char *s; /* char *s; */
const char *spanp; /* const char *spanp; */
int c, sc; /* int c, sc; */
char *tok; /* char *tok; */
if((s = *stringp) == NULL) /* if((s = *stringp) == NULL) */
return (NULL); /* return (NULL); */
for(tok = s;;) { /* for(tok = s;;) { */
c = *s++; /* c = *s++; */
spanp = delim; /* spanp = delim; */
do { /* do { */
if((sc = *spanp++) == c) { /* if((sc = *spanp++) == c) { */
if(c == 0) /* if(c == 0) */
s = NULL; /* s = NULL; */
else /* else */
s[-1] = 0; /* s[-1] = 0; */
*stringp = s; /* *stringp = s; */
return (tok); /* return (tok); */
} /* } */
} while (sc != 0); /* } while (sc != 0); */
} /* } */
/* NOTREACHED */ /* /\* NOTREACHED *\/ */
} /* } */
#endif /* #endif */