removed kernel support and #if 0s

This commit is contained in:
Campus
2015-11-12 12:08:41 +01:00
parent 349e0b6fd2
commit a4f170604c
19 changed files with 20 additions and 254 deletions
-7
View File
@@ -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
View File
@@ -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
View File
@@ -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
/* } */
-4
View File
@@ -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"
-38
View File
@@ -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