Sorry, please prefer this patch set to the previous ones

The differences are minor:
a) I missed a #endif out of the first patch (went into the 3rd instead)
b) I broke the nDPI build, fixed here
c) tidied up some comments

I also added a tentative patch 4 to remove the #include<time.h> - it appears to serve no purpose on linux, but it might break win32 or something? If it's needed, could it please be added back only for required archs?

Thanks

Ed W


On 16/10/2012 00:46, Ed W wrote:
OK, please check the following patches and critique. These allow me to compile the kernel netfilter module and approximately smell right...

I have broken the patches into 3 so that you can more easily chuck them back at me...

Cheers

Ed W


_______________________________________________
Ntop-dev mailing list
[email protected]
http://listgateway.unipi.it/mailman/listinfo/ntop-dev

From 5c2a9d56bff956ed3906d9ad44f27919616e110e Mon Sep 17 00:00:00 2001
From: Ed W <[email protected]>
Date: Tue, 16 Oct 2012 00:17:02 +0100
Subject: [PATCH 1/3] Remove NDPI_BUILD flag


Signed-off-by: Ed W <[email protected]>
---
 src/include/ndpi_main.h      |    2 --
 src/include/ndpi_protocols.h |    2 --
 src/include/ndpi_structs.h   |    2 --
 src/lib/ndpi_main.c          |    2 --
 4 files changed, 0 insertions(+), 8 deletions(-)

diff --git a/src/include/ndpi_main.h b/src/include/ndpi_main.h
index 8ee6940..c4ca3a9 100644
--- a/src/include/ndpi_main.h
+++ b/src/include/ndpi_main.h
@@ -51,7 +51,6 @@
 #include <limits.h>
 #endif
 
-#ifdef NDPI_BUILD
 #ifdef WIN32
 #define __attribute__(x)
 typedef char int8_t;
@@ -65,7 +64,6 @@ typedef unsigned __int64 u_int64_t;
 #endif
 
 #include "linux_compat.h"
-#endif
 
 #if defined(__FreeBSD__)
 #include <netinet/in.h>
diff --git a/src/include/ndpi_protocols.h b/src/include/ndpi_protocols.h
index 416415a..3573dcb 100644
--- a/src/include/ndpi_protocols.h
+++ b/src/include/ndpi_protocols.h
@@ -24,8 +24,6 @@
 #ifndef __NDPI_PROTOCOLS_INCLUDE_FILE__
 #define __NDPI_PROTOCOLS_INCLUDE_FILE__
 
-#define NDPI_BUILD
-
 #include "ndpi_main.h"
 
 /* the get_uXX will return raw network packet bytes !! */
diff --git a/src/include/ndpi_structs.h b/src/include/ndpi_structs.h
index 973f3b1..c7e7145 100644
--- a/src/include/ndpi_structs.h
+++ b/src/include/ndpi_structs.h
@@ -24,9 +24,7 @@
 #ifndef __NDPI_STRUCTS_INCLUDE_FILE__
 #define __NDPI_STRUCTS_INCLUDE_FILE__
 
-#ifdef NDPI_BUILD
 #include "linux_compat.h"
-#endif
 
 #include "ndpi_define.h"
 
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c
index 9833de0..79bcb09 100644
--- a/src/lib/ndpi_main.c
+++ b/src/lib/ndpi_main.c
@@ -20,8 +20,6 @@
  *
  */
 
-#define NDPI_BUILD
-
 #include "ndpi_main.h"
 #include "ndpi_protocols.h"
 #include "ndpi_utils.h"
-- 
1.7.3.4

>From ffdd675649b34252d7814c08c0f8cf4b261f99cf Mon Sep 17 00:00:00 2001
From: Ed W <[email protected]>
Date: Tue, 16 Oct 2012 00:25:36 +0100
Subject: [PATCH 2/3] Define needed functions used in protocols


Signed-off-by: Ed W <[email protected]>
---
 src/include/ndpi_main.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/include/ndpi_main.h b/src/include/ndpi_main.h
index c4ca3a9..df1447f 100644
--- a/src/include/ndpi_main.h
+++ b/src/include/ndpi_main.h
@@ -83,6 +83,7 @@ typedef unsigned __int64 u_int64_t;
 #include "ndpi_macros.h"
 #include "ndpi_protocols_osdpi.h"
 
+u_int16_t ntohs_ndpi_bytestream_to_number(const u_int8_t * str, u_int16_t 
max_chars_to_read, u_int16_t * bytes_read);
 
 u_int32_t ndpi_bytestream_to_number(const u_int8_t * str, u_int16_t 
max_chars_to_read, u_int16_t * bytes_read);
 u_int64_t ndpi_bytestream_to_number64(const u_int8_t * str, u_int16_t 
max_chars_to_read, u_int16_t * bytes_read);
-- 
1.7.3.4

From 680749084267d11069e2c3b073a3f9aae3b703b1 Mon Sep 17 00:00:00 2001
From: Ed W <[email protected]>
Date: Tue, 16 Oct 2012 00:38:10 +0100
Subject: [PATCH 3/3] compile fixes for netfilter module


Signed-off-by: Ed W <[email protected]>
---
 src/include/linux_compat.h |   17 +++++++++++------
 src/include/ndpi_define.h  |   11 +++++++++++
 src/include/ndpi_main.h    |   19 ++++++++++++-------
 3 files changed, 34 insertions(+), 13 deletions(-)

diff --git a/src/include/linux_compat.h b/src/include/linux_compat.h
index 1bf1bd6..3205f83 100644
--- a/src/include/linux_compat.h
+++ b/src/include/linux_compat.h
@@ -51,6 +51,9 @@ struct ndpi_iphdr {
   u_int32_t daddr;
 };
 
+
+#ifdef WIN32
+
 typedef unsigned char  u_char;
 typedef unsigned short u_short;
 typedef unsigned int   uint;
@@ -102,6 +105,13 @@ struct ndpi_ip6_ext
 
 #define s6_addr16              __u6_addr.__u6_addr16
 #define s6_addr32              __u6_addr.__u6_addr32
+#else
+#ifndef OPENDPI_NETFILTER_MODULE
+#include <arpa/inet.h>
+#endif
+#endif
+
+
 
 struct ndpi_in6_addr {
   union {
@@ -148,10 +158,5 @@ struct ndpi_udphdr {
   u_int16_t len;
   u_int16_t check;
 };
-#else
-#ifndef WIN32
-#include <arpa/inet.h>
-#endif
-#endif
-
 
+#endif
diff --git a/src/include/ndpi_define.h b/src/include/ndpi_define.h
index 8b061c1..290aeb9 100644
--- a/src/include/ndpi_define.h
+++ b/src/include/ndpi_define.h
@@ -26,6 +26,15 @@
 */
 
 #if !(defined(__LITTLE_ENDIAN__) || defined(__BIG_ENDIAN__))
+/* Kernel modules */
+#if defined(__LITTLE_ENDIAN)
+#define __LITTLE_ENDIAN__
+#endif
+#if defined(__BIG_ENDIAN)
+#define __BIG_ENDIAN__
+#endif
+/* Everything else */
+#if (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__))
 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
 #define __LITTLE_ENDIAN__
 #else
@@ -33,6 +42,8 @@
 #endif
 #endif
 
+#endif
+
 #define NDPI_USE_ASYMMETRIC_DETECTION             0
 #define NDPI_SELECTION_BITMASK_PROTOCOL_SIZE                   u_int32_t
 
diff --git a/src/include/ndpi_main.h b/src/include/ndpi_main.h
index df1447f..90238ab 100644
--- a/src/include/ndpi_main.h
+++ b/src/include/ndpi_main.h
@@ -31,7 +31,7 @@
 #include <string.h>
 #endif
 
-#if !defined(WIN32)
+#ifndef WIN32
 #if 1 && !defined __APPLE__ && !defined __FreeBSD__
 
 #ifndef OPENDPI_NETFILTER_MODULE
@@ -41,16 +41,17 @@
 #  include <asm/byteorder.h>
 #endif
 
-#endif                                                 /* not WIN32 && not 
APPLE) */
-#endif /* ntop */
+#endif
 
 /* default includes */
 
-#ifndef WIN32
+#ifndef OPENDPI_NETFILTER_MODULE
 #include <sys/param.h>
 #include <limits.h>
 #endif
 
+#endif
+
 #ifdef WIN32
 #define __attribute__(x)
 typedef char int8_t;
@@ -71,9 +72,13 @@ typedef unsigned __int64 u_int64_t;
 
 #ifndef WIN32
 #ifndef OPENDPI_NETFILTER_MODULE
-#include <netinet/ip.h> 
-#include <netinet/tcp.h> 
-#include <netinet/udp.h> 
+#  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
 
-- 
1.7.3.4

>From d2286f888c42d2c4ffd58c4a9a508d35329a5715 Mon Sep 17 00:00:00 2001
From: Ed W <[email protected]>
Date: Tue, 16 Oct 2012 14:15:45 +0100
Subject: [PATCH 1/1] Why do need tine.h? Doesn't seem needed on linux?

If needed for another arch, please add with #ifdef
to avoid including in linux kernel builds

Signed-off-by: Ed W <[email protected]>
---
 src/include/ndpi_main.h |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/src/include/ndpi_main.h b/src/include/ndpi_main.h
index 90238ab..8b33174 100644
--- a/src/include/ndpi_main.h
+++ b/src/include/ndpi_main.h
@@ -82,8 +82,6 @@ typedef unsigned __int64 u_int64_t;
 #endif
 #endif
 
-#include <time.h>
-
 #include "ndpi_define.h"
 #include "ndpi_macros.h"
 #include "ndpi_protocols_osdpi.h"
-- 
1.7.3.4

_______________________________________________
Ntop-dev mailing list
[email protected]
http://listgateway.unipi.it/mailman/listinfo/ntop-dev

Reply via email to