How to compile VEL21RIPN ndpi-netfilter2 and using for lede/openwrt


#21

hi, i will post now a makefile that will compile,but not guaranteed to compile on all architectures.

 #
# Copyright (C) 2010 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk

PKG_NAME:=ndpi-netfilter2
PKG_VERSION:=0670f78
PKG_RELEASE:=1
PKG_REV:=0670f78

PKG_SOURCE_PROTO:=git
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_MIRROR_HASH:=d9a5c2c9455fdcd7181582e6079c7469b88628a0acf3cac8dcf1c2e7586f47da
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_URL:=https://github.com/vel21ripn/nDPI.git
PKG_SOURCE_VERSION:=$(PKG_REV)

PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)

PKG_FIXUP:=autoreconf
PKG_INSTALL:=1

include $(INCLUDE_DIR)/uclibc++.mk
include $(INCLUDE_DIR)/package.mk


CONFIGURE_ARGS += --with-pic
MAKE_PATH := ndpi-netfilter

define Package/iptables-mod-ndpi
	SUBMENU:=Firewall
	SECTION:=net
	CATEGORY:=Network
	TITLE:=ndpi successor of OpenDPI
	URL:=http://www.ntop.org/products/ndpi/
	DEPENDS:=+iptables +iptables-mod-conntrack-extra +kmod-ipt-ndpi
	MAINTAINER:=Thomas Heil <heil@terminal-consulting.de>
endef

define Package/iptables-mod-ndpi/description
  nDPI is a ntop-maintained superset of the popular OpenDPI library
endef

MAKE_FLAGS += KERNEL_DIR="$(LINUX_DIR)" MODULES_DIR="$(TARGET_MODULES_DIR)" 

define Package/iptables-mod-ndpi/install
	$(INSTALL_DIR) $(1)/usr/lib/iptables
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/ndpi-netfilter/ipt/libxt_ndpi.so $(1)/usr/lib/iptables
endef

define KernelPackage/ipt-ndpi
	SUBMENU:=Netfilter Extensions
	TITLE:= nDPI net netfilter module
	DEPENDS:=+kmod-nf-conntrack +kmod-nf-conntrack-netlink +kmod-ipt-compat-xtables
	KCONFIG:=CONFIG_NF_CONNTRACK_LABELS=y
	FILES:= \
	$(PKG_BUILD_DIR)/ndpi-netfilter/src/xt_ndpi.ko
	AUTOLOAD:=$(call AutoProbe,xt_ndpi)
endef

$(eval $(call BuildPackage,iptables-mod-ndpi))
$(eval $(call KernelPackage,ipt-ndpi))

many thanks to jow for spotting mistakes and help.


#22

Thank you! Will test it soon! I'm using x86 arch.


#23

i edited again,you welcome.
don't forget to enable connlabel support from menuconfig, if you have compile errors please post here.
how to compile:
1.put make file in /package/ndpi-netfilter2 folder.
2.from menuconfig search about ndpi then go and select them.
3.run make /package/ndpi-netfilter2/{clean,compile} V=s


#24

Thank you very much! I was able to compile iptables with ndpi for x86 arch using your makefile.
Testing it now.


#25

wow, great to hear that!
you're welcome, happy testing!


#26

now the only problem is it won't to compile for lantiq, but it's compile fine for x86_x64 arch.


#27

Faced with the strange issue: can't resolve dependencies for kmod-ipt-ipset. I want to use mwan3 in my image, but when I enable ipset, build fails:

Collected errors:
 * satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod-ipt-ipset:
 *      kmod-nfnetlink *
 * opkg_install_cmd: Cannot install package kmod-ipt-ipset.
 * satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod-ipt-nflog:
 *      kmod-nfnetlink *
 * opkg_install_cmd: Cannot install package kmod-ipt-nflog.
 * satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod-ipt-nfqueue:
 *      kmod-nfnetlink *
 * opkg_install_cmd: Cannot install package kmod-ipt-nfqueue.
 * satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod-nf-conntrack-netlink:
 *      kmod-nfnetlink *
 * opkg_install_cmd: Cannot install package kmod-nf-conntrack-netlink.
 * satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod-nft-core:
 *      kmod-nfnetlink *
 * opkg_install_cmd: Cannot install package kmod-nft-core.

It is really strange because kmod-nfnetlink was enabled in menuconfig.
It looks like I'm not the only one who faced it: https://forum.openwrt.org/viewtopic.php?id=72960


#28

before build you should run :
./scripts/feeds update -a
./scripts/feeds install kmod-ipt-ipset

it may fix your problem, also try to enable all other depends.
BTW: is ndpi-netfilter working ?


#29

Thanks! Will try!
Yes, ndpi works, I made few tests: DROP and MARK rules work fine.


#30

Great news!
you're welcome.


#31

I can't see nf_conntrack_labels in my make menuconfig??


#32

It is kernel config, you do not need it now, the makefile will enable it.


#33

Does this apply to Openwrt 15.05 as well? It doesn’t seem to work for me in that environment


#34

Nope, only test for LEDE.


#35

Anyone able to tell me why i'm having so much trouble getting nf_conntrack_labels into my build on kernel 3.18/owrt 15.05? It doesn't show up in the make menuconfig.
I don't know if i'm being daft or i've missed the bus completely on this one or what.


#36

i'm not sure why you can't see it . cause i'm not using old openwrt anymore.
but try to use ./scripts/feeds update then ./scripts/feeds install "pkg_name"


#37

I had uploaded the makfile on github here's the link: https://github.com/hisham2630/openwrt-ndpi-netfilter


#38

Has anyone been able to compile this on the ar71xx (MIPS)?

I get the following errors when trying to compile.

using the following git repo to compile https://github.com/openwrt-develop/ndpi-netfilter

 CC [M]  /home/gmoss/openwrt/openwrt-sdk-18.06.1-ar71xx-generic_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mips_24kc_musl/linux-ar71xx_generic/ndpi-netfilter-a360566-2.4/ndpi-netfilter/src/../../src/lib/protocols/fasttrack.o
In file included from /home/gmoss/openwrt/openwrt-sdk-18.06.1-ar71xx-generic_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mips_24kc_musl/linux-ar71xx_generic/ndpi-netfilter-a360566-2.4/ndpi-netfilter/src/../../src/include/ndpi_main.h:30:0,
                 from /home/gmoss/openwrt/openwrt-sdk-18.06.1-ar71xx-generic_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mips_24kc_musl/linux-ar71xx_generic/ndpi-netfilter-a360566-2.4/ndpi-netfilter/src/../../src/include/ndpi_api.h:28,
                 from /home/gmoss/openwrt/openwrt-sdk-18.06.1-ar71xx-generic_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mips_24kc_musl/linux-ar71xx_generic/ndpi-netfilter-a360566-2.4/ndpi-netfilter/src/../../src/lib/protocols/fasttrack.c:29:
/home/gmoss/openwrt/openwrt-sdk-18.06.1-ar71xx-generic_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mips_24kc_musl/linux-ar71xx_generic/ndpi-netfilter-a360566-2.4/ndpi-netfilter/src/../../src/include/ndpi_define.h:61:21: warning: "__LITTLE_ENDIAN" is not defined, evaluates to 0 [-Wundef]
 #if __BYTE_ORDER == __LITTLE_ENDIAN
                     ^~~~~~~~~~~~~~~
  CC [M]  /home/gmoss/openwrt/openwrt-sdk-18.06.1-ar71xx-generic_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mips_24kc_musl/linux-ar71xx_generic/ndpi-netfilter-a360566-2.4/ndpi-netfilter/src/../../src/lib/protocols/fbzero.o
In file included from /home/gmoss/openwrt/openwrt-sdk-18.06.1-ar71xx-generic_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mips_24kc_musl/linux-ar71xx_generic/ndpi-netfilter-a360566-2.4/ndpi-netfilter/src/../../src/include/ndpi_main.h:30:0,
                 from /home/gmoss/openwrt/openwrt-sdk-18.06.1-ar71xx-generic_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mips_24kc_musl/linux-ar71xx_generic/ndpi-netfilter-a360566-2.4/ndpi-netfilter/src/../../src/include/ndpi_api.h:28,
                 from /home/gmoss/openwrt/openwrt-sdk-18.06.1-ar71xx-generic_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mips_24kc_musl/linux-ar71xx_generic/ndpi-netfilter-a360566-2.4/ndpi-netfilter/src/../../src/lib/protocols/fbzero.c:27:
/home/gmoss/openwrt/openwrt-sdk-18.06.1-ar71xx-generic_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mips_24kc_musl/linux-ar71xx_generic/ndpi-netfilter-a360566-2.4/ndpi-netfilter/src/../../src/include/ndpi_define.h:61:21: warning: "__LITTLE_ENDIAN" is not defined, evaluates to 0 [-Wundef]
 #if __BYTE_ORDER == __LITTLE_ENDIAN
                     ^~~~~~~~~~~~~~~
  CC [M]  /home/gmoss/openwrt/openwrt-sdk-18.06.1-ar71xx-generic_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mips_24kc_musl/linux-ar71xx_generic/ndpi-netfilter-a360566-2.4/ndpi-netfilter/src/../../src/lib/protocols/fiesta.o
In file included from /home/gmoss/openwrt/openwrt-sdk-18.06.1-ar71xx-generic_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mips_24kc_musl/linux-ar71xx_generic/ndpi-netfilter-a360566-2.4/ndpi-netfilter/src/../../src/include/ndpi_main.h:30:0,
                 from /home/gmoss/openwrt/openwrt-sdk-18.06.1-ar71xx-generic_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mips_24kc_musl/linux-ar71xx_generic/ndpi-netfilter-a360566-2.4/ndpi-netfilter/src/../../src/include/ndpi_api.h:28,
                 from /home/gmoss/openwrt/openwrt-sdk-18.06.1-ar71xx-generic_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mips_24kc_musl/linux-ar71xx_generic/ndpi-netfilter-a360566-2.4/ndpi-netfilter/src/../../src/lib/protocols/fiesta.c:29:
/home/gmoss/openwrt/openwrt-sdk-18.06.1-ar71xx-generic_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mips_24kc_musl/linux-ar71xx_generic/ndpi-netfilter-a360566-2.4/ndpi-netfilter/src/../../src/include/ndpi_define.h:61:21: warning: "__LITTLE_ENDIAN" is not defined, evaluates to 0 [-Wundef]
 #if __BYTE_ORDER == __LITTLE_ENDIAN
                     ^~~~~~~~~~~~~~~
In file included from /home/gmoss/openwrt/openwrt-sdk-18.06.1-ar71xx-generic_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mips_24kc_musl/linux-ar71xx_generic/ndpi-netfilter-a360566-2.4/ndpi-netfilter/src/../../src/include/ndpi_main.h:30:0,
                 from /home/gmoss/openwrt/openwrt-sdk-18.06.1-ar71xx-generic_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mips_24kc_musl/linux-ar71xx_generic/ndpi-netfilter-a360566-2.4/ndpi-netfilter/src/../../src/include/ndpi_api.h:28,
                 from /home/gmoss/openwrt/openwrt-sdk-18.06.1-ar71xx-generic_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mips_24kc_musl/linux-ar71xx_generic/ndpi-netfilter-a360566-2.4/ndpi-netfilter/src/../../src/lib/protocols/fiesta.c:29:
/home/gmoss/openwrt/openwrt-sdk-18.06.1-ar71xx-generic_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mips_24kc_musl/linux-ar71xx_generic/ndpi-netfilter-a360566-2.4/ndpi-netfilter/src/../../src/lib/protocols/fiesta.c: In function 'ndpi_search_fiesta':
/home/gmoss/openwrt/openwrt-sdk-18.06.1-ar71xx-generic_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mips_24kc_musl/linux-ar71xx_generic/ndpi-netfilter-a360566-2.4/ndpi-netfilter/src/../../src/include/ndpi_define.h:337:23: error: implicit declaration of function 'bswap_16'; did you mean 'swab16'? [-Werror=implicit-function-declaration]
 # define get_l16(X,O) bswap_16(get_u_int16_t(X,O))
                       ^
/home/gmoss/openwrt/openwrt-sdk-18.06.1-ar71xx-generic_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mips_24kc_musl/linux-ar71xx_generic/ndpi-netfilter-a360566-2.4/ndpi-netfilter/src/../../src/lib/protocols/fiesta.c:55:8: note: in expansion of macro 'get_l16'
     && get_l16(packet->payload, 1) == packet->payload_packet_len - 3))) {
        ^~~~~~~
cc1: some warnings being treated as errors
make[6]: *** [/home/gmoss/openwrt/openwrt-sdk-18.06.1-ar71xx-generic_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mips_24kc_musl/linux-ar71xx_generic/ndpi-netfilter-a360566-2.4/ndpi-netfilter/src/../../src/lib/protocols/fiesta.o] Error 1
make[5]: *** [_module_/home/gmoss/openwrt/openwrt-sdk-18.06.1-ar71xx-generic_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mips_24kc_musl/linux-ar71xx_generic/ndpi-netfilter-a360566-2.4/ndpi-netfilter/src] Error 2
make[5]: Leaving directory `/home/gmoss/openwrt/openwrt-sdk-18.06.1-ar71xx-generic_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mips_24kc_musl/linux-ar71xx_generic/linux-4.9.120'
make[4]: *** [modules] Error 2
make[4]: Leaving directory `/home/gmoss/openwrt/openwrt-sdk-18.06.1-ar71xx-generic_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mips_24kc_musl/linux-ar71xx_generic/ndpi-netfilter-a360566-2.4/ndpi-netfilter/src'
make[3]: *** [all] Error 2
make[3]: Leaving directory `/home/gmoss/openwrt/openwrt-sdk-18.06.1-ar71xx-generic_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mips_24kc_musl/linux-ar71xx_generic/ndpi-netfilter-a360566-2.4/ndpi-netfilter'
make[2]: *** [/home/gmoss/openwrt/openwrt-sdk-18.06.1-ar71xx-generic_gcc-7.3.0_musl.Linux-x86_64/build_dir/target-mips_24kc_musl/linux-ar71xx_generic/ndpi-netfilter-a360566-2.4/.built] Error 2
make[2]: Leaving directory `/home/gmoss/openwrt/custom-feed/ndpi-netfilter'
time: package/feeds/custom/ndpi-netfilter/compile#63.70#22.84#101.98
make[1]: *** [package/feeds/custom/ndpi-netfilter/compile] Error 2
make[1]: Leaving directory `/home/gmoss/openwrt/openwrt-sdk-18.06.1-ar71xx-generic_gcc-7.3.0_musl.Linux-x86_64'
make: *** [package/ndpi-netfilter/compile] Error 2

#39

i have the same problem.but it's compile fine on x86/x64
i think we have to patch some lines in the code.


#40

try this make file and see if it will work!