removed kernel support and #if 0s
This commit is contained in:
@@ -653,16 +653,6 @@ static void node_proto_guess_walker(const void *node, ndpi_VISIT which, int dept
|
||||
struct ndpi_flow *flow = *(struct ndpi_flow **) node;
|
||||
u_int16_t thread_id = *((u_int16_t *) user_data);
|
||||
|
||||
#if 0
|
||||
printf("<%d>Walk on node %s (%p)\n",
|
||||
depth,
|
||||
which == preorder?"preorder":
|
||||
which == postorder?"postorder":
|
||||
which == endorder?"endorder":
|
||||
which == leaf?"leaf": "unknown",
|
||||
flow);
|
||||
#endif
|
||||
|
||||
if((which == ndpi_preorder) || (which == ndpi_leaf)) { /* Avoid walking the same node multiple times */
|
||||
if(enable_protocol_guess) {
|
||||
if(flow->detected_protocol.protocol == NDPI_PROTOCOL_UNKNOWN) {
|
||||
@@ -1083,31 +1073,6 @@ static unsigned int packet_processing(u_int16_t thread_id,
|
||||
snprintf(flow->ssl.server_certificate, sizeof(flow->ssl.server_certificate), "%s", flow->ndpi_flow->protos.ssl.server_certificate);
|
||||
}
|
||||
|
||||
#if 0
|
||||
if(verbose > 1) {
|
||||
if(ndpi_is_proto(flow->detected_protocol, NDPI_PROTOCOL_HTTP)) {
|
||||
char *method;
|
||||
|
||||
printf("[URL] %s\n", ndpi_get_http_url(ndpi_thread_info[thread_id].ndpi_struct, ndpi_flow));
|
||||
printf("[Content-Type] %s\n", ndpi_get_http_content_type(ndpi_thread_info[thread_id].ndpi_struct, ndpi_flow));
|
||||
|
||||
switch(ndpi_get_http_method(ndpi_thread_info[thread_id].ndpi_struct, ndpi_flow)) {
|
||||
case HTTP_METHOD_OPTIONS: method = "HTTP_METHOD_OPTIONS"; break;
|
||||
case HTTP_METHOD_GET: method = "HTTP_METHOD_GET"; break;
|
||||
case HTTP_METHOD_HEAD: method = "HTTP_METHOD_HEAD"; break;
|
||||
case HTTP_METHOD_POST: method = "HTTP_METHOD_POST"; break;
|
||||
case HTTP_METHOD_PUT: method = "HTTP_METHOD_PUT"; break;
|
||||
case HTTP_METHOD_DELETE: method = "HTTP_METHOD_DELETE"; break;
|
||||
case HTTP_METHOD_TRACE: method = "HTTP_METHOD_TRACE"; break;
|
||||
case HTTP_METHOD_CONNECT: method = "HTTP_METHOD_CONNECT"; break;
|
||||
default: method = "HTTP_METHOD_UNKNOWN"; break;
|
||||
}
|
||||
|
||||
printf("[Method] %s\n", method);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
free_ndpi_flow(flow);
|
||||
|
||||
if(verbose > 1) {
|
||||
@@ -1122,11 +1087,6 @@ static unsigned int packet_processing(u_int16_t thread_id,
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if(ndpi_flow->l4.tcp.host_server_name[0] != '\0')
|
||||
printf("%s\n", ndpi_flow->l4.tcp.host_server_name);
|
||||
#endif
|
||||
|
||||
if(live_capture) {
|
||||
if(ndpi_thread_info[thread_id].last_idle_scan_time + IDLE_SCAN_PERIOD < ndpi_thread_info[thread_id].last_time) {
|
||||
/* scan for idle flows */
|
||||
@@ -2077,16 +2037,6 @@ struct timezone {
|
||||
|
||||
/* ***************************************************** */
|
||||
|
||||
#if 0
|
||||
int gettimeofday(struct timeval *tv, void *notUsed) {
|
||||
tv->tv_sec = time(NULL);
|
||||
tv->tv_usec = 0;
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ***************************************************** */
|
||||
|
||||
int gettimeofday(struct timeval *tv, struct timezone *tz) {
|
||||
FILETIME ft;
|
||||
LARGE_INTEGER li;
|
||||
|
||||
@@ -42,12 +42,6 @@
|
||||
#endif/* BYTE_ORDER */
|
||||
#endif/* __OPENBSD__ */
|
||||
|
||||
#if 0
|
||||
#ifndef NDPI_ENABLE_DEBUG_MESSAGES
|
||||
#define NDPI_ENABLE_DEBUG_MESSAGES
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#define __LITTLE_ENDIAN__ 1
|
||||
#endif
|
||||
|
||||
+3
-22
@@ -3171,16 +3171,7 @@ ndpi_protocol ndpi_detection_process_packet(struct ndpi_detection_module_struct
|
||||
goto ret_protocols;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
a = flow->detected_protocol_stack[0];
|
||||
if(a != NDPI_PROTOCOL_UNKNOWN) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNKNOWN, ndpi_struct, NDPI_LOG_TRACE, "PROCESS KNOWN PROTOCOL\n");
|
||||
ndpi_struct->proto_defaults[a].func(ndpi_struct, flow);
|
||||
return a;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
check_ndpi_flow_func(ndpi_struct, flow, &ndpi_selection_packet);
|
||||
|
||||
a = flow->packet.detected_protocol_stack[0];
|
||||
@@ -3216,18 +3207,8 @@ ndpi_protocol ndpi_detection_process_packet(struct ndpi_detection_module_struct
|
||||
flow->host_already_guessed = 1;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Swap protocols in case of success */
|
||||
if(ret.master_protocol != NDPI_PROTOCOL_UNKNOWN) {
|
||||
u_int16_t t = ret.master_protocol;
|
||||
|
||||
ret.master_protocol = ret.protocol;
|
||||
ret.protocol = t;
|
||||
}
|
||||
#endif
|
||||
|
||||
if((ret.protocol == NDPI_PROTOCOL_UNKNOWN) && (ret.master_protocol != NDPI_PROTOCOL_UNKNOWN))
|
||||
ret.protocol = flow->guessed_host_proto_id;
|
||||
if((ret.protocol == NDPI_PROTOCOL_UNKNOWN) && (ret.master_protocol != NDPI_PROTOCOL_UNKNOWN))
|
||||
ret.protocol = flow->guessed_host_proto_id;
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@@ -432,14 +432,7 @@ void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
u_int32_t ts = ntohl(*((u_int32_t*)&(packet->payload[4])));
|
||||
u_int32_t now;
|
||||
|
||||
#ifndef __KERNEL__
|
||||
now = (u_int32_t)time(NULL);
|
||||
#else
|
||||
struct timespec t;
|
||||
|
||||
getnstimeofday(&t);
|
||||
now = t.tv_sec;
|
||||
#endif
|
||||
|
||||
if((ts < (now+86400)) && (ts > (now-86400))) {
|
||||
goto bittorrent_found;
|
||||
|
||||
@@ -42,8 +42,6 @@ typedef signed long long int i_int64_t;
|
||||
|
||||
#include "btlib.h"
|
||||
|
||||
#ifndef __KERNEL__
|
||||
|
||||
int bt_parse_debug = 0;
|
||||
|
||||
static char *printXb(char *s,const u_int8_t *b,int l) {
|
||||
@@ -183,11 +181,8 @@ static void _print_safe_str(char *msg,char *k,const u_int8_t *s,size_t l) {
|
||||
static void print_safe_str(char *msg,bt_parse_data_cb_t *cbd) {
|
||||
_print_safe_str(msg,cbd->buf,cbd->v.s.s,cbd->v.s.l);
|
||||
}
|
||||
#define DEBUG_TRACE(cmd) { if(bt_parse_debug) cmd; }
|
||||
#else
|
||||
#define DEBUG_TRACE(cmd,args...)
|
||||
#endif /* __KERNEL */
|
||||
|
||||
#define DEBUG_TRACE(cmd) { if(bt_parse_debug) cmd; }
|
||||
#define STREQ(a,b) !strcmp(a,b)
|
||||
|
||||
|
||||
|
||||
@@ -139,9 +139,7 @@ typedef struct bt_parse_data_cb {
|
||||
} v;
|
||||
} bt_parse_data_cb_t;
|
||||
|
||||
#ifndef __KERNEL__
|
||||
extern int bt_parse_debug;
|
||||
void dump_bt_proto_struct(struct bt_parse_protocol *p);
|
||||
#endif
|
||||
const u_int8_t *bt_decode(const u_int8_t *b, size_t *l, int *ret, bt_parse_data_cb_t *cbd);
|
||||
|
||||
|
||||
@@ -33,14 +33,6 @@ static void ndpi_check_citrix(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
u_int32_t payload_len = packet->payload_packet_len;
|
||||
|
||||
#if 0
|
||||
printf("[len=%u][%02X %02X %02X %02X]\n", payload_len,
|
||||
packet->payload[0] & 0xFF,
|
||||
packet->payload[1] & 0xFF,
|
||||
packet->payload[2] & 0xFF,
|
||||
packet->payload[3] & 0xFF);
|
||||
#endif
|
||||
|
||||
if(packet->tcp != NULL) {
|
||||
flow->l4.tcp.citrix_packet_id++;
|
||||
|
||||
@@ -70,7 +62,6 @@ static void ndpi_check_citrix(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_CITRIX);
|
||||
} else if(flow->l4.tcp.citrix_packet_id > 3)
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_CITRIX);
|
||||
|
||||
@@ -709,23 +709,10 @@ void ndpi_search_direct_download_link_tcp(struct ndpi_detection_module_struct *n
|
||||
{
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
|
||||
// struct ndpi_id_struct *src=ndpi_struct->src;
|
||||
// struct ndpi_id_struct *dst=ndpi_struct->dst;
|
||||
#if 0
|
||||
if (ndpi_struct->direct_download_link_counter_callback != NULL) {
|
||||
if (packet->detected_protocol == NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK) {
|
||||
/* skip packets not requests from the client to the server */
|
||||
if (packet->packet_direction == flow->l4.tcp.ddlink_server_direction) {
|
||||
search_ddl_domains(ndpi_struct, flow); // do the detection again in order to get the URL in keep alive streams
|
||||
} else {
|
||||
// just count the packet
|
||||
ndpi_struct->direct_download_link_counter_callback(flow->hash_id_number, packet->l3_packet_len);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
// do not detect again if it is already ddl
|
||||
/* struct ndpi_id_struct *src=ndpi_struct->src; */
|
||||
/* struct ndpi_id_struct *dst=ndpi_struct->dst; */
|
||||
|
||||
/* do not detect again if it is already ddl */
|
||||
if (packet->detected_protocol_stack[0] != NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK) {
|
||||
if (search_ddl_domains(ndpi_struct, flow) != 0) {
|
||||
return;
|
||||
|
||||
@@ -35,14 +35,6 @@ static void ndpi_check_gtp(struct ndpi_detection_module_struct *ndpi_struct, str
|
||||
// const u_int8_t *packet_payload = packet->payload;
|
||||
u_int32_t payload_len = packet->payload_packet_len;
|
||||
|
||||
#if 0
|
||||
printf("[len=%u][%02X %02X %02X %02X]\n", payload_len,
|
||||
packet->payload[0] & 0xFF,
|
||||
packet->payload[1] & 0xFF,
|
||||
packet->payload[2] & 0xFF,
|
||||
packet->payload[3] & 0xFF);
|
||||
#endif
|
||||
|
||||
if((packet->udp != NULL) && (payload_len > sizeof(struct gtp_header_generic))) {
|
||||
u_int32_t gtp_u = ntohs(2152);
|
||||
u_int32_t gtp_c = ntohs(2123);
|
||||
|
||||
@@ -349,14 +349,6 @@ static void check_content_type_and_change_protocol(struct ndpi_detection_module_
|
||||
|
||||
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "User Agent Type Line found %.*s\n",
|
||||
packet->user_agent_line.len, packet->user_agent_line.ptr);
|
||||
|
||||
#if 0
|
||||
if((ndpi_struct->http_dont_dissect_response) || flow->http_detected)
|
||||
ndpi_match_content_subprotocol(ndpi_struct, flow,
|
||||
(char*)packet->user_agent_line.ptr,
|
||||
packet->user_agent_line.len,
|
||||
NDPI_PROTOCOL_HTTP);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* check for host line */
|
||||
|
||||
@@ -35,20 +35,6 @@ static void ndpi_check_lotus_notes(struct ndpi_detection_module_struct *ndpi_str
|
||||
if(packet->tcp != NULL) {
|
||||
flow->l4.tcp.lotus_notes_packet_id++;
|
||||
|
||||
#if 0
|
||||
printf("[lotus_notes_packet_id: %u][len=%u][%02X %02X %02X %02X %02X %02X %02X %02X]\n",
|
||||
flow->l4.tcp.lotus_notes_packet_id, payload_len,
|
||||
packet->payload[6] & 0xFF,
|
||||
packet->payload[7] & 0xFF,
|
||||
packet->payload[8] & 0xFF,
|
||||
packet->payload[9] & 0xFF,
|
||||
packet->payload[10] & 0xFF,
|
||||
packet->payload[11] & 0xFF,
|
||||
packet->payload[12] & 0xFF,
|
||||
packet->payload[13] & 0xFF
|
||||
);
|
||||
#endif
|
||||
|
||||
if((flow->l4.tcp.lotus_notes_packet_id == 1)
|
||||
/* We have seen the 3-way handshake */
|
||||
&& flow->l4.tcp.seen_syn
|
||||
|
||||
@@ -23,12 +23,10 @@
|
||||
|
||||
#ifdef NDPI_PROTOCOL_NETFLOW
|
||||
|
||||
#ifndef __KERNEL__
|
||||
#ifdef WIN32
|
||||
extern int gettimeofday(struct timeval * tp, struct timezone * tzp);
|
||||
#endif
|
||||
#define do_gettimeofday(a) gettimeofday(a, NULL)
|
||||
#endif
|
||||
|
||||
struct flow_ver1_rec {
|
||||
u_int32_t srcaddr; /* Source IP Address */
|
||||
|
||||
@@ -35,14 +35,6 @@ static void ndpi_check_radius(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
// const u_int8_t *packet_payload = packet->payload;
|
||||
u_int32_t payload_len = packet->payload_packet_len;
|
||||
|
||||
#if 0
|
||||
printf("[len=%u][%02X %02X %02X %02X]\n", payload_len,
|
||||
packet->payload[0] & 0xFF,
|
||||
packet->payload[1] & 0xFF,
|
||||
packet->payload[2] & 0xFF,
|
||||
packet->payload[3] & 0xFF);
|
||||
#endif
|
||||
|
||||
if(packet->udp != NULL) {
|
||||
struct radius_header *h = (struct radius_header*)packet->payload;
|
||||
u_int len = ntohs(h->len);
|
||||
|
||||
@@ -66,13 +66,11 @@ int ndpi_is_ssl_tor(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
ndpi_int_tor_add_connection(ndpi_struct, flow);
|
||||
return(1);
|
||||
} else {
|
||||
#ifndef __KERNEL__
|
||||
#ifdef PENDANTIC_TOR_CHECK
|
||||
if(gethostbyname(certificate) == NULL) {
|
||||
ndpi_int_tor_add_connection(ndpi_struct, flow);
|
||||
return(1);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
-7
@@ -51,18 +51,13 @@
|
||||
/* { from defs.h */
|
||||
#define prefix_touchar(prefix) ((u_char *)&(prefix)->add.sin)
|
||||
|
||||
#ifdef __KERNEL__
|
||||
#define MAXLINE 512
|
||||
#else
|
||||
#define MAXLINE 1024
|
||||
#endif
|
||||
|
||||
#define BIT_TEST(f, b) ((f) & (b))
|
||||
/* } */
|
||||
|
||||
#define addroute make_and_lookup
|
||||
|
||||
#ifndef __KERNEL__
|
||||
#include <sys/types.h> /* for u_* definitions (on FreeBSD 5) */
|
||||
#include <errno.h> /* for EAFNOSUPPORT */
|
||||
|
||||
@@ -81,8 +76,6 @@
|
||||
#include <ws2tcpip.h> /* IPv6 */
|
||||
#endif
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
/* { from mrt.h */
|
||||
|
||||
typedef struct the_prefix4_t {
|
||||
|
||||
-4
@@ -18,12 +18,10 @@
|
||||
along with multifast. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __KERNEL__
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
|
||||
#include "ndpi_api.h"
|
||||
#include "ahocorasick.h"
|
||||
@@ -245,7 +243,6 @@ void ac_automata_release (AC_AUTOMATA_t * thiz)
|
||||
ndpi_free(thiz);
|
||||
}
|
||||
|
||||
#ifndef __KERNEL__
|
||||
/******************************************************************************
|
||||
* FUNCTION: ac_automata_display
|
||||
* Prints the automata to output in human readable form. it is useful for
|
||||
@@ -299,7 +296,6 @@ void ac_automata_display (AC_AUTOMATA_t * thiz, char repcast)
|
||||
printf("---------------------------------\n");
|
||||
}
|
||||
}
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
/******************************************************************************
|
||||
* FUNCTION: ac_automata_register_nodeptr
|
||||
|
||||
+12
-40
@@ -39,7 +39,6 @@
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __KERNEL__
|
||||
#include <assert.h> /* assert */
|
||||
#include <ctype.h> /* isdigit */
|
||||
#include <errno.h> /* errno */
|
||||
@@ -54,26 +53,8 @@
|
||||
#include <netinet/in.h> /* BSD, Linux: for inet_addr */
|
||||
#include <arpa/inet.h> /* BSD, Linux, Solaris: for inet_addr */
|
||||
#endif
|
||||
#else
|
||||
#define assert(a) ;
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
#include "ndpi_patricia.h"
|
||||
|
||||
|
||||
#ifdef __KERNEL__
|
||||
|
||||
long atol(const char *nptr) {
|
||||
long l;
|
||||
char *endp;
|
||||
|
||||
l = simple_strtol(nptr, &endp, 10);
|
||||
return(l);
|
||||
}
|
||||
#endif
|
||||
|
||||
// #define PATRICIA_DEBUG
|
||||
|
||||
void ndpi_DeleteEntry(void *a) {
|
||||
ndpi_free(a);
|
||||
}
|
||||
@@ -126,7 +107,7 @@ inet_pton (int af, const char *src, void *dst)
|
||||
}
|
||||
}
|
||||
#ifdef NT
|
||||
#if defined(PATRICIA_IPV6) && (!defined(__KERNEL__))
|
||||
#if defined(PATRICIA_IPV6)
|
||||
else if(af == AF_INET6) {
|
||||
struct in6_addr Address;
|
||||
return (inet6_addr(src, &Address));
|
||||
@@ -175,15 +156,13 @@ ndpi_my_inet_pton (int af, const char *src, void *dst)
|
||||
}
|
||||
memcpy (dst, xp, sizeof(struct in_addr));
|
||||
return (1);
|
||||
#if defined(PATRICIA_IPV6) && (!defined(__KERNEL__))
|
||||
#if defined(PATRICIA_IPV6)
|
||||
} else if(af == AF_INET6) {
|
||||
return (inet_pton (af, src, dst));
|
||||
return (inet_pton (af, src, dst));
|
||||
#endif /* PATRICIA_IPV6 */
|
||||
} else {
|
||||
} else {
|
||||
#ifndef NT
|
||||
#ifndef __KERNEL__
|
||||
errno = EAFNOSUPPORT;
|
||||
#endif
|
||||
errno = EAFNOSUPPORT;
|
||||
#endif /* NT */
|
||||
return -1;
|
||||
}
|
||||
@@ -236,7 +215,7 @@ ndpi_prefix_toa2x (prefix_t *prefix, char *buff, int with_len)
|
||||
}
|
||||
return (buff);
|
||||
}
|
||||
#if defined(PATRICIA_IPV6) && (!defined(__KERNEL__))
|
||||
#if defined(PATRICIA_IPV6)
|
||||
else if(prefix->family == AF_INET6) {
|
||||
char *r;
|
||||
r = (char *) inet_ntop (AF_INET6, &prefix->add.sin6, buff, 48 /* a guess value */ );
|
||||
@@ -274,7 +253,7 @@ ndpi_New_Prefix2 (int family, void *dest, int bitlen, prefix_t *prefix)
|
||||
int dynamic_allocated = 0;
|
||||
int default_bitlen = sizeof(struct in_addr) * 8;
|
||||
|
||||
#if defined(PATRICIA_IPV6) && (!defined(__KERNEL__))
|
||||
#if defined(PATRICIA_IPV6)
|
||||
if(family == AF_INET6) {
|
||||
default_bitlen = sizeof(struct in6_addr) * 8;
|
||||
if(prefix == NULL) {
|
||||
@@ -319,8 +298,7 @@ ndpi_New_Prefix (int family, void *dest, int bitlen)
|
||||
return (ndpi_New_Prefix2 (family, dest, bitlen, NULL));
|
||||
}
|
||||
|
||||
/* ndpi_ascii2prefix
|
||||
*/
|
||||
/* ndpi_ascii2prefix */
|
||||
prefix_t *
|
||||
ndpi_ascii2prefix (int family, char *string)
|
||||
{
|
||||
@@ -328,7 +306,7 @@ ndpi_ascii2prefix (int family, char *string)
|
||||
long maxbitlen = 0;
|
||||
char *cp;
|
||||
struct in_addr sin;
|
||||
#if defined(PATRICIA_IPV6) && (!defined(__KERNEL__))
|
||||
#if defined(PATRICIA_IPV6)
|
||||
struct in6_addr sin6;
|
||||
#endif /* PATRICIA_IPV6 */
|
||||
char save[MAXLINE];
|
||||
@@ -339,7 +317,7 @@ ndpi_ascii2prefix (int family, char *string)
|
||||
/* easy way to handle both families */
|
||||
if(family == 0) {
|
||||
family = AF_INET;
|
||||
#if defined(PATRICIA_IPV6) && (!defined(__KERNEL__))
|
||||
#if defined(PATRICIA_IPV6)
|
||||
if(strchr (string, ':')) family = AF_INET6;
|
||||
#endif /* PATRICIA_IPV6 */
|
||||
}
|
||||
@@ -347,7 +325,7 @@ ndpi_ascii2prefix (int family, char *string)
|
||||
if(family == AF_INET) {
|
||||
maxbitlen = sizeof(struct in_addr) * 8;
|
||||
}
|
||||
#if defined(PATRICIA_IPV6) && (!defined(__KERNEL__))
|
||||
#if defined(PATRICIA_IPV6)
|
||||
else if(family == AF_INET6) {
|
||||
maxbitlen = sizeof(struct in6_addr) * 8;
|
||||
}
|
||||
@@ -373,7 +351,7 @@ ndpi_ascii2prefix (int family, char *string)
|
||||
return (ndpi_New_Prefix (AF_INET, &sin, bitlen));
|
||||
}
|
||||
|
||||
#if defined(PATRICIA_IPV6) && (!defined(__KERNEL__))
|
||||
#if defined(PATRICIA_IPV6)
|
||||
else if(family == AF_INET6) {
|
||||
// Get rid of this with next IPv6 upgrade
|
||||
#if defined(NT) && !defined(HAVE_INET_NTOP)
|
||||
@@ -420,8 +398,6 @@ ndpi_Deref_Prefix (prefix_t * prefix)
|
||||
}
|
||||
}
|
||||
|
||||
/* } */
|
||||
|
||||
/* #define PATRICIA_DEBUG 1 */
|
||||
|
||||
static int num_active_patricia = 0;
|
||||
@@ -446,7 +422,6 @@ ndpi_New_Patricia (int maxbits)
|
||||
* if func is supplied, it will be called as func(node->data)
|
||||
* before deleting the node
|
||||
*/
|
||||
|
||||
void
|
||||
ndpi_Clear_Patricia (patricia_tree_t *patricia, void_fn_t func)
|
||||
{
|
||||
@@ -503,7 +478,6 @@ ndpi_Destroy_Patricia (patricia_tree_t *patricia, void_fn_t func)
|
||||
/*
|
||||
* if func is supplied, it will be called as func(node->prefix, node->data)
|
||||
*/
|
||||
|
||||
void
|
||||
ndpi_patricia_process (patricia_tree_t *patricia, void_fn2_t func)
|
||||
{
|
||||
@@ -1073,5 +1047,3 @@ ndpi_lookup_then_remove (patricia_tree_t *tree, char *string)
|
||||
patricia_remove (tree, node);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* } */
|
||||
|
||||
Vendored
-4
@@ -18,14 +18,10 @@
|
||||
along with multifast. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __KERNEL__
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include "ndpi_api.h"
|
||||
|
||||
#include "../include/node.h"
|
||||
#include "sort.h"
|
||||
|
||||
|
||||
Vendored
-38
@@ -4,9 +4,6 @@
|
||||
* Jan 23 2005 Matt Mackall <mpm@selenic.com>
|
||||
*/
|
||||
|
||||
#ifdef __KERNEL__
|
||||
#include <linux/types.h>
|
||||
#else
|
||||
#ifdef WIN32
|
||||
#include <stdint.h>
|
||||
typedef uint32_t u_int32_t;
|
||||
@@ -15,7 +12,6 @@ typedef uint32_t u_int32_t;
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
/* This is a function ported from the Linux kernel lib/sort.c */
|
||||
|
||||
@@ -94,37 +90,3 @@ void sort(void *_base, size_t num, size_t size,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
/* a simple boot-time regression test */
|
||||
|
||||
int cmpint(const void *a, const void *b)
|
||||
{
|
||||
return *(int *)a - *(int *)b;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int *a, i, r = 1;
|
||||
|
||||
a = ndpi_malloc(1000 * sizeof(int));
|
||||
|
||||
printf("testing sort()\n");
|
||||
|
||||
for (i = 0; i < 1000; i++) {
|
||||
r = (r * 725861) % 6599;
|
||||
a[i] = r;
|
||||
}
|
||||
|
||||
sort(a, 1000, sizeof(int), cmpint, NULL);
|
||||
|
||||
for (i = 0; i < 999; i++)
|
||||
if (a[i] > a[i+1]) {
|
||||
printf("sort() failed!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user