diff options
| author | Yi Zhao <yi.zhao@windriver.com> | 2017-07-28 15:42:51 +0800 |
|---|---|---|
| committer | Joe MacDonald <joe_macdonald@mentor.com> | 2017-09-12 10:37:17 -0400 |
| commit | fe11100661547ba3a0e85754965173ae6af15193 (patch) | |
| tree | 37a935d32542227f54b8762ca78951915665c6be | |
| parent | a5846fc960ac002a35455916eb78ba156b1d9005 (diff) | |
| download | meta-openembedded-fe11100661547ba3a0e85754965173ae6af15193.tar.gz | |
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.
Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
9 files changed, 642 insertions, 0 deletions
diff --git a/meta-networking/recipes-support/ntop/ntop.inc b/meta-networking/recipes-support/ntop/ntop.inc new file mode 100644 index 0000000000..b964334252 --- /dev/null +++ b/meta-networking/recipes-support/ntop/ntop.inc | |||
| @@ -0,0 +1,131 @@ | |||
| 1 | SUMMARY = "ntop is network top" | ||
| 2 | DESCRIPTION = "ntop is a network traffic probe that shows the network usage, \ | ||
| 3 | similar to what the popular top Unix command does." | ||
| 4 | |||
| 5 | SECTION = "console/network" | ||
| 6 | |||
| 7 | LICENSE = "GPLv2+ & GPLv3 & OpenSSL" | ||
| 8 | LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504 \ | ||
| 9 | file://LICENSE-OpenSSL.txt;md5=a409f902e447ddd889cffa0c70e7c7c2 \ | ||
| 10 | " | ||
| 11 | |||
| 12 | SRC_URI = "${SOURCEFORGE_MIRROR}/ntop/ntop-${PV}.tar.gz \ | ||
| 13 | file://ntop_configure_in.patch \ | ||
| 14 | file://ntop_init.patch \ | ||
| 15 | file://ntop_webInterface.patch \ | ||
| 16 | file://ntop_configure_in_net_snmp_config_exist.patch \ | ||
| 17 | file://ntop.service \ | ||
| 18 | file://use-static-inline.patch \ | ||
| 19 | file://support-arm64.patch \ | ||
| 20 | " | ||
| 21 | |||
| 22 | inherit autotools-brokensep useradd pythonnative pkgconfig systemd | ||
| 23 | |||
| 24 | DEPENDS = "geoip rrdtool python zlib libpcap gdbm" | ||
| 25 | |||
| 26 | PACKAGECONFIG ??= "openssl snmp plugins" | ||
| 27 | PACKAGECONFIG[openssl] = "--with-ssl, --without-ssl, openssl, openssl" | ||
| 28 | PACKAGECONFIG[snmp] = "--enable-snmp=yes NETSNMP=${STAGING_BINDIR_CROSS}/net-snmp-config, \ | ||
| 29 | --disable-snmp,net-snmp," | ||
| 30 | PACKAGECONFIG[plugins] = "--enable-plugins=yes, --disable-plugins, ," | ||
| 31 | |||
| 32 | EXTRA_OECONF += "ac_cv_file_aclocal_m4=yes ac_cv_file_depcomp=no" | ||
| 33 | |||
| 34 | do_configure() { | ||
| 35 | cp ${STAGING_DATADIR_NATIVE}/aclocal/libtool.m4 libtool.m4.in | ||
| 36 | cat acinclude.m4.in acinclude.m4.ntop libtool.m4.in > acinclude.m4 | ||
| 37 | cp 3rd_party/* ./ | ||
| 38 | |||
| 39 | # config nDPI | ||
| 40 | cd nDPI | ||
| 41 | ./configure ${CONFIGUREOPTS} --with-pic | ||
| 42 | cd .. | ||
| 43 | |||
| 44 | sed -i -e 's:^CFG_DBFILE_DIR=$localstatedir/ntop:CFG_DBFILE_DIR=$localstatedir/lib/ntop:' ${S}/configure.in | ||
| 45 | |||
| 46 | # fix the CFLAGS, CPPFLAGS, LDFLAGS, remove the host include | ||
| 47 | sed -i \ | ||
| 48 | -e 's:\(^CFLAGS="\$.*\) -I/usr/local/include -I/opt/local/include":\1":' \ | ||
| 49 | -e 's:\(^CPPFLAGS="\$.*\) -I/usr/local/include -I/opt/local/include":\1":' \ | ||
| 50 | -e 's:\(^LDFLAGS="\$.*\) -L/usr/local/lib -L/opt/local/lib":\1":' \ | ||
| 51 | ${S}/configure.in | ||
| 52 | |||
| 53 | # replace the DISTRO RELEASE in configure.in which are host's | ||
| 54 | # with our release, although those doesn't affect functionality | ||
| 55 | sed -i -e \ | ||
| 56 | '/DEFINEOS="LINUX"/{N;s/DISTRO=.*/DISTRO="${DISTRO}"/;N;s/RELEASE=.*/RELEASE="${DISTRO_VERSION}"/;}' \ | ||
| 57 | ${S}/configure.in | ||
| 58 | |||
| 59 | # osName in original configure.in should be ${TARGET_SYS} | ||
| 60 | # which will show in ntop's "show configuration" | ||
| 61 | sed -i -e \ | ||
| 62 | 's:^osName=.*:osName=${TARGET_SYS}:' \ | ||
| 63 | ${S}/configure.in | ||
| 64 | |||
| 65 | # rename configureextra to configureextra_rename to avoid | ||
| 66 | # configure.in to guess host OS and pull in more configure, non needed | ||
| 67 | # which will cause some cross-compiling failure on specific host | ||
| 68 | # e.g. SUSE(SLED...) | ||
| 69 | test ! -f configureextra || mv -f configureextra configureextra_rename | ||
| 70 | |||
| 71 | # make sure configure finds python includdirs/libs with these envs | ||
| 72 | export BUILD_SYS=${BUILD_SYS} HOST_SYS=${HOST_SYS} \ | ||
| 73 | STAGING_INCDIR=${STAGING_INCDIR} \ | ||
| 74 | STAGING_LIBDIR=${STAGING_LIBDIR} | ||
| 75 | |||
| 76 | autotools_do_configure | ||
| 77 | } | ||
| 78 | |||
| 79 | do_compile_prepend() { | ||
| 80 | cd nDPI | ||
| 81 | oe_runmake | ||
| 82 | cd .. | ||
| 83 | } | ||
| 84 | |||
| 85 | do_install_append() { | ||
| 86 | # remove the empty dirs | ||
| 87 | rm -rf ${D}${libdir}/plugins | ||
| 88 | |||
| 89 | install -D -m 0755 ${S}/packages/RedHat/ntop.init \ | ||
| 90 | ${D}${sysconfdir}/init.d/ntop | ||
| 91 | install -D -m 0644 ${S}/packages/RedHat/ntop.conf.sample \ | ||
| 92 | ${D}${sysconfdir}/ntop.conf | ||
| 93 | |||
| 94 | # change ntop dir in ntop.conf | ||
| 95 | # don't use the -P as the ntop.init didn't support it | ||
| 96 | sed -i -e "s:^--db-file-path /usr/share/ntop:--db-file-path /var/lib/ntop:" \ | ||
| 97 | -e "s:^#? -P /var/ntop:#? -P /var/lib/ntop:" \ | ||
| 98 | ${D}${sysconfdir}/ntop.conf | ||
| 99 | |||
| 100 | # For systemd | ||
| 101 | if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then | ||
| 102 | install -D -m 0755 ${S}/packages/RedHat/ntop.init ${D}${libexecdir}/ntop-helper | ||
| 103 | install -D -m 0644 ${WORKDIR}/ntop.service ${D}${systemd_system_unitdir}/ntop.service | ||
| 104 | sed -i -e 's,@LIBEXECDIR@,${libexecdir},g' \ | ||
| 105 | -e 's,@SYSCONFDIR@,${sysconfdir},g' \ | ||
| 106 | ${D}${systemd_system_unitdir}/ntop.service | ||
| 107 | fi | ||
| 108 | |||
| 109 | # Fix host-user-contaminated issue | ||
| 110 | chown -R root:root ${D} | ||
| 111 | |||
| 112 | chown -R ntop.ntop ${D}${datadir}/ntop | ||
| 113 | chown -R ntop:ntop ${D}${localstatedir}/lib/ntop | ||
| 114 | } | ||
| 115 | |||
| 116 | USERADD_PACKAGES = "${PN}" | ||
| 117 | USERADD_PARAM_${PN} = "-M -g ntop -r -d ${localstatedir}/lib/ntop \ | ||
| 118 | -s /usr/sbin/nologin -c 'ntop' ntop" | ||
| 119 | GROUPADD_PARAM_${PN} = "-r ntop" | ||
| 120 | |||
| 121 | SYSTEMD_SERVICE_${PN} = "ntop.service" | ||
| 122 | SYSTEMD_AUTO_ENABLE = "disable" | ||
| 123 | |||
| 124 | FILES_${PN}_append = "${libdir}/ntop/plugins ${libdir}/libntop-*.so \ | ||
| 125 | ${libdir}/libntopreport-*.so ${libdir}/lib*-${PV}.so" | ||
| 126 | FILES_${PN}-dev = "${includedir} ${libdir}/libntop.so \ | ||
| 127 | ${libdir}/libntopreport.so \ | ||
| 128 | ${libdir}/libnetflowPlugin.so ${libdir}/libsflowPlugin.so \ | ||
| 129 | ${libdir}/librrdPlugin.so \ | ||
| 130 | ${libdir}/*.a ${libdir}/libntopreport.a ${libdir}/*.la" | ||
| 131 | |||
diff --git a/meta-networking/recipes-support/ntop/ntop/ntop.service b/meta-networking/recipes-support/ntop/ntop/ntop.service new file mode 100644 index 0000000000..1ead2a0c5f --- /dev/null +++ b/meta-networking/recipes-support/ntop/ntop/ntop.service | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | [Unit] | ||
| 2 | Description=A network traffic probe similar to the UNIX top command | ||
| 3 | Requires=network.target | ||
| 4 | |||
| 5 | ConditionPathExists=@SYSCONFDIR@/ntop.conf | ||
| 6 | After=syslog.target network.target | ||
| 7 | |||
| 8 | [Service] | ||
| 9 | Type=oneshot | ||
| 10 | RemainAfterExit=yes | ||
| 11 | ExecStart=@LIBEXECDIR@/ntop-helper start | ||
| 12 | ExecStop=@LIBEXECDIR@/ntop-helper stop | ||
| 13 | |||
| 14 | [Install] | ||
| 15 | WantedBy=multi-user.target | ||
diff --git a/meta-networking/recipes-support/ntop/ntop/ntop_configure_in.patch b/meta-networking/recipes-support/ntop/ntop/ntop_configure_in.patch new file mode 100644 index 0000000000..392cb082b7 --- /dev/null +++ b/meta-networking/recipes-support/ntop/ntop/ntop_configure_in.patch | |||
| @@ -0,0 +1,164 @@ | |||
| 1 | 1)add --with-pcap-config option to use libpcap's pcap-config | ||
| 2 | 2)add AC_CHECK_LIB if user didn't specify PCAP_ROOT and pcap-config | ||
| 3 | put it before host check to make cross-compiling easier. | ||
| 4 | pcap doesn't need extra include and libs so it is fine. | ||
| 5 | 3)remove old rrd configure code but use pkg-config to config rrd | ||
| 6 | rrdtool should have the pkg-config file installed. | ||
| 7 | 4)fix python-config | ||
| 8 | 5)change AC_TRY_RUN to AC_COMPILE_IFELSE for pthread_rwlock_t checking | ||
| 9 | 6)fix a net-snmp-config bug | ||
| 10 | |||
| 11 | Upstream-Status: Pending | ||
| 12 | |||
| 13 | Signed-off-by: Yao Zhao <yao.zhao@windriver.com> | ||
| 14 | --- | ||
| 15 | diff --git a/configure.in b/configure.in | ||
| 16 | index 0c7c0a5..cad40be 100644 | ||
| 17 | --- a/configure.in | ||
| 18 | +++ b/configure.in | ||
| 19 | @@ -230,14 +230,14 @@ dnl> | ||
| 20 | AC_ARG_WITH(void, | ||
| 21 | [ +-External-source-locations:-------------------------------------------------+]) | ||
| 22 | |||
| 23 | -AC_ARG_WITH( rrd-home, | ||
| 24 | - [ --with-rrd-home=DIR Usually /usr/local/rrdtool-1.2.x], | ||
| 25 | - RRD_HOME="$withval", | ||
| 26 | - RRD_HOME=/usr/local/rrdtool-1.2.19) | ||
| 27 | AC_ARG_WITH( pcap-root, | ||
| 28 | [ --with-pcap-root=DIR LBNL pcap located in DIR], | ||
| 29 | PCAP_ROOT="$withval", | ||
| 30 | PCAP_ROOT=) | ||
| 31 | +AC_ARG_WITH( pcap-config, | ||
| 32 | + [ --with-pcap-config=path/pcap-config where to find pcap-config], | ||
| 33 | + PCAP_CONFIG="$withval", | ||
| 34 | + PCAP_CONFIG=) | ||
| 35 | AC_ARG_WITH( gdbm-root, | ||
| 36 | [ --with-gdbm-root=DIR gdbm located in DIR], | ||
| 37 | GDBM_DIRECTORY="$withval", | ||
| 38 | @@ -556,6 +556,7 @@ if test ".${PCAPRING_DIR}" != .; then | ||
| 39 | else | ||
| 40 | |||
| 41 | TMP_ROOT=${HOME}/PF_RING/userland/libpcap/ | ||
| 42 | +FOUND_PCAP=1 | ||
| 43 | if test ".${PCAP_ROOT}" == . && | ||
| 44 | test -d ${TMP_ROOT} && | ||
| 45 | test -r ${TMP_ROOT}/libpcap.a; then | ||
| 46 | @@ -563,6 +564,18 @@ if test ".${PCAP_ROOT}" == . && | ||
| 47 | CORELIBS="${CORELIBS} -L${TMP_ROOT} -L${HOME}/PF_RING/userland/lib -lpfring -lpcap " | ||
| 48 | INCS="${INCS} -I ${PCAP_ROOT}" | ||
| 49 | AC_MSG_RESULT([found in $PCAP_ROOT]) | ||
| 50 | +elif test -n "${PCAP_CONFIG}" && test -x "${PCAP_CONFIG}"; then | ||
| 51 | + CORELIBS="${CORELIBS} $(${PCAP_CONFIG} --libs)" | ||
| 52 | + INCS="${INCS} $(${PCAP_CONFIG} --cflags)" | ||
| 53 | + AC_DEFINE_UNQUOTED(HAVE_LIBPCAP, 1, [have libpcap ]) | ||
| 54 | + AC_MSG_RESULT([found pcap-config: $PCAP_CONFIG, libs:$(${PCAP_CONFIG} --libs) cflags:$(${PCAP_CONFIG} --cflags)]) | ||
| 55 | +else | ||
| 56 | + AC_CHECK_LIB(pcap, pcap_lookupdev, , | ||
| 57 | + [FOUND_PCAP=]) | ||
| 58 | +fi | ||
| 59 | + | ||
| 60 | +if test -n "$FOUND_PCAP"; then | ||
| 61 | + : | ||
| 62 | elif test ".${PCAP_ROOT}" != .; then | ||
| 63 | if test -d $PCAP_ROOT && | ||
| 64 | test -r $PCAP_ROOT/lib/libpcap.a && | ||
| 65 | @@ -880,44 +893,11 @@ AC_CHECK_LIB([z], [zlibVersion], [], [ | ||
| 66 | exit -1 | ||
| 67 | ]) | ||
| 68 | |||
| 69 | -# RRD | ||
| 70 | -if test -d "$RRD_HOME"; then | ||
| 71 | - AC_MSG_RESULT(checking for RRD home... yes) | ||
| 72 | -else | ||
| 73 | - RRD_HOME=/usr/local/rrdtool | ||
| 74 | - if test -d "$RRD_HOME"; then | ||
| 75 | - AC_MSG_RESULT(Checking rrdtool in $RRD_HOME) | ||
| 76 | - else | ||
| 77 | - RRD_HOME=/usr/local | ||
| 78 | - fi | ||
| 79 | -fi | ||
| 80 | - | ||
| 81 | -RRD_LIB="-L${RRD_HOME}/lib -lrrd_th" | ||
| 82 | - | ||
| 83 | -if test -f "$RRD_HOME/lib/librrd_th.so"; then | ||
| 84 | - AC_MSG_RESULT(checking for rrdtool... yes) | ||
| 85 | -else | ||
| 86 | - if test -f "$RRD_HOME/lib/librrd_th.dylib"; then # OSX | ||
| 87 | - AC_MSG_RESULT(checking for rrdtool... yes) | ||
| 88 | - else | ||
| 89 | - if test -f "$RRD_HOME/lib/librrd_th.a"; then | ||
| 90 | - AC_MSG_RESULT(checking for rrdtool... yes) | ||
| 91 | - else | ||
| 92 | - AC_CHECK_LIB([rrd_th], [main]) | ||
| 93 | - if test ".${ac_cv_lib_rrd_th_main}" != ".yes"; then | ||
| 94 | - AC_MSG_ERROR(Unable to find RRD at $RRD_HOME: please use --with-rrd-home=DIR); | ||
| 95 | - AC_MSG_ERROR(RRD source can be downloaded from http://www.rrdtool.org/); | ||
| 96 | - else | ||
| 97 | - RRD_LIB= | ||
| 98 | - fi | ||
| 99 | - fi | ||
| 100 | - fi | ||
| 101 | -fi | ||
| 102 | - | ||
| 103 | -RRD_INC= | ||
| 104 | -if test -d "${RRD_HOME}/include"; then | ||
| 105 | - RRD_INC="-I${RRD_HOME}/include" | ||
| 106 | -fi | ||
| 107 | +PKG_CHECK_MODULES( [RRD], [librrd] ) | ||
| 108 | +AC_SUBST(RRD_CFLAGS) | ||
| 109 | +AC_SUBST(RRD_LIBS) | ||
| 110 | +RRD_INC=$RRD_FLAGS | ||
| 111 | +RRD_LIB=$RRD_LIBS | ||
| 112 | |||
| 113 | dnl> The failed recheck stuff below is courtesy of Chris Turbeville [turbo@verio.net] | ||
| 114 | dnl> Chris developed this for Solaris 9, confirming work I had done earlier for FreeBSD | ||
| 115 | @@ -1041,7 +1021,7 @@ AC_CHECK_HEADERS([sched.h sys/sched.h]) | ||
| 116 | AC_CHECK_HEADERS([pthread.h]) | ||
| 117 | |||
| 118 | AC_MSG_CHECKING([if r/w locks are supported]) | ||
| 119 | -AC_TRY_RUN([ | ||
| 120 | +AC_COMPILE_IFELSE([ | ||
| 121 | #include <pthread.h> | ||
| 122 | |||
| 123 | int main() | ||
| 124 | @@ -1443,15 +1423,15 @@ dnl> NET-SNMP | ||
| 125 | dnl> | ||
| 126 | if test ".${ac_disable_snmp}" != ".yes"; then | ||
| 127 | AC_CHECK_TOOL(NETSNMP, net-snmp-config) | ||
| 128 | - if test "x$ac_cv_prog_ac_ct_NETSNMP" = "xnet-snmp-config"; then | ||
| 129 | + if test -n "$NETSNMP"; then | ||
| 130 | AC_DEFINE_UNQUOTED(HAVE_SNMP, 1, [SNMP is supported]) | ||
| 131 | - SNMPLIBS="`net-snmp-config --libs`" | ||
| 132 | + SNMPLIBS="`$NETSNMP --libs`" | ||
| 133 | SNMPLIBS="`echo ${SNMPLIBS}|sed -e s,'-R../lib',,g`" | ||
| 134 | echo "net-snmp libs: ${SNMPLIBS}" | ||
| 135 | LIBS="${LIBS} ${SNMPLIBS}" | ||
| 136 | dnl remove unecessary path | ||
| 137 | LIBS=`echo ${LIBS}|sed -e s,'-R../lib',,g` | ||
| 138 | - INCS="${INCS} `net-snmp-config --cflags`" | ||
| 139 | + INCS="${INCS} `$NETSNMP --cflags`" | ||
| 140 | else | ||
| 141 | AC_MSG_RESULT(NETSNMP is not present: SNMP support is disabled) | ||
| 142 | fi | ||
| 143 | @@ -1464,10 +1444,9 @@ SAVED_LIBS=$LIBS | ||
| 144 | dnl> | ||
| 145 | dnl> PYTHON | ||
| 146 | dnl> | ||
| 147 | - AC_CHECK_TOOL(PYTHON, python-config) | ||
| 148 | - PYTHON_CONFIG="" | ||
| 149 | + AC_CHECK_TOOL(PYTHON_CONFIG, python-config) | ||
| 150 | |||
| 151 | - if test "x$ac_cv_prog_ac_ct_PYTHON" != "xpython-config"; then | ||
| 152 | + if test -z "$PYTHON_CONFIG"; then | ||
| 153 | if test -f "/etc/debian_version"; then | ||
| 154 | AC_MSG_RESULT(Please install python-dev and rerun configure) | ||
| 155 | exit 1 | ||
| 156 | @@ -1481,8 +1460,6 @@ dnl> | ||
| 157 | PYTHON_CONFIG="python-config" | ||
| 158 | fi | ||
| 159 | fi | ||
| 160 | - else | ||
| 161 | - PYTHON_CONFIG="python-config" | ||
| 162 | fi | ||
| 163 | |||
| 164 | if test "x$PYTHON_CONFIG" != "x"; then | ||
diff --git a/meta-networking/recipes-support/ntop/ntop/ntop_configure_in_net_snmp_config_exist.patch b/meta-networking/recipes-support/ntop/ntop/ntop_configure_in_net_snmp_config_exist.patch new file mode 100644 index 0000000000..269138df93 --- /dev/null +++ b/meta-networking/recipes-support/ntop/ntop/ntop_configure_in_net_snmp_config_exist.patch | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | Check net-snmp-config's existence in case user specified the | ||
| 2 | ac_cv_prog_NETSNMP to avoid HAVE_SNMP defined if the specified | ||
| 3 | net-snmp-config doesn't exist. | ||
| 4 | |||
| 5 | Upstream-Status: Inappropriate [Embedded specific] | ||
| 6 | |||
| 7 | Signed-off-by: Yao Zhao <yao.zhao@windriver.com> | ||
| 8 | --- | ||
| 9 | diff --git a/configure.in b/configure.in | ||
| 10 | index 6f3e88f..8ddf017 100755 | ||
| 11 | --- a/configure.in | ||
| 12 | +++ b/configure.in | ||
| 13 | @@ -1423,7 +1423,7 @@ dnl> NET-SNMP | ||
| 14 | dnl> | ||
| 15 | if test ".${ac_disable_snmp}" != ".yes"; then | ||
| 16 | AC_CHECK_TOOL(NETSNMP, net-snmp-config) | ||
| 17 | - if test -n "$NETSNMP"; then | ||
| 18 | + if test -n "$NETSNMP" -a -e "$NETSNMP"; then | ||
| 19 | AC_DEFINE_UNQUOTED(HAVE_SNMP, 1, [SNMP is supported]) | ||
| 20 | SNMPLIBS="`$NETSNMP --libs`" | ||
| 21 | SNMPLIBS="`echo ${SNMPLIBS}|sed -e s,'-R../lib',,g`" | ||
diff --git a/meta-networking/recipes-support/ntop/ntop/ntop_init.patch b/meta-networking/recipes-support/ntop/ntop/ntop_init.patch new file mode 100644 index 0000000000..e7684c1b4c --- /dev/null +++ b/meta-networking/recipes-support/ntop/ntop/ntop_init.patch | |||
| @@ -0,0 +1,228 @@ | |||
| 1 | Modify ntop.init to WRLinux 5.0 style. | ||
| 2 | |||
| 3 | Fix a small problem that when ntop not running, | ||
| 4 | /etc/init.d/ntop stop will return 1 | ||
| 5 | |||
| 6 | Upstream-Status: Inappropriate [embedded specific] | ||
| 7 | |||
| 8 | Signed-off-by: Yao Zhao <yao.zhao@windriver.com> | ||
| 9 | --- | ||
| 10 | packages/RedHat/ntop.init | 102 +++++++++----------------------------------- | ||
| 11 | 1 files changed, 21 insertions(+), 81 deletions(-) | ||
| 12 | |||
| 13 | diff --git a/packages/RedHat/ntop.init b/packages/RedHat/ntop.init | ||
| 14 | index 40d49f1..a189c59 100755 | ||
| 15 | --- a/packages/RedHat/ntop.init | ||
| 16 | +++ b/packages/RedHat/ntop.init | ||
| 17 | @@ -10,19 +10,9 @@ | ||
| 18 | # You have set the admin password - read docs/1STRUN.txt | ||
| 19 | # You have created /etc/ntop.conf with appropriate parameters. | ||
| 20 | |||
| 21 | -# To identify an interface to ntop, use the following flags | ||
| 22 | -# in /etc/sysconfig/network-scripts/ifcfg-ethx | ||
| 23 | - | ||
| 24 | -# NTOP="yes" <--- means for ntop to use this interface | ||
| 25 | -# NTOPCONFIG="yes" <--- means for ntop to configure this interface | ||
| 26 | - | ||
| 27 | # Note that if you give a -i parameter in either /etc/ntop.conf or | ||
| 28 | # the command line, the scan is NOT performed. | ||
| 29 | |||
| 30 | -# However, when it comes to the configuration step, with NTOPCONFIG="yes" | ||
| 31 | -# the interface is configured regardless of how the interface list was | ||
| 32 | -# specified. | ||
| 33 | - | ||
| 34 | # | ||
| 35 | # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- | ||
| 36 | # | ||
| 37 | @@ -107,11 +97,7 @@ ntopusesyslog="local3" | ||
| 38 | invoked=$0 | ||
| 39 | |||
| 40 | # Source function library. | ||
| 41 | -. /etc/rc.d/init.d/functions | ||
| 42 | - | ||
| 43 | -# Source networking configuration. | ||
| 44 | -. /etc/sysconfig/network | ||
| 45 | - | ||
| 46 | +. /etc/init.d/functions | ||
| 47 | |||
| 48 | # Basic sanity checks... | ||
| 49 | if ! [ -x $prog ]; then | ||
| 50 | @@ -124,16 +110,6 @@ if ! [ -x $prog ]; then | ||
| 51 | exit 1 | ||
| 52 | fi | ||
| 53 | |||
| 54 | -if [ ${NETWORKING} = "no" ]; then | ||
| 55 | - echo "" | ||
| 56 | - echo "ERROR -" | ||
| 57 | - echo " Networking is not up!" | ||
| 58 | - echo "" | ||
| 59 | - echo "Aborting..." | ||
| 60 | - echo "" | ||
| 61 | - exit 1 | ||
| 62 | -fi | ||
| 63 | - | ||
| 64 | if ! [ -f ${conf} ]; then | ||
| 65 | echo "" | ||
| 66 | echo "ERROR -" | ||
| 67 | @@ -180,8 +156,8 @@ fi | ||
| 68 | if [ "${debug}" = "y" ]; then echo "DEBUG: parm file temp is ${parmfile}"; fi | ||
| 69 | |||
| 70 | cmd=`echo \ | ||
| 71 | - @${conf} \ | ||
| 72 | -i tbd \ | ||
| 73 | + @${conf} \ | ||
| 74 | $extra $@` | ||
| 75 | |||
| 76 | echo ${cmd} | awk ' \ | ||
| 77 | @@ -305,42 +281,6 @@ logger -p ${ntopusesyslog} -t ${name}${instance} -- "INITD - Configuration | ||
| 78 | |||
| 79 | # Build list of interfaces, e.g eth0 eth1 eth1:1 | ||
| 80 | # (Yeah, we'll have to convert that to eth0,eth1,eth1:1 later | ||
| 81 | -if [ ".${ntopinterface}" = ".tbd" ]; then | ||
| 82 | - | ||
| 83 | - ntopinterface="" | ||
| 84 | - iflist=`ip link show | \ | ||
| 85 | - awk '/^[0-9]*:\ eth/ { printf("%s ", substr($2, 1, length($2)-1)) }'` | ||
| 86 | - logger -p ${ntopusesyslog} -t ${name}${instance} -- "INITD - Scanning all interfaces $iflist" | ||
| 87 | - if [ "${debug}" = "y" ]; then echo "DEBUG: Interface candidates are ${iflist}"; fi | ||
| 88 | - | ||
| 89 | - for eth in $iflist; do | ||
| 90 | - | ||
| 91 | - if ! LANG=C egrep -L "^[Nn][Tt][Oo][Pp]=['\"]?[Yy][Ee][Ss]['\"]?" \ | ||
| 92 | - /etc/sysconfig/network-scripts/ifcfg-$eth > /dev/null ; then | ||
| 93 | - logger -p ${ntopusesyslog} -t ${name}${instance} -- "INITD - $eth is not ntop=yes, skipping" | ||
| 94 | - if [ "${debug}" = "y" ]; then echo "DEBUG: $eth not ntop=yes"; fi | ||
| 95 | - continue | ||
| 96 | - fi | ||
| 97 | - | ||
| 98 | - ntopinterface="${ntopinterface} $eth" | ||
| 99 | - | ||
| 100 | - ip=`ip addr show $eth | \ | ||
| 101 | - awk '/inet/ { printf("%s", substr($2, 1, index($2, "/")-1)) }'` | ||
| 102 | - | ||
| 103 | - if [ ".$ip" = "." ]; then | ||
| 104 | - is="is unnumbered interface" | ||
| 105 | - else | ||
| 106 | - is="has IP address $ip" | ||
| 107 | - fi | ||
| 108 | - logger -p ${ntopusesyslog} -t ${name}${instance} -- "INITD - $eth is ntop=yes, ${is}" | ||
| 109 | - if [ "${debug}" = "y" ]; then echo "DEBUG: $eth ntop=yes, ${is}"; fi | ||
| 110 | - | ||
| 111 | - done | ||
| 112 | - | ||
| 113 | -else | ||
| 114 | - logger -p ${ntopusesyslog} -t ${name}${instance} -- "INITD - Skipping interface scan - list in parms" | ||
| 115 | -fi | ||
| 116 | - | ||
| 117 | if [ "x${ntopinterface}" = "x" ]; then | ||
| 118 | ntopinterface="none" | ||
| 119 | fi | ||
| 120 | @@ -462,12 +402,6 @@ config_interfaces () { | ||
| 121 | if="${if},${eth}" | ||
| 122 | fi | ||
| 123 | |||
| 124 | - if ! LANG=C egrep -L "^[Nn][Tt][Oo][Pp][Cc].*=['\"]?[Yy][Ee][Ss]['\"]?" \ | ||
| 125 | - /etc/sysconfig/network-scripts/ifcfg-$eth > /dev/null ; then | ||
| 126 | - logger -p ${ntopusesyslog} -t ${name}${instance} -- "INITD - $eth is not ntopconfigure=yes, skipping" | ||
| 127 | - continue | ||
| 128 | - fi | ||
| 129 | - | ||
| 130 | logger -p ${ntopusesyslog} -t ${name}${instance} -- "INITD - Configuring $eth" | ||
| 131 | if [ "${debug}" = "y" ]; then echo "DEBUG: Configuring $eth"; fi | ||
| 132 | |||
| 133 | @@ -527,7 +461,7 @@ start () { | ||
| 134 | show_extra | ||
| 135 | config_interfaces | ||
| 136 | |||
| 137 | - cmd=`echo $prog \ | ||
| 138 | + cmd=`echo \ | ||
| 139 | @${conf} \ | ||
| 140 | -i $if \ | ||
| 141 | $extra $@` | ||
| 142 | @@ -541,7 +475,7 @@ start () { | ||
| 143 | if [ ".${ldlibpath}" != "." ]; then | ||
| 144 | export LD_LIBRARY_PATH="${ldlibpath}" | ||
| 145 | fi | ||
| 146 | - daemon ${cmd} | ||
| 147 | + start-stop-daemon --start --quiet --exec $prog -- ${cmd} | ||
| 148 | RETVAL=$? | ||
| 149 | |||
| 150 | [ $RETVAL = 0 ] && touch /var/lock/subsys/${name}${instance} | ||
| 151 | @@ -551,6 +485,7 @@ start () { | ||
| 152 | stop () { | ||
| 153 | # stop daemon | ||
| 154 | |||
| 155 | + NOT_RUNNING=1 | ||
| 156 | RETVAL=1 | ||
| 157 | echo -n $"Stopping ${name}${instance}: " | ||
| 158 | logger -p ${ntopusesyslog} -t ${name}${instance} -- "INITD - Stopping: ${name}${instance}" | ||
| 159 | @@ -563,13 +498,14 @@ stop () { | ||
| 160 | if [ $rc = 0 ]; then | ||
| 161 | logger -p ${ntopusesyslog} -t ${name}${instance} -- "INITD - Sending SIGTERM to ${pid}" | ||
| 162 | if [ "${debug}" = "y" ]; then echo "Sending SIGTERM to ${pid}"; fi | ||
| 163 | - kill -s SIGTERM ${pid} | ||
| 164 | + kill -TERM ${pid} 2>&1 > /dev/null | ||
| 165 | RETVAL=$? | ||
| 166 | rm -f ${ntopdbfilepath}/ntop.pid | ||
| 167 | else | ||
| 168 | logger -p ${ntopusesyslog} -t ${name}${instance} -- "INITD - Unable to find process ${pid} ... will kill by name" | ||
| 169 | if [ "${debug}" = "y" ]; then echo "Unable to find process ${pid} ... will kill by name"; fi | ||
| 170 | fi | ||
| 171 | + NOT_RUNNING=0 | ||
| 172 | else | ||
| 173 | |||
| 174 | logger -p ${ntopusesyslog} -t ${name}${instance} -- "INITD - Unable to find ${ntopdbfilepath}/ntop.pid file ... will kill by name" | ||
| 175 | @@ -577,15 +513,16 @@ stop () { | ||
| 176 | |||
| 177 | fi | ||
| 178 | |||
| 179 | - echo | ||
| 180 | - | ||
| 181 | if [ $RETVAL != 0 ]; then | ||
| 182 | pids=`ps axf | grep '\/usr\/bin\/ntop' | awk '{ printf(" %s", $1) }; END { print "" }'` | ||
| 183 | - if [ "${pids}" != " " ]; then | ||
| 184 | + if [ "${pids}" != "" ]; then | ||
| 185 | logger -p ${ntopusesyslog} -t ${name}${instance} -- "INITD - Sending SIGTERM to ${prog}...${pids}" | ||
| 186 | if [ "${debug}" = "y" ]; then echo "Sending SIGTERM to ${prog}...${pids}"; fi | ||
| 187 | - kill -INT ${pids} | ||
| 188 | + kill -TERM ${pids} > /dev/null 2>&1 | ||
| 189 | RETVAL=$? | ||
| 190 | + NOT_RUNNING=0 | ||
| 191 | + else | ||
| 192 | + NOT_RUNNING=1 | ||
| 193 | fi | ||
| 194 | fi | ||
| 195 | |||
| 196 | @@ -597,13 +534,9 @@ stop () { | ||
| 197 | if [ "${debug}" = "y" ]; then echo "DEBUG: Unconfiguring interfaces"; fi | ||
| 198 | |||
| 199 | for eth in ${ntopinterface}; do | ||
| 200 | - if ! LANG=C egrep -L "^[Nn][Tt][Oo][Pp][Cc].*=['\"]?[Yy][Ee][Ss]['\"]?" \ | ||
| 201 | - /etc/sysconfig/network-scripts/ifcfg-$eth > /dev/null ; then | ||
| 202 | - logger -p ${ntopusesyslog} -t ${name}${instance} -- "INITD - $eth is not ntopconfigure=yes, skipping" | ||
| 203 | - if [ "${debug}" = "y" ]; then echo "DEBUG: $eth is not ntopconfigure=yes"; fi | ||
| 204 | - continue | ||
| 205 | + if [ "$eth" = "none" ]; then | ||
| 206 | + continue | ||
| 207 | fi | ||
| 208 | - | ||
| 209 | logger -p ${ntopusesyslog} -t ${name}${instance} -- "INITD - Unconfiguring $eth" | ||
| 210 | if [ "${debug}" = "y" ]; then echo "DEBUG: Unconfiguring $eth"; fi | ||
| 211 | |||
| 212 | @@ -623,6 +556,13 @@ stop () { | ||
| 213 | if [ "${debug}" = "y" ]; then echo "DEBUG: Interfaces are unconfigured"; fi | ||
| 214 | fi | ||
| 215 | |||
| 216 | + if [ $NOT_RUNNING -eq 1 -o $RETVAL -eq 0 ]; then | ||
| 217 | + echo " [ OK ]" | ||
| 218 | + RETVAL=0 | ||
| 219 | + else | ||
| 220 | + echo " [ FAILED ]" | ||
| 221 | + fi | ||
| 222 | + | ||
| 223 | return $RETVAL | ||
| 224 | } | ||
| 225 | |||
| 226 | -- | ||
| 227 | 1.7.5.4 | ||
| 228 | |||
diff --git a/meta-networking/recipes-support/ntop/ntop/ntop_webInterface.patch b/meta-networking/recipes-support/ntop/ntop/ntop_webInterface.patch new file mode 100644 index 0000000000..9f57ca4255 --- /dev/null +++ b/meta-networking/recipes-support/ntop/ntop/ntop_webInterface.patch | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | change osName to version as it prints out "ntop Version". | ||
| 2 | |||
| 3 | Upstream-Status: Pending | ||
| 4 | |||
| 5 | Signed-off-by: Yao Zhao <yao.zhao@windriver.com> | ||
| 6 | --- | ||
| 7 | diff --git a/webInterface.c b/webInterface.c | ||
| 8 | index 5622e69..8cb7a67 100644 | ||
| 9 | --- a/webInterface.c | ||
| 10 | +++ b/webInterface.c | ||
| 11 | @@ -5816,7 +5816,7 @@ static void printNtopConfigInfoData(int textPrintFlag, UserPref *pref) { | ||
| 12 | printInfoSectionTitle(textPrintFlag, "Basic Information"); | ||
| 13 | |||
| 14 | safe_snprintf(__FILE__, __LINE__, formatBuf, sizeof(formatBuf), "%s (%d bit)", | ||
| 15 | - osName, sizeof(long) == 8 ? 64 : 32); | ||
| 16 | + version, sizeof(long) == 8 ? 64 : 32); | ||
| 17 | printFeatureConfigInfo(textPrintFlag, "ntop Version", formatBuf); | ||
| 18 | |||
| 19 | #ifndef WIN32 | ||
diff --git a/meta-networking/recipes-support/ntop/ntop/support-arm64.patch b/meta-networking/recipes-support/ntop/ntop/support-arm64.patch new file mode 100644 index 0000000000..0b1e8afbc9 --- /dev/null +++ b/meta-networking/recipes-support/ntop/ntop/support-arm64.patch | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | Add support for arm64 | ||
| 2 | |||
| 3 | Upstream-Status: Inappropriate [no longer maintained] | ||
| 4 | |||
| 5 | Signed-off-by: Yue Tao <Yue.Tao@windriver.com> | ||
| 6 | |||
| 7 | diff --git a/nDPI/config.sub.old b/nDPI/config.sub | ||
| 8 | index c2d1257..e4347ac 100755 | ||
| 9 | --- a/nDPI/config.sub.old | ||
| 10 | +++ b/nDPI/config.sub | ||
| 11 | @@ -249,7 +249,7 @@ case $basic_machine in | ||
| 12 | | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | ||
| 13 | | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | ||
| 14 | | am33_2.0 \ | ||
| 15 | - | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ | ||
| 16 | + | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 | aarch64 \ | ||
| 17 | | bfin \ | ||
| 18 | | c4x | clipper \ | ||
| 19 | | d10v | d30v | dlx | dsp16xx \ | ||
| 20 | @@ -331,7 +331,7 @@ case $basic_machine in | ||
| 21 | | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | ||
| 22 | | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | ||
| 23 | | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | ||
| 24 | - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | ||
| 25 | + | arm-* | armbe-* | armle-* | armeb-* | armv*-* | aarch64-* \ | ||
| 26 | | avr-* | avr32-* \ | ||
| 27 | | bfin-* | bs2000-* \ | ||
| 28 | | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ | ||
diff --git a/meta-networking/recipes-support/ntop/ntop/use-static-inline.patch b/meta-networking/recipes-support/ntop/ntop/use-static-inline.patch new file mode 100644 index 0000000000..2b001c13e8 --- /dev/null +++ b/meta-networking/recipes-support/ntop/ntop/use-static-inline.patch | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | [PATCH] replace 'inline' with 'static inline' for gcc 5.x | ||
| 2 | |||
| 3 | gcc 5.x defaults to -std=gnu11 instead of -std=gnu89 which change | ||
| 4 | the semantics for inline functions and the standalone 'inline' | ||
| 5 | causes error with "gcc5 -g -o0" | ||
| 6 | |||
| 7 | Replace inline with static inline to be compatible with both gcc 4 | ||
| 8 | and 5. | ||
| 9 | |||
| 10 | Upstream-status: Pending | ||
| 11 | |||
| 12 | Signed-off-by: Roy Li <rongqing.li@windriver.com> | ||
| 13 | --- | ||
| 14 | nDPI/src/lib/protocols/ssl.c | 2 +- | ||
| 15 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
| 16 | |||
| 17 | diff --git a/nDPI/src/lib/protocols/ssl.c b/nDPI/src/lib/protocols/ssl.c | ||
| 18 | index 245b8c3..72beda9 100644 | ||
| 19 | --- a/nDPI/src/lib/protocols/ssl.c | ||
| 20 | +++ b/nDPI/src/lib/protocols/ssl.c | ||
| 21 | @@ -39,7 +39,7 @@ static void ipoque_int_ssl_add_connection(struct ipoque_detection_module_struct | ||
| 22 | |||
| 23 | #ifdef HAVE_NTOP | ||
| 24 | #ifndef WIN32 | ||
| 25 | -inline int min(int a, int b) { return(a < b ? a : b); } | ||
| 26 | +static inline int min(int a, int b) { return(a < b ? a : b); } | ||
| 27 | #endif | ||
| 28 | |||
| 29 | static void stripCertificateTrailer(char *buffer, int buffer_len) { | ||
| 30 | -- | ||
| 31 | 1.9.1 | ||
| 32 | |||
diff --git a/meta-networking/recipes-support/ntop/ntop_5.0.1.bb b/meta-networking/recipes-support/ntop/ntop_5.0.1.bb new file mode 100644 index 0000000000..77b5e436f2 --- /dev/null +++ b/meta-networking/recipes-support/ntop/ntop_5.0.1.bb | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | include ntop.inc | ||
| 2 | |||
| 3 | SRC_URI[md5sum] = "01710b6925a8a5ffe1a41b8b512ebd69" | ||
| 4 | SRC_URI[sha256sum] = "7e8e84cb14d2173beaca4d4cb991a14d84a4bef84ec37b2276bc363f45c52ef8" | ||
