Skip to contentSkip to conversation

ntop: add new recipe

PATCH New Yi Zhao 1 participant 1 message Jul 28, 2017

lore
Share & tools
lore

Yi Zhao

author
#0 lore raw

PATCH 1/1 ntop: add new recipe

ntop is a tool that shows the network usage, similar to what the popular top Unix command does. ntop is based on pcapture and it has been written in a portable way in order to virtually run on every Unix platform.

---
 meta-networking/recipes-support/ntop/ntop.inc      | 131 ++++++++++++
 .../recipes-support/ntop/ntop/ntop.service         |  15 ++
 .../ntop/ntop/ntop_configure_in.patch              | 164 +++++++++++++++
 .../ntop_configure_in_net_snmp_config_exist.patch  |  21 ++
 .../recipes-support/ntop/ntop/ntop_init.patch      | 228 +++++++++++++++++++++
 .../ntop/ntop/ntop_webInterface.patch              |  19 ++
 .../recipes-support/ntop/ntop/support-arm64.patch  |  28 +++
 .../ntop/ntop/use-static-inline.patch              |  32 +++
 meta-networking/recipes-support/ntop/ntop_5.0.1.bb |   4 +
 9 files changed, 642 insertions(+)
 create mode 100644 meta-networking/recipes-support/ntop/ntop.inc
 create mode 100644 meta-networking/recipes-support/ntop/ntop/ntop.service
 create mode 100644 meta-networking/recipes-support/ntop/ntop/ntop_configure_in.patch
 create mode 100644 meta-networking/recipes-support/ntop/ntop/ntop_configure_in_net_snmp_config_exist.patch
 create mode 100644 meta-networking/recipes-support/ntop/ntop/ntop_init.patch
 create mode 100644 meta-networking/recipes-support/ntop/ntop/ntop_webInterface.patch
 create mode 100644 meta-networking/recipes-support/ntop/ntop/support-arm64.patch
 create mode 100644 meta-networking/recipes-support/ntop/ntop/use-static-inline.patch
 create mode 100644 meta-networking/recipes-support/ntop/ntop_5.0.1.bb
meta-networking/recipes-support/ntop/ntop.inc new file +131 -0
new file mode 100644
index 0000000..b964334
@@ -0,0 +1,131 @@
+SUMMARY = "ntop is network top"
+DESCRIPTION = "ntop is a network traffic probe that shows the network usage, \
+similar to what the popular top Unix command does."
+
+SECTION = "console/network"
+
+LICENSE = "GPLv2+ & GPLv3 & OpenSSL"
+LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504 \
+                    file://LICENSE-OpenSSL.txt;md5=a409f902e447ddd889cffa0c70e7c7c2 \
+                   "
+
+SRC_URI = "${SOURCEFORGE_MIRROR}/ntop/ntop-${PV}.tar.gz \
+           file://ntop_configure_in.patch \
+           file://ntop_init.patch \
+           file://ntop_webInterface.patch \
+           file://ntop_configure_in_net_snmp_config_exist.patch \
+           file://ntop.service \
+           file://use-static-inline.patch \
+           file://support-arm64.patch \
+          "
+
+inherit autotools-brokensep useradd pythonnative pkgconfig systemd
+
+DEPENDS = "geoip rrdtool python zlib libpcap gdbm"
+
+PACKAGECONFIG ??= "openssl snmp plugins"
+PACKAGECONFIG[openssl] = "--with-ssl, --without-ssl, openssl, openssl"
+PACKAGECONFIG[snmp] = "--enable-snmp=yes NETSNMP=${STAGING_BINDIR_CROSS}/net-snmp-config, \
+--disable-snmp,net-snmp,"
+PACKAGECONFIG[plugins] = "--enable-plugins=yes, --disable-plugins, ,"
+
+EXTRA_OECONF += "ac_cv_file_aclocal_m4=yes ac_cv_file_depcomp=no"
+
+do_configure() {
+    cp ${STAGING_DATADIR_NATIVE}/aclocal/libtool.m4 libtool.m4.in
+    cat acinclude.m4.in acinclude.m4.ntop libtool.m4.in > acinclude.m4
+    cp 3rd_party/* ./
+
+    # config nDPI
+    cd nDPI
+    ./configure ${CONFIGUREOPTS} --with-pic
+    cd ..
+
+    sed -i -e 's:^CFG_DBFILE_DIR=$localstatedir/ntop:CFG_DBFILE_DIR=$localstatedir/lib/ntop:' ${S}/configure.in
+
+    # fix the CFLAGS, CPPFLAGS, LDFLAGS, remove the host include
+    sed -i \
+        -e 's:\(^CFLAGS="\$.*\) -I/usr/local/include -I/opt/local/include":\1":' \
+        -e 's:\(^CPPFLAGS="\$.*\) -I/usr/local/include -I/opt/local/include":\1":' \
+        -e 's:\(^LDFLAGS="\$.*\) -L/usr/local/lib -L/opt/local/lib":\1":' \
+        ${S}/configure.in
+
+    # replace the DISTRO RELEASE in configure.in which are host's
+    # with our release, although those doesn't affect functionality
+    sed -i -e \
+        '/DEFINEOS="LINUX"/{N;s/DISTRO=.*/DISTRO="${DISTRO}"/;N;s/RELEASE=.*/RELEASE="${DISTRO_VERSION}"/;}' \
+        ${S}/configure.in
+
+    # osName in original configure.in should be ${TARGET_SYS}
+    # which will show in ntop's "show configuration"
+    sed -i -e \
+        's:^osName=.*:osName=${TARGET_SYS}:' \
+        ${S}/configure.in
+
+    # rename configureextra to configureextra_rename to avoid
+    # configure.in to guess host OS and pull in more configure, non needed
+    # which will cause some cross-compiling failure on specific host
+    # e.g. SUSE(SLED...)
+    test ! -f configureextra || mv -f configureextra configureextra_rename
+
+    # make sure configure finds python includdirs/libs with these envs
+    export BUILD_SYS=${BUILD_SYS} HOST_SYS=${HOST_SYS} \
+        STAGING_INCDIR=${STAGING_INCDIR} \
+        STAGING_LIBDIR=${STAGING_LIBDIR}
+
+    autotools_do_configure
+}
+
+do_compile_prepend() {
+    cd nDPI
+    oe_runmake
+    cd ..
+}
+
+do_install_append() {
+    # remove the empty dirs
+    rm -rf ${D}${libdir}/plugins
+
+    install -D -m 0755 ${S}/packages/RedHat/ntop.init \
+        ${D}${sysconfdir}/init.d/ntop
+    install -D -m 0644 ${S}/packages/RedHat/ntop.conf.sample \
+        ${D}${sysconfdir}/ntop.conf
+
+    # change ntop dir in ntop.conf
+    # don't use the -P as the ntop.init didn't support it
+    sed -i -e "s:^--db-file-path /usr/share/ntop:--db-file-path /var/lib/ntop:" \
+        -e "s:^#? -P /var/ntop:#? -P /var/lib/ntop:" \
+        ${D}${sysconfdir}/ntop.conf
+
+    # For systemd
+    if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
+        install -D -m 0755 ${S}/packages/RedHat/ntop.init ${D}${libexecdir}/ntop-helper
+        install -D -m 0644 ${WORKDIR}/ntop.service ${D}${systemd_system_unitdir}/ntop.service
+        sed -i -e 's,@LIBEXECDIR@,${libexecdir},g' \
+            -e 's,@SYSCONFDIR@,${sysconfdir},g' \
+            ${D}${systemd_system_unitdir}/ntop.service
+    fi
+
+    # Fix host-user-contaminated issue
+    chown -R root:root ${D}
+
+    chown -R ntop.ntop ${D}${datadir}/ntop
+    chown -R ntop:ntop ${D}${localstatedir}/lib/ntop
+}
+
+USERADD_PACKAGES = "${PN}"
+USERADD_PARAM_${PN} = "-M -g ntop -r -d ${localstatedir}/lib/ntop \
+-s /usr/sbin/nologin -c 'ntop' ntop"
+GROUPADD_PARAM_${PN} = "-r ntop"
+
+SYSTEMD_SERVICE_${PN} = "ntop.service"
+SYSTEMD_AUTO_ENABLE = "disable"
+
+FILES_${PN}_append = "${libdir}/ntop/plugins ${libdir}/libntop-*.so \
+                      ${libdir}/libntopreport-*.so ${libdir}/lib*-${PV}.so"
+FILES_${PN}-dev = "${includedir} ${libdir}/libntop.so \
+                   ${libdir}/libntopreport.so \
+                   ${libdir}/libnetflowPlugin.so ${libdir}/libsflowPlugin.so \
+                   ${libdir}/librrdPlugin.so \
+                   ${libdir}/*.a ${libdir}/libntopreport.a ${libdir}/*.la"
+
meta-networking/recipes-support/ntop/ntop/ntop.service new file +15 -0
new file mode 100644
index 0000000..1ead2a0
@@ -0,0 +1,15 @@
+[Unit]
+Description=A network traffic probe similar to the UNIX top command
+Requires=network.target
+
+ConditionPathExists=@SYSCONFDIR@/ntop.conf
+After=syslog.target network.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=@LIBEXECDIR@/ntop-helper start
+ExecStop=@LIBEXECDIR@/ntop-helper stop
+
+[Install]
+WantedBy=multi-user.target
meta-networking/recipes-support/ntop/ntop/ntop_configure_in.patch new file +164 -0

164 lines not on this page · raw message

meta-networking/recipes-support/ntop/ntop/ntop_configure_in_net_snmp_config_exist.patch new file +21 -0
new file mode 100644
index 0000000..269138d
@@ -0,0 +1,21 @@
+Check net-snmp-config's existence in case user specified the
+ac_cv_prog_NETSNMP to avoid HAVE_SNMP defined if the specified
+net-snmp-config doesn't exist.
+
+Upstream-Status: Inappropriate [Embedded specific]
+
+Signed-off-by: Yao Zhao <[email protected]>
+---
+diff --git a/configure.in b/configure.in
+index 6f3e88f..8ddf017 100755
+--- a/configure.in
++++ b/configure.in
+@@ -1423,7 +1423,7 @@ dnl> NET-SNMP
+ dnl>
+ if test ".${ac_disable_snmp}" != ".yes"; then
+   AC_CHECK_TOOL(NETSNMP, net-snmp-config)
+-  if test -n "$NETSNMP"; then
++  if test -n "$NETSNMP" -a -e "$NETSNMP"; then
+     AC_DEFINE_UNQUOTED(HAVE_SNMP, 1, [SNMP is supported])
+     SNMPLIBS="`$NETSNMP --libs`"
+     SNMPLIBS="`echo ${SNMPLIBS}|sed -e s,'-R../lib',,g`"
meta-networking/recipes-support/ntop/ntop/ntop_init.patch new file +228 -0

228 lines not on this page · raw message

meta-networking/recipes-support/ntop/ntop/ntop_webInterface.patch new file +19 -0
new file mode 100644
index 0000000..9f57ca4
@@ -0,0 +1,19 @@
+change osName to version as it prints out "ntop Version".
+
+Upstream-Status: Pending
+
+Signed-off-by: Yao Zhao <[email protected]>
+---
+diff --git a/webInterface.c b/webInterface.c
+index 5622e69..8cb7a67 100644
+--- a/webInterface.c
++++ b/webInterface.c
+@@ -5816,7 +5816,7 @@ static void printNtopConfigInfoData(int textPrintFlag, UserPref *pref) {
+   printInfoSectionTitle(textPrintFlag, "Basic Information");
+ 
+   safe_snprintf(__FILE__, __LINE__, formatBuf, sizeof(formatBuf), "%s (%d bit)",
+-		osName, sizeof(long) == 8 ? 64 : 32);
++		version, sizeof(long) == 8 ? 64 : 32);
+   printFeatureConfigInfo(textPrintFlag, "ntop Version", formatBuf);
+ 
+ #ifndef WIN32
meta-networking/recipes-support/ntop/ntop/support-arm64.patch new file +28 -0
new file mode 100644
index 0000000..0b1e8af
@@ -0,0 +1,28 @@
+Add support for arm64
+
+Upstream-Status: Inappropriate [no longer maintained]
+
+Signed-off-by: Yue Tao <[email protected]>
+
+diff --git a/nDPI/config.sub.old b/nDPI/config.sub
+index c2d1257..e4347ac 100755
+--- a/nDPI/config.sub.old
++++ b/nDPI/config.sub
+@@ -249,7 +249,7 @@ case $basic_machine in
+ 	| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+ 	| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+ 	| am33_2.0 \
+-	| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
++	| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 | aarch64 \
+ 	| bfin \
+ 	| c4x | clipper \
+ 	| d10v | d30v | dlx | dsp16xx \
+@@ -331,7 +331,7 @@ case $basic_machine in
+ 	| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+ 	| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+ 	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+-	| arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
++	| arm-*  | armbe-* | armle-* | armeb-* | armv*-* | aarch64-* \
+ 	| avr-* | avr32-* \
+ 	| bfin-* | bs2000-* \
+ 	| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
meta-networking/recipes-support/ntop/ntop/use-static-inline.patch new file +32 -0
new file mode 100644
index 0000000..2b001c1
@@ -0,0 +1,32 @@
+[PATCH] replace 'inline' with 'static inline' for gcc 5.x
+
+gcc 5.x defaults to -std=gnu11 instead of -std=gnu89 which change
+the semantics for inline functions and the standalone 'inline'
+causes error with "gcc5 -g -o0"
+ 
+Replace inline with static inline to be compatible with both gcc 4
+and 5.
+
+Upstream-status: Pending
+
+Signed-off-by: Roy Li <[email protected]>
+---
+ nDPI/src/lib/protocols/ssl.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/nDPI/src/lib/protocols/ssl.c b/nDPI/src/lib/protocols/ssl.c
+index 245b8c3..72beda9 100644
+--- a/nDPI/src/lib/protocols/ssl.c
++++ b/nDPI/src/lib/protocols/ssl.c
+@@ -39,7 +39,7 @@ static void ipoque_int_ssl_add_connection(struct ipoque_detection_module_struct
+ 
+ #ifdef HAVE_NTOP
+ #ifndef WIN32
+-inline int min(int a, int b) { return(a < b ? a : b); }
++static inline int min(int a, int b) { return(a < b ? a : b); }
+ #endif
+ 
+ static void stripCertificateTrailer(char *buffer, int buffer_len) {
+-- 
+1.9.1
+
meta-networking/recipes-support/ntop/ntop_5.0.1.bb new file +4 -0
new file mode 100644
index 0000000..77b5e43
@@ -0,0 +1,4 @@
+include ntop.inc
+
+SRC_URI[md5sum] = "01710b6925a8a5ffe1a41b8b512ebd69"
+SRC_URI[sha256sum] = "7e8e84cb14d2173beaca4d4cb991a14d84a4bef84ec37b2276bc363f45c52ef8"
Signature · 1 line
2.7.4