betolj / ndpi-netfilter

GNU General Public License v2.0
126 stars 72 forks source link

Compile on Centos 6.x? #28

Open hariesnurikhwan opened 8 years ago

hariesnurikhwan commented 8 years ago

Hello, is it possible to compile the ndpi-netfilter to make it work on Centos 6.x? I've look around but haven't found anything to make it work on Centos 6.x

elico commented 8 years ago

What have you tried until now? What kernel are you using? What output did you got from a build?

hariesnurikhwan commented 8 years ago

I've tried compile using the steps listed in "ndpi.install", and changes few requirement to make it work on Centos

Kernel version Linux Centos-SG 2.6.32-642.1.1.el6.x86_64 #1 SMP Tue May 31 21:57:07 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

/usr/src/ndpi-netfilter/src/ndpi_cpy/include/ndpi_define.h:299:2: error: #error "__BYTE_ORDER MUST BE DEFINED !"
In file included from /usr/src/ndpi-netfilter/src/ndpi_cpy/include/ndpi_main.h:57,
                 from /usr/src/ndpi-netfilter/src/main.c:41:
/usr/src/ndpi-netfilter/src/ndpi_cpy/include/ndpi_typedefs.h:195:3: error: #error "Byte order must be defined"
/usr/src/ndpi-netfilter/src/ndpi_cpy/include/ndpi_typedefs.h:254:3: error: #error "Byte order must be defined"
make[3]: *** [/usr/src/ndpi-netfilter/src/main.o] Error 1
make[2]: *** [_module_/usr/src/ndpi-netfilter/src] Error 2
make[2]: Leaving directory `/usr/src/kernels/2.6.32-642.1.1.el6.x86_64'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/usr/src/ndpi-netfilter/src'
make: *** [all] Error 2
elico commented 8 years ago

@hariesnurikhwan in any case you will need to either recompile the kernel or install a new one. Else then what the result I can try to help you but I need to know what development packages have you installed? I will try to see if I am managing to build it here with an elrepo lt or ml kernel.

elico commented 8 years ago

@hariesnurikhwan it seems that from an unkown reason(to me) probably the compiler doesn't find that the system works with LITTLE_ENDIAN. The basic test to verify the ENDIANESS of the system would be something like:

python -c "import sys;sys.exit(0 if sys.byteorder=='big' else 1)"; if [ "$?" -eq 0 ];then echo "BIG";else; echo "LITTLE";fi

Probably someone else can fix the issue in the sources. I created a patch that allows it to be built on a Docker container but I cannot test it now on a running server. Patch: https://gist.github.com/elico/eb6f4116cafd0e526f6506cb56166a93#file-little-endian-patch-patch

Details of the Dockerfile and build files at: https://gist.github.com/elico/eb6f4116cafd0e526f6506cb56166a93

I have Built it on elrepo ml kernel and it compiles fine.

tinkerofthoughts commented 7 years ago

@elico Thanks for posting the resources.

OS - CentOS release 6.3 (Final) Kernel - 4.2.8

Applied the patch given by @elico.

I am getting an error when I run NDPI_PATH=/usr/src/ndpi-netfilter-master/nDPI make

In file included from /usr/src/ndpi-netfilter-master/src/main.c:42:
/usr/src/ndpi-netfilter-master/src/xt_ndpi.h:35: error: expected specifier-qualifier-list before 'NDPI_PROTOCOL_BITMASK'
/usr/src/ndpi-netfilter-master/src/main.c:85: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'protocols_bitmask'
/usr/src/ndpi-netfilter-master/src/main.c: In function 'ndpi_enable_protocols':
/usr/src/ndpi-netfilter-master/src/main.c:326: error: implicit declaration of function 'NDPI_COMPARE_PROTOCOL_TO_BITMASK'
/usr/src/ndpi-netfilter-master/src/main.c:326: error: 'const struct xt_ndpi_mtinfo' has no member named 'flags'
/usr/src/ndpi-netfilter-master/src/main.c:327: error: 'struct ndpi_detection_module_struct' has no member named 'proto_defaults'
/usr/src/ndpi-netfilter-master/src/main.c:332: error: 'struct ndpi_detection_module_struct' has no member named 'proto_defaults'
/usr/src/ndpi-netfilter-master/src/main.c:333: error: implicit declaration of function 'NDPI_ADD_PROTOCOL_TO_BITMASK'
/usr/src/ndpi-netfilter-master/src/main.c:333: error: 'protocols_bitmask' undeclared (first use in this function)
/usr/src/ndpi-netfilter-master/src/main.c:333: error: (Each undeclared identifier is reported only once
/usr/src/ndpi-netfilter-master/src/main.c:333: error: for each function it appears in.)
/usr/src/ndpi-netfilter-master/src/main.c:334: error: 'struct ndpi_detection_module_struct' has no member named 'proto_defaults'
/usr/src/ndpi-netfilter-master/src/main.c:336: error: 'struct ndpi_detection_module_struct' has no member named 'proto_defaults'
/usr/src/ndpi-netfilter-master/src/main.c:343: error: implicit declaration of function 'ndpi_set_protocol_detection_bitmask2'
/usr/src/ndpi-netfilter-master/src/main.c: In function 'ndpi_disable_protocols':
/usr/src/ndpi-netfilter-master/src/main.c:358: error: 'const struct xt_ndpi_mtinfo' has no member named 'flags'
/usr/src/ndpi-netfilter-master/src/main.c:361: error: implicit declaration of function 'NDPI_DEL_PROTOCOL_FROM_BITMASK'
/usr/src/ndpi-netfilter-master/src/main.c:361: error: 'protocols_bitmask' undeclared (first use in this function)
/usr/src/ndpi-netfilter-master/src/main.c: In function 'ndpi_mt':
/usr/src/ndpi-netfilter-master/src/main.c:662: error: 'const struct xt_ndpi_mtinfo' has no member named 'flags'
/usr/src/ndpi-netfilter-master/src/main.c: In function 'ndpi_mt_check':
/usr/src/ndpi-netfilter-master/src/main.c:717: error: implicit declaration of function 'NDPI_BITMASK_IS_EMPTY'
/usr/src/ndpi-netfilter-master/src/main.c:717: error: 'const struct xt_ndpi_mtinfo' has no member named 'flags'
/usr/src/ndpi-netfilter-master/src/main.c:722: error: implicit declaration of function 'NDPI_BITMASK_RESET'
/usr/src/ndpi-netfilter-master/src/main.c:722: error: 'protocols_bitmask' undeclared (first use in this function)
/usr/src/ndpi-netfilter-master/src/main.c: In function 'ndpi_mt_init':
/usr/src/ndpi-netfilter-master/src/main.c:830: error: 'protocols_bitmask' undeclared (first use in this function)
make[3]: *** [/usr/src/ndpi-netfilter-master/src/main.o] Error 1
make[2]: *** [_module_/usr/src/ndpi-netfilter-master/src] Error 2
make[2]: Leaving directory `/root/kernel-update/linux-4.2.8'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/usr/src/ndpi-netfilter-master/src'
make: *** [all] Error 2

Complete error - https://pastebin.com/snGiwb5x

Has anyone got it working on CentOS 6.x ?

elico commented 7 years ago

@tinkerofthoughts There is a big diffrence between building\compiling to running it. I will try to spin a CentOS 6 VM and see if I can reproduce it. Can you attach here the specific commands from on a vanilla 6.latest?

That will help to try and reproduce the issue locally and mabe fix it(if posssible).