diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/include/linux_compat.h | 2 | ||||
-rw-r--r-- | src/include/ndpi_define.h | 13 | ||||
-rw-r--r-- | src/include/ndpi_main.h | 13 | ||||
-rw-r--r-- | src/include/ndpi_typedefs.h | 7 | ||||
-rw-r--r-- | src/include/ndpi_unix.h | 7 | ||||
-rw-r--r-- | src/lib/ndpi_main.c | 204 |
6 files changed, 1 insertions, 245 deletions
diff --git a/src/include/linux_compat.h b/src/include/linux_compat.h index 57f00d154..25ed2c4e9 100644 --- a/src/include/linux_compat.h +++ b/src/include/linux_compat.h @@ -219,10 +219,8 @@ struct ndpi_ip6_ext #define s6_addr32 u6_addr.u6_addr32 */ #else -#ifndef __KERNEL__ #include <arpa/inet.h> #endif -#endif struct ndpi_in6_addr { union { diff --git a/src/include/ndpi_define.h b/src/include/ndpi_define.h index 4fcdc617f..f938c8ffb 100644 --- a/src/include/ndpi_define.h +++ b/src/include/ndpi_define.h @@ -218,12 +218,7 @@ #define NDPI_COMPARE_IPV6_ADDRESS_STRUCTS(x,y) \ ((((u_int64_t *)(x))[0]) < (((u_int64_t *)(y))[0]) || ( (((u_int64_t *)(x))[0]) == (((u_int64_t *)(y))[0]) && (((u_int64_t *)(x))[1]) < (((u_int64_t *)(y))[1])) ) -#if !defined(__KERNEL__) && !defined(NDPI_IPTABLES_EXT) #define NDPI_NUM_BITS 256 -#else -/* custom protocols not supported */ -#define NDPI_NUM_BITS 192 -#endif #define NDPI_BITS /* 32 */ (sizeof(ndpi_ndpi_mask) * 8 /* number of bits in a byte */) /* bits per mask */ #define howmanybits(x, y) (((x)+((y)-1))/(y)) @@ -289,18 +284,10 @@ #define get_l32(X,O) get_u_int32_t(X,O) #elif defined(__BIG_ENDIAN__) || defined(__BIG_ENDIAN) /* convert the bytes from big to little endian */ -#ifndef __KERNEL__ # define get_l16(X,O) bswap_16(get_u_int16_t(X,O)) # define get_l32(X,O) bswap_32(get_u_int32_t(X,O)) #else -# define get_l16(X,O) __cpu_to_le16(get_u_int16_t(X,O)) -# define get_l32(X,O) __cpu_to_le32(get_u_int32_t(X,O)) -#endif - -#else - #error "__BYTE_ORDER MUST BE DEFINED !" - #endif /* __BYTE_ORDER */ /* define memory callback function */ diff --git a/src/include/ndpi_main.h b/src/include/ndpi_main.h index 1acc5e14f..cb6d9b629 100644 --- a/src/include/ndpi_main.h +++ b/src/include/ndpi_main.h @@ -25,7 +25,6 @@ #ifndef __NDPI_MAIN_INCLUDE_FILE__ #define __NDPI_MAIN_INCLUDE_FILE__ -#ifndef __KERNEL__ #include <stdint.h> #include <stdio.h> #include <stdarg.h> @@ -35,33 +34,21 @@ #endif #include <ctype.h> #include <time.h> -#endif #ifndef WIN32 -#ifndef __KERNEL__ #include <sys/time.h> -#endif #if !defined __APPLE__ && !defined __FreeBSD__ && !defined __NetBSD__ && !defined __OpenBSD__ - -#ifndef __KERNEL__ #include <endian.h> #include <byteswap.h> -#else -#include <asm/byteorder.h> -#include <linux/ctype.h> -#endif - #endif /* default includes */ -#ifndef __KERNEL__ #include <sys/param.h> #include <limits.h> #endif -#endif #include "ndpi_win32.h" #include "ndpi_unix.h" diff --git a/src/include/ndpi_typedefs.h b/src/include/ndpi_typedefs.h index 7f82d0a28..63013230c 100644 --- a/src/include/ndpi_typedefs.h +++ b/src/include/ndpi_typedefs.h @@ -100,7 +100,6 @@ typedef union { #ifdef NDPI_PROTOCOL_BITTORRENT -#ifndef __KERNEL__ typedef struct spinlock { volatile int val; } spinlock_t; @@ -108,8 +107,6 @@ typedef struct atomic { volatile int counter; } atomic_t; -#endif - struct hash_ip4p_node { struct hash_ip4p_node *next,*prev; time_t lchg; @@ -692,11 +689,7 @@ typedef struct ndpi_flow_struct { that identifies the server of this connection */ -#ifndef __KERNEL__ u_char host_server_name[256]; /* HTTP host or DNS query */ -#else - u_char host_server_name[160]; -#endif u_char detected_os[32]; /* Via HTTP User-Agent */ u_char nat_ip[24]; /* Via HTTP X-Forwarded-For */ diff --git a/src/include/ndpi_unix.h b/src/include/ndpi_unix.h index 79de7b43c..d902cd9b2 100644 --- a/src/include/ndpi_unix.h +++ b/src/include/ndpi_unix.h @@ -38,16 +38,9 @@ #endif #ifndef WIN32 -#ifndef __KERNEL__ - #include <netinet/ip.h> #include <netinet/tcp.h> #include <netinet/udp.h> -#else -#include <linux/ip.h> -#include <linux/tcp.h> -#include <linux/udp.h> -#endif #endif #endif /* __NDPI_UNIX_INCLUDE_FILE__ */ diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c index 0aad7bdb4..7f93d9be7 100644 --- a/src/lib/ndpi_main.c +++ b/src/lib/ndpi_main.c @@ -23,30 +23,18 @@ */ -#ifndef __KERNEL__ #include <stdlib.h> #include <errno.h> -#endif - #include "ahocorasick.h" #include "ndpi_api.h" - - -#ifndef __KERNEL__ #include "../../config.h" -#endif // #define DEBUG -#ifdef __KERNEL__ -#include <linux/version.h> -#define printf printk -#else #include <time.h> #ifndef WIN32 #include <unistd.h> #endif -#endif #include "ndpi_content_match.c.inc" #include "third_party/include/ndpi_patricia.h" @@ -59,115 +47,6 @@ #endif #endif -#ifdef __KERNEL__ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39) -static inline char _tolower(const char c) -{ - return c | 0x20; -} - -static int _kstrtoull(const char *s, unsigned int base, unsigned long long *res) -{ - unsigned long long acc; - int ok; - - if(base == 0) { - if(s[0] == '0') { - if(_tolower(s[1]) == 'x' && isxdigit(s[2])) - base = 16; - else - base = 8; - } else - base = 10; - } - if(base == 16 && s[0] == '0' && _tolower(s[1]) == 'x') - s += 2; - - acc = 0; - ok = 0; - while (*s) { - unsigned int val; - - if('0' <= *s && *s <= '9') - val = *s - '0'; - else if('a' <= _tolower(*s) && _tolower(*s) <= 'f') - val = _tolower(*s) - 'a' + 10; - else if(*s == '\n') { - if(*(s + 1) == '\0') - break; - else - return -EINVAL; - } else - return -EINVAL; - - if(val >= base) - return -EINVAL; - if(acc > div_u64(ULLONG_MAX - val, base)) - return -ERANGE; - acc = acc * base + val; - ok = 1; - - s++; - } - if(!ok) - return -EINVAL; - *res = acc; - return 0; -} - -int kstrtoull(const char *s, unsigned int base, unsigned long long *res) -{ - if(s[0] == '+') - s++; - return _kstrtoull(s, base, res); -} -int kstrtoll(const char *s, unsigned int base, long long *res) -{ - unsigned long long tmp; - int rv; - - if(s[0] == '-') { - rv = _kstrtoull(s + 1, base, &tmp); - if(rv < 0) - return rv; - if((long long)(-tmp) >= 0) - return -ERANGE; - *res = -tmp; - } else { - rv = kstrtoull(s, base, &tmp); - if(rv < 0) - return rv; - if((long long)tmp < 0) - return -ERANGE; - *res = tmp; - } - return 0; -} -int kstrtoint(const char *s, unsigned int base, int *res) -{ - long long tmp; - int rv; - - rv = kstrtoll(s, base, &tmp); - if(rv < 0) - return rv; - if(tmp != (long long)(int)tmp) - return -ERANGE; - *res = tmp; - return 0; -} -#endif - -int atoi(const char *str) { - int rc; - - if(kstrtoint(str, 0, &rc) == 0 /* Success */) - return(rc); - else - return(0); -} -#endif - /* ftp://ftp.cc.uoc.gr/mirrors/OpenBSD/src/lib/libc/stdlib/tsearch.c */ /* find or insert datum into search tree */ void * @@ -1966,54 +1845,6 @@ u_int16_t ndpi_guess_protocol_id(struct ndpi_detection_module_struct *ndpi_struc /* ******************************************************************** */ -#if 0 -#ifndef __KERNEL__ -static int add_proto_default_port(u_int16_t **ports, u_int16_t new_port, - ndpi_proto_defaults_t *def, - ndpi_default_ports_tree_node_t *root) { - u_int num_ports, i; - - if(*ports == NULL) { - ndpi_port_range range = { new_port, new_port }; - - addDefaultPort(&range, def, &root); - return(0); - } - - for(num_ports=0; (*ports)[num_ports] != 0; num_ports++) - ; - - if(num_ports >= MAX_DEFAULT_PORTS) { - printf("Too many ports defined: ignored port %d\n", new_port); - return(-1); - } else { - u_int16_t *new_ports = (u_int16_t*)ndpi_malloc(num_ports+1); - ndpi_port_range range; - - if(new_ports == NULL) { - printf("Not enough memory\n"); - return(-2); - } - - for(i=0; i<num_ports; i++) - new_ports[i] = (*ports)[i]; - - new_ports[i++] = new_port; - new_ports[i++] = 0; - - ndpi_free(*ports); - *ports = new_ports; - - range.port_low = range.port_high = new_port; - addDefaultPort(&range, def, &root); - return(0); - } -} -#endif -#endif - -/* ******************************************************************** */ - u_int ndpi_get_num_supported_protocols(struct ndpi_detection_module_struct *ndpi_mod) { return(ndpi_mod->ndpi_num_supported_protocols); } @@ -2135,9 +1966,6 @@ int ndpi_handle_rule(struct ndpi_detection_module_struct *ndpi_mod, char* rule, */ int ndpi_load_protocols_file(struct ndpi_detection_module_struct *ndpi_mod, char* path) { -#ifdef __KERNEL__ - return(0); -#else FILE *fd = fopen(path, "r"); int i; @@ -2162,14 +1990,6 @@ int ndpi_load_protocols_file(struct ndpi_detection_module_struct *ndpi_mod, char fclose(fd); -#if 0 - printf("\nTCP:\n"); - ndpi_twalk(ndpi_mod->tcpRoot, ndpi_default_ports_tree_node_t_walker, NULL); - printf("\nUDP:\n"); - ndpi_twalk(ndpi_mod->udpRoot, ndpi_default_ports_tree_node_t_walker, NULL); -#endif -#endif - return(0); } @@ -3324,15 +3144,7 @@ ndpi_protocol ndpi_detection_process_packet(struct ndpi_detection_module_struct } flow->packet.tick_timestamp_l = current_tick_l; -#ifdef __KERNEL__ - { - u_int64_t d = current_tick_l; - do_div(d,1000); - flow->packet.tick_timestamp = d; - } -#else flow->packet.tick_timestamp = (u_int32_t)current_tick_l/1000; -#endif /* parse packet */ flow->packet.iph = (struct ndpi_iphdr *)packet; @@ -4190,16 +4002,6 @@ u_int16_t ntohs_ndpi_bytestream_to_number(const u_int8_t * str, u_int16_t max_ch /* ****************************************************** */ -#if 0 -#ifndef __KERNEL__ -static u_int is_port(u_int16_t sport, u_int16_t dport, u_int16_t match_port) { - return(((match_port == sport) || (match_port == dport)) ? 1 : 0); -} -#endif -#endif - -/* ****************************************************** */ - ndpi_protocol ndpi_find_port_based_protocol(struct ndpi_detection_module_struct *ndpi_struct /* NOTUSED */, u_int8_t proto, u_int32_t shost, u_int16_t sport, @@ -4504,11 +4306,7 @@ void ndpi_free_flow(struct ndpi_flow_struct *flow) { /* ****************************************************** */ -#ifndef __KERNEL__ -char* ndpi_revision() { - return(NDPI_GIT_RELEASE); -} -#endif +char* ndpi_revision() { return(NDPI_GIT_RELEASE); } /* ****************************************************** */ |