debian/0000775000000000000000000000000012265237571007202 5ustar debian/README.Debian0000664000000000000000000000136412265236144011242 0ustar liboping on Debian ================== Notes on using liboping-dev: ---------------------------- The liboping library provides two functions, namely ping_setopt() and ping_iterator_get_info(), whose functionality is defined by a set of numerical IDs, each defining a specific feature. New features may be added by adding support for additional IDs without breaking the API or ABI. If your software uses those functions, make sure to build-depend on the appropriate version of liboping-dev. This will also ensure - by means of the 'Build-Depends-Package' field in liboping's symbols file (see dpkg-shlibdeps(1) for details) - that the resulting binary package depends on the right version of liboping while not imposing the latest version on all packages. debian/changelog0000664000000000000000000002032712265237530011053 0ustar liboping (1.6.2-4) unstable; urgency=low * always rebuild man pages (closes: 733341) -- Barak A. Pearlmutter Tue, 14 Jan 2014 13:44:56 +0000 liboping (1.6.2-3) unstable; urgency=medium * prettyping patch requires swizzling build dependency from libncurses to libncursesw (oops!) -- Barak A. Pearlmutter Fri, 27 Dec 2013 15:44:51 +0100 liboping (1.6.2-2) unstable; urgency=low * remove phony target declarations from debian/rules (closes: #720008) * dh 9 * bump standards version * remove unused/uninformative debian/ files: *.dirs, liboping.docs, README * stop installing docs COPYING, INSTALL, NEWS, replicated upstream changelog * print rpath before deleting it (when none, can remove chrpath removal code) * enable multiarch support * add quilt patch with prettyping support (closes: #731207) -- Barak A. Pearlmutter Thu, 26 Dec 2013 16:58:42 +0100 liboping (1.6.2-1) unstable; urgency=low * New upstream version -- Barak A. Pearlmutter Thu, 02 Feb 2012 23:00:14 +0000 liboping (1.6.1+2.g207d51d-3) unstable; urgency=low * Update/modernize debian packaging info: - Bump to dh 8. - Use dh and override_* to dramatically shorten debian/rules. - Use dh --parallel for multicore goodness. - Use dh --with autoreconf to build derived files like ./configure. - Use dh_xxx, e.g. dh_lintian, to reduce debian/rules boilerplate. - Generalise debian/*.install files - Single debian patch source option: when operative see git patches. - Trim trailing whitespace. - Convert officially depricated constructs to blessed replacements. * git ignore debian build debris. -- Barak A. Pearlmutter Sun, 16 Oct 2011 14:33:33 +0100 liboping (1.6.1+2.g207d51d-2) unstable; urgency=low [ Barak A. Pearlmutter ] * debian/control: - Updated standards-version to 3.9.2; no changes. * Simplified debian/liboping-dev.install, debian/oping.install. [ Sebastian Harl ] * debian/source/format: - Switched to '3.0 (quilt)' format. * debian/control: - Added Barak to uploaders. * debian/patches: - Added recvtos -- patch for #618729 (missing IP_RECVTOS on FreeBSD) as separate patch. - Added z-option -- upstream patch adding option -Z to enable non-zero exit codes in case a certain amount of replies were lost. * debian/rules: - Split target 'build' into 'build-arch' and 'build-indep'. -- Sebastian Harl Thu, 13 Oct 2011 16:32:46 +0200 liboping (1.6.1+2.g207d51d-1.1) unstable; urgency=low * Fix FTBS on kfreebsd due to IP_RECVTOS nonexistence (closes: #618729). * Kill inappropriate rpath in built perl library, which presumably appeared due to toolchain changes. -- Barak A. Pearlmutter Mon, 19 Sep 2011 09:39:54 +0100 liboping (1.6.1+2.g207d51d-1) unstable; urgency=low * New upstream release. - Based on release 1.6.1 plus upstream Git commits up to 207d51d, which fix two build issues. * debian/rules: - Do not install .la files in favor of the goal to remove those files (for details see ). - Use 'dh_prep' rather than 'dh_clean -k'. * debian/control: - Updated standards-version to 3.9.1. - Depend on debhelper (>=7) rather than (>=5) -- this is required for 'dh_prep'. -- Sebastian Harl Sun, 13 Mar 2011 22:27:08 +0100 liboping (1.4.0-1) unstable; urgency=low * New upstream release. * debian/control: - Updated standards-version to 3.8.4 -- no changes. - Build-depend on libncurses5-dev, required by the new "noping" ncurses front-end to liboping. - Let all packages depend on ${misc:Depends} as recommended by debhelper. - Improved oping's package description. * debian/oping.install: - Added /usr/bin/noping. * debian/oping.links: - Make noping.8 be a symlink to oping.8. * debian/rules, debian/oping.overrides: - Install /usr/bin/noping setuid root and document that in overrides. -- Sebastian Harl Tue, 15 Jun 2010 00:08:46 +0200 liboping (1.3.4-1) unstable; urgency=low * New upstream release. -- Sebastian Harl Sat, 26 Dec 2009 23:17:45 +0100 liboping (1.3.3-1) unstable; urgency=high * New upstream release: - Disable the "-f" command line option (read hosts from a file) if the real and affective user IDs don't match (e.g. when running setuid), unless "-" (STDIN) has been specified; thanks a lot to Steve Kemp for reporting this (Closes: #548684). * Set urgency to "high" because of the fix for #548684. * debian/control: - Updated Standards-Version to 3.8.3 - no changes. -- Sebastian Harl Wed, 30 Sep 2009 01:12:26 +0200 liboping (1.3.2-1) unstable; urgency=low * New upstream release. -- Sebastian Harl Sun, 02 Aug 2009 22:44:30 +0200 liboping (1.3.1-1) unstable; urgency=low * New upstream release. * Added liboping0.symbols: - Use 0.3.2 as MINVER for all symbols - all symbols exist since 0.1.0 but 0.3.2 is the first version that introduced a SONAME version. - Use 'Build-Depends-Package: liboping-dev' to let a user specify the minimal version required for optional features. * debian/rules: - Do not ignore 'make clean' errors. - Use config.{guess,sub} provided by autotools-dev to fix a FTBFS on avr32, thanks to Bradley Smith for reporting this (Closes: #529460). - Use dh_install's --fail-missing instead of --list-missing. - Pass CFLAGS as arguments to configure instead of setting them in the environment - this is the recommended way. - Remove manpages to force a rebuild to avoid errors from man. * debian/control: - Use ${binary:Version} instead of ${Source-Version}. - Updated Standards-Version to 3.8.2. - Added Homepage and Vcs-{Git,Browser} fields. - Removed duplicate field "Section" for package "liboping0". - Added versioned build dependency on dpkg-dev (>= 1.14.13) to support the Homepage and Vcs-* fields and Build-Depends-Package. - Let the -dev package depend on a strict version of the lib package - the -dev package includes a symlink to the full soname, not only the major version. - Let the binary packages oping and libnet-oping-perl depend on liboping0 (>= ${source:Upstream-Version}) explicitly since we do not want to build depend on liboping-dev to get the right version through 'Build-Depends- Package'. - Build depend on perl, required for pod2man. * debian/compat: - Updated to compat version 5. * Added new binary package "libnet-oping-perl": - Since Net::Oping uses its own version number, $srcver-$perlver-$debrev is used for the package version. - Added libnet-oping-perl.install. - Build-depend on perl-modules - debian/rules now requires the ExtUtils:MM module. * debian/liboping0.shlibs: - Updated version to >= 1.3.0. * Added debian/README.Debian: - Added a note explaining the use of the 'Build-Depends-Package' field. -- Sebastian Harl Tue, 21 Jul 2009 13:29:31 +0200 liboping (0.3.5-1) unstable; urgency=low * New upstream release (Closes: #418277). - Added support for C++. * Added watch file. -- Sebastian Harl Tue, 10 Apr 2007 11:52:48 +0000 liboping (0.3.4-1) unstable; urgency=low * New upstream release. -- Sebastian Harl Fri, 1 Dec 2006 11:46:01 +0000 liboping (0.3.3-4) unstable; urgency=low * Renamed liboping0-dev to liboping-dev. -- Sebastian Harl Sun, 23 Jul 2006 20:12:33 +0000 liboping (0.3.3-3) unstable; urgency=low * Added shlibs file. -- Sebastian Harl Sat, 22 Jul 2006 22:38:07 +0200 liboping (0.3.3-2) unstable; urgency=low * Fixed switched long package descriptions (Closes: #378473). -- Sebastian Harl Sun, 16 Jul 2006 16:05:31 +0000 liboping (0.3.3-1) unstable; urgency=low * New upstream release. -- Sebastian Harl Sun, 16 Jul 2006 14:31:02 +0200 liboping (0.3.2-1) unstable; urgency=low * Initial release (Closes: #377527). -- Sebastian Harl Mon, 10 Jul 2006 00:29:07 +0200 debian/compat0000664000000000000000000000000212265236144010373 0ustar 9 debian/control0000664000000000000000000000463512265236144010610 0ustar Source: liboping Section: libs Priority: optional Maintainer: Sebastian Harl Uploaders: Barak A. Pearlmutter Build-Depends: debhelper (>= 9), dh-autoreconf, chrpath, perl, perl-modules, libncursesw5-dev Standards-Version: 3.9.5 Homepage: http://verplant.org/liboping/ Vcs-Git: git://git.tokkee.org/pkg-liboping.git Vcs-Browser: http://git.tokkee.org/?p=pkg-liboping.git Package: liboping-dev Section: libdevel Architecture: any Multi-Arch: same Pre-Depends: ${misc:Pre-Depends} Depends: liboping0 (= ${binary:Version}), ${misc:Depends} Conflicts: liboping0-dev Replaces: liboping0-dev Description: C/C++ library to generate ICMP ECHO_REQUESTs (development files) liboping features pinging multiple hosts in parallel using IPv4 or IPv6 transparently. The interface is object oriented. . This package contains the header files, the static library and the manpages. Package: liboping0 Architecture: any Multi-Arch: same Pre-Depends: ${misc:Pre-Depends} Depends: ${shlibs:Depends}, ${misc:Depends} Description: C/C++ library to generate ICMP ECHO_REQUESTs liboping features pinging multiple hosts in parallel using IPv4 or IPv6 transparently. The interface is object oriented. . This package contains the shared library. Package: oping Section: net Architecture: any Pre-Depends: ${misc:Pre-Depends} Depends: ${shlibs:Depends}, liboping0 (>= ${source:Upstream-Version}), ${misc:Depends} Description: sends ICMP_ECHO requests to network hosts oping uses ICMP packages (better known as "ping packets") to test the reachability of network hosts. It supports pinging multiple hosts in parallel using IPv4 and/or IPv6 transparently. . This package contains two command line applications: "oping" is a replacement for tools like ping(1), ping6(1) and fping(1). "noping" is an ncurses-based tool which displays statistics while pinging and highlights aberrant round-trip times. Package: libnet-oping-perl Section: perl Architecture: any Pre-Depends: ${misc:Pre-Depends} Depends: ${perl:Depends}, ${shlibs:Depends}, liboping0 (>= ${source:Upstream-Version}), ${misc:Depends} Description: module for ICMP latency measurement Net::Oping is a Perl module for sending ICMP ECHO_REQUESTs (better known as "ping packets") and measuring the time that elapses until the reception of an ICMP ECHO_REPLY packet (also known as "pong"). It supports pinging multiple hosts in parallel using IPv4 or IPv6 transparently. debian/copyright0000664000000000000000000000712512265236144011135 0ustar This package was debianized by Sebastian Harl on Mon, 10 Jul 2006 00:29:07 +0200. It was downloaded from . Upstream Author: Florian Forster For individual credits, see AUTHORS. Copyright Holders: Florian Forster Olivier Fredj License: Files bindings/perl/lib/Net/Oping.pm bindings/perl/Oping.xs Copyright © 2007 Olivier Fredj Copyright © 2008-2009 Florian Forster File src/oping.c Copyright © 2006-2011 Florian Forster This package is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; only version 2 of the license is applicable. This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this package; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. On Debian systems, the complete text of the GNU General Public License v2 can be found in `/usr/share/common-licenses/GPL-2'. All other files: Copyright © 2006-2011 Florian Forster This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA On Debian systems, the complete text of the GNU Lesser General Public License v2.1 can be found in `/usr/share/common-licenses/LGPL-2.1'. The Debian packaging is © 2006-2011, Sebastian Harl and is licensed under the 2-clause BSD license: All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. debian/libnet-oping-perl.install0000664000000000000000000000020012265236144014104 0ustar usr/lib/perl5/Net/Oping.pm usr/lib/perl5/auto/Net/Oping/Oping.bs usr/lib/perl5/auto/Net/Oping/Oping.so usr/share/man/man3/*.3pm debian/liboping-dev.docs0000664000000000000000000000001712265236144012424 0ustar AUTHORS README debian/liboping-dev.install0000664000000000000000000000011612265236144013142 0ustar usr/include usr/lib/*/liboping.a usr/lib/*/liboping.so usr/share/man/man3/*.3 debian/liboping-dev.manpages0000664000000000000000000000033212265236144013267 0ustar src/mans/liboping.3 src/mans/ping_construct.3 src/mans/ping_get_error.3 src/mans/ping_host_add.3 src/mans/ping_iterator_get.3 src/mans/ping_iterator_get_context.3 src/mans/ping_iterator_get_info.3 src/mans/ping_send.3 debian/liboping0.install0000664000000000000000000000003012265236144012441 0ustar usr/lib/*/liboping.so.* debian/liboping0.shlibs0000664000000000000000000000004012265236144012260 0ustar liboping 0 liboping0 (>= 1.3.0) debian/liboping0.symbols0000664000000000000000000000064712265236144012501 0ustar liboping.so.0 liboping0 #MINVER# * Build-Depends-Package: liboping-dev ping_construct@Base 0.3.2 ping_destroy@Base 0.3.2 ping_get_error@Base 0.3.2 ping_host_add@Base 0.3.2 ping_host_remove@Base 0.3.2 ping_iterator_get@Base 0.3.2 ping_iterator_get_context@Base 0.3.2 ping_iterator_get_info@Base 0.3.2 ping_iterator_next@Base 0.3.2 ping_iterator_set_context@Base 0.3.2 ping_send@Base 0.3.2 ping_setopt@Base 0.3.2 debian/oping.docs0000664000000000000000000000001712265236144011161 0ustar AUTHORS README debian/oping.install0000664000000000000000000000006012265236144011675 0ustar usr/bin/noping usr/bin/oping usr/share/man/man8 debian/oping.links0000664000000000000000000000006712265236144011356 0ustar usr/share/man/man8/oping.8 usr/share/man/man8/noping.8 debian/oping.lintian-overrides0000664000000000000000000000014512265236144013671 0ustar oping: setuid-binary usr/bin/oping 4755 root/root oping: setuid-binary usr/bin/noping 4755 root/root debian/oping.manpages0000664000000000000000000000002112265236144012017 0ustar src/mans/oping.8 debian/patches/0000775000000000000000000000000012265237571010631 5ustar debian/patches/0001-z-option.patch0000664000000000000000000001160712265236144014007 0ustar From: "Barak A. Pearlmutter" Date: Tue, 6 Sep 2011 00:00:00 +0000 Subject: z-option Allow non-zero exit status if some ping fails. (Patch has been forwarded upstream.) See https://github.com/octo/liboping/commit/9631429 Authors: Barak A. Pearlmutter Florian Forster diff a/src/mans/oping.pod b/src/mans/oping.pod --- src/mans/oping.pod | 12 ++++++++++++ src/oping.c | 50 +++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 57 insertions(+), 5 deletions(-) diff --git a/src/mans/oping.pod b/src/mans/oping.pod index 56712fd..8b8c644 100644 --- a/src/mans/oping.pod +++ b/src/mans/oping.pod @@ -166,6 +166,18 @@ I (ECN), even if the deprecated I (ToS) aliases were used to specify the bits of outgoing packets. +=item B<-Z> I + +If any hosts have a drop rate higher than I, where I is a +number between zero and 100 inclusively, exit with a non-zero exit status. +Since it is not possible to have a higher drop rate than 100%, passing this +limit will effectively disable the feature (the default). Setting the option to +zero means that the exit status will only be zero if I replies for I +hosts have been received. + +The exit status will indicate the number of hosts with more than I +packets lost, up to a number of 255 failing hosts. + =back =head1 COLORS diff --git a/src/oping.c b/src/oping.c index 79d7569..762a3ea 100644 --- a/src/oping.c +++ b/src/oping.c @@ -121,6 +121,7 @@ static char *opt_filename = NULL; static int opt_count = -1; static int opt_send_ttl = 64; static uint8_t opt_send_qos = 0; +static double opt_exit_status_threshold = 1.0; static int host_num = 0; @@ -265,6 +266,8 @@ static void usage_exit (const char *name, int status) /* {{{ */ " -I srcaddr source address\n" " -D device outgoing interface name\n" " -f filename filename to read hosts from\n" + " -Z percent Exit with non-zero exit status if more than this percentage of\n" + " probes timed out. (default: never)\n" "\noping "PACKAGE_VERSION", http://verplant.org/liboping/\n" "by Florian octo Forster \n" @@ -467,7 +470,7 @@ static int read_options (int argc, char **argv) /* {{{ */ while (1) { - optchar = getopt (argc, argv, "46c:hi:I:t:Q:f:D:"); + optchar = getopt (argc, argv, "46c:hi:I:t:Q:f:D:Z:"); if (optchar == -1) break; @@ -538,6 +541,24 @@ static int read_options (int argc, char **argv) /* {{{ */ set_opt_send_qos (optarg); break; + case 'Z': + { + char *endptr = NULL; + double tmp; + + errno = 0; + tmp = strtod (optarg, &endptr); + if ((errno != 0) || (endptr == NULL) || (*endptr != 0) || (tmp < 0.0) || (tmp > 100.0)) + { + fprintf (stderr, "Ignoring invalid -Z argument: %s\n", optarg); + fprintf (stderr, "The \"-Z\" option requires a numeric argument between 0 and 100.\n"); + } + else + opt_exit_status_threshold = tmp / 100.0; + + break; + } + case 'h': usage_exit (argv[0], 0); break; @@ -623,7 +644,7 @@ static int update_stats_from_context (ping_context_t *ctx) /* {{{ */ average = context_get_average (ctx); deviation = context_get_stddev (ctx); - + mvwprintw (ctx->window, /* y = */ 2, /* x = */ 2, "rtt min/avg/max/sdev = %.3f/%.3f/%.3f/%.3f ms", ctx->latency_min, @@ -951,9 +972,13 @@ static void update_host_hook (pingobj_iter_t *iter, /* {{{ */ #endif } /* }}} void update_host_hook */ +/* Prints statistics for each host, cleans up the contexts and returns the + * number of hosts which failed to return more than the fraction + * opt_exit_status_threshold of pings. */ static int post_loop_hook (pingobj_t *ping) /* {{{ */ { pingobj_iter_t *iter; + int failure_count = 0; #if USE_NCURSES endwin (); @@ -973,6 +998,13 @@ static int post_loop_hook (pingobj_t *ping) /* {{{ */ context_get_packet_loss (context), context->latency_total); + { + double pct_failed = 1.0 - (((double) context->req_rcvd) + / ((double) context->req_sent)); + if (pct_failed > opt_exit_status_threshold) + failure_count++; + } + if (context->req_rcvd != 0) { double average; @@ -992,7 +1024,7 @@ static int post_loop_hook (pingobj_t *ping) /* {{{ */ context_destroy (context); } - return (0); + return (failure_count); } /* }}} int post_loop_hook */ int main (int argc, char **argv) /* {{{ */ @@ -1281,11 +1313,19 @@ int main (int argc, char **argv) /* {{{ */ opt_count--; } /* while (opt_count != 0) */ - post_loop_hook (ping); + /* Returns the number of failed hosts according to -Z. */ + status = post_loop_hook (ping); ping_destroy (ping); - return (0); + if (status == 0) + exit (EXIT_SUCCESS); + else + { + if (status > 255) + status = 255; + exit (status); + } } /* }}} int main */ /* vim: set fdm=marker : */ debian/patches/0002-prettyping.patch0000664000000000000000000002542212265236144014436 0ustar From: =?utf-8?q?Antoine_Beaupr=C3=A9?= Date: Fri, 6 Dec 2013 00:00:00 +0000 Subject: prettyping MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Code so noping can use unicode and ncurses to draw graphs and look very pretty. See: http://bugs.debian.org/731207 See: http://anarcat.koumbit.org/2013-12-03-announcing-prettier-noping See: git://src.anarc.at/liboping (branch prettyping) Written by Antoine Beaupré and Florian Forster . This patch is liboping-1.6.2..prettyping, aka 148ff55b..65e6e0f3 ported to apply cleanly to the z-option patch. --- configure.ac | 6 +- src/Makefile.am | 2 +- src/mans/oping.pod | 5 ++ src/oping.c | 186 +++++++++++++++++++++++++++++++++++++++++++++++++---- 4 files changed, 184 insertions(+), 15 deletions(-) diff --git a/configure.ac b/configure.ac index de0a8b0..6eb4b4b 100644 --- a/configure.ac +++ b/configure.ac @@ -48,7 +48,7 @@ LT_INIT([dlopen]) # Checks for header files. AC_HEADER_STDC AC_HEADER_TIME -AC_CHECK_HEADERS([math.h signal.h fcntl.h inttypes.h netdb.h stdint.h stdlib.h string.h sys/socket.h sys/time.h unistd.h]) +AC_CHECK_HEADERS([math.h signal.h fcntl.h inttypes.h netdb.h stdint.h stdlib.h string.h sys/socket.h sys/time.h unistd.h locale.h langinfo.h]) # This sucks, but what can I do..? AC_CHECK_HEADERS(netinet/in_systm.h, [], [], @@ -186,10 +186,10 @@ AC_CHECK_FUNCS(nanosleep, [], AM_CONDITIONAL(BUILD_WITH_LIBRT, test "x$nanosleep_needs_rt" = "xyes") with_ncurses="yes" -AC_CHECK_HEADERS(ncurses.h, [with_ncurses="yes"], [with_ncurses="no"]) +AC_CHECK_HEADERS(ncursesw/ncurses.h, [with_ncurses="yes"], [with_ncurses="no"]) if test "x$with_ncurses" = "xyes" then - AC_CHECK_LIB(ncurses, mvwprintw, [with_ncurses="yes"], [with_ncurses="no"]) + AC_CHECK_LIB(ncursesw, mvwprintw, [with_ncurses="yes"], [with_ncurses="no"]) fi AM_CONDITIONAL(BUILD_WITH_LIBNCURSES, test "x$with_ncurses" = "xyes") diff --git a/src/Makefile.am b/src/Makefile.am index 1326783..c266883 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -46,7 +46,7 @@ bin_PROGRAMS += noping noping_SOURCES = oping.c noping_CPPFLAGS = $(AM_CPPFLAGS) -DUSE_NCURSES=1 -noping_LDADD = liboping.la -lm -lncurses +noping_LDADD = liboping.la -lm -lncursesw if BUILD_WITH_LIBRT noping_LDADD += -lrt endif diff --git a/src/mans/oping.pod b/src/mans/oping.pod index 8b8c644..3bdfc5b 100644 --- a/src/mans/oping.pod +++ b/src/mans/oping.pod @@ -178,6 +178,11 @@ hosts have been received. The exit status will indicate the number of hosts with more than I packets lost, up to a number of 255 failing hosts. +=item B<-u>|B<-U> + +I B<-u> forces UTF-8 output, B<-U> disables UTF-8 output. If +neither is given, the codeset is automatically determined from the locale. + =back =head1 COLORS diff --git a/src/oping.c b/src/oping.c index 762a3ea..0354d11 100644 --- a/src/oping.c +++ b/src/oping.c @@ -74,13 +74,47 @@ #include #endif +#include +#include + #if USE_NCURSES # define NCURSES_OPAQUE 1 -# include +/* http://newsgroups.derkeiler.com/Archive/Rec/rec.games.roguelike.development/2010-09/msg00050.html */ +# define _X_OPEN_SOURCE_EXTENDED +# include # define OPING_GREEN 1 # define OPING_YELLOW 2 # define OPING_RED 3 +# define OPING_GREEN_HIST 4 +# define OPING_YELLOW_HIST 5 +# define OPING_RED_HIST 6 + +static char const * const hist_symbols_utf8[] = { + "▁", "▂", "▃", "▄", "▅", "▆", "▇", "█" }; +static size_t const hist_symbols_utf8_num = sizeof (hist_symbols_utf8) + / sizeof (hist_symbols_utf8[0]); + +/* scancodes for 6 levels of horizontal bars, ncurses-specific */ +/* those are not the usual constants because those are not constant */ +static int const hist_symbols_acs[] = { + 115, /* ACS_S9 "⎽" */ + 114, /* ACS_S7 "⎼" */ + 113, /* ACS_S5 "─" */ + 112, /* ACS_S3 "⎻" */ + 111 /* ACS_S1 "⎺" */ +}; +static size_t const hist_symbols_acs_num = sizeof (hist_symbols_acs) + / sizeof (hist_symbols_acs[0]); + +/* use different colors without a background for scancodes */ +static int const hist_colors_utf8[] = { + OPING_GREEN_HIST, OPING_YELLOW_HIST, OPING_RED_HIST }; +static int const hist_colors_acs[] = { + OPING_GREEN, OPING_YELLOW, OPING_RED }; +/* assuming that both arrays are the same size */ +static size_t const hist_colors_num = sizeof (hist_colors_utf8) + / sizeof (hist_colors_utf8[0]); #endif #include "oping.h" @@ -122,6 +156,9 @@ static int opt_count = -1; static int opt_send_ttl = 64; static uint8_t opt_send_qos = 0; static double opt_exit_status_threshold = 1.0; +#if USE_NCURSES +static int opt_utf8 = 0; +#endif static int host_num = 0; @@ -268,6 +305,9 @@ static void usage_exit (const char *name, int status) /* {{{ */ " -f filename filename to read hosts from\n" " -Z percent Exit with non-zero exit status if more than this percentage of\n" " probes timed out. (default: never)\n" +#if USE_NCURSES + " -u / -U force / disable UTF-8 output\n" +#endif "\noping "PACKAGE_VERSION", http://verplant.org/liboping/\n" "by Florian octo Forster \n" @@ -470,7 +510,11 @@ static int read_options (int argc, char **argv) /* {{{ */ while (1) { - optchar = getopt (argc, argv, "46c:hi:I:t:Q:f:D:Z:"); + optchar = getopt (argc, argv, "46c:hi:I:t:Q:f:D:Z:" +#if USE_NCURSES + "uU" +#endif + ); if (optchar == -1) break; @@ -559,6 +603,15 @@ static int read_options (int argc, char **argv) /* {{{ */ break; } +#if USE_NCURSES + case 'u': + opt_utf8 = 2; + break; + case 'U': + opt_utf8 = 1; + break; +#endif + case 'h': usage_exit (argv[0], 0); break; @@ -618,12 +671,116 @@ static void time_calc (struct timespec *ts_dest, /* {{{ */ } /* }}} void time_calc */ #if USE_NCURSES -static int update_stats_from_context (ping_context_t *ctx) /* {{{ */ +static _Bool has_utf8() /* {{{ */ +{ + if (!opt_utf8) + { + /* Automatically determine */ + if (strcasecmp ("UTF-8", nl_langinfo (CODESET)) == 0) + opt_utf8 = 2; + else + opt_utf8 = 1; + } + return ((_Bool) (opt_utf8 - 1)); +} /* }}} _Bool has_utf8 */ + +static int update_prettyping_graph (ping_context_t *ctx, /* {{{ */ + double latency, unsigned int sequence) { + int color = OPING_RED; + char const *symbol = "!"; + int symbolc = '!'; + size_t hist_symbols_num; + size_t index_symbols; + + int x_max; + int x_pos; + + x_max = getmaxx (ctx->window); + x_pos = ((sequence - 1) % (x_max - 4)) + 2; + + if (has_utf8()) + { + hist_symbols_num = hist_symbols_utf8_num; + } + else { + hist_symbols_num = hist_symbols_acs_num; + } + + if (latency >= 0.0) + { + double ratio; + size_t intensity; + size_t index_colors; + + ratio = latency / PING_DEF_TTL; + if (ratio > 1) { + ratio = 1.0; + } + + intensity = (size_t) ((ratio * hist_symbols_num + * hist_colors_num) - 1); + + index_colors = intensity / hist_symbols_num; + assert (index_colors < hist_colors_num); + + index_symbols = intensity % hist_symbols_num; + if (has_utf8()) + { + color = hist_colors_utf8[index_colors]; + symbol = hist_symbols_utf8[index_symbols]; + } + else + { + color = hist_colors_acs[index_colors]; + symbolc = hist_symbols_acs[index_symbols] | A_ALTCHARSET; + } + } + else /* if (!(latency >= 0.0)) */ + wattron (ctx->window, A_BOLD); + + wattron (ctx->window, COLOR_PAIR(color)); + if (has_utf8()) + { + mvwprintw (ctx->window, + /* y = */ 3, + /* x = */ x_pos, + symbol); + } + else { + mvwaddch (ctx->window, + /* y = */ 3, + /* x = */ x_pos, + symbolc); + } + wattroff (ctx->window, COLOR_PAIR(color)); + + /* Use negation here to handle NaN correctly. */ + if (!(latency >= 0.0)) + wattroff (ctx->window, A_BOLD); + + wprintw (ctx->window, " "); + return (0); +} /* }}} int update_prettyping_graph */ + +static int update_stats_from_context (ping_context_t *ctx, pingobj_iter_t *iter) /* {{{ */ +{ + double latency = -1.0; + size_t buffer_len = sizeof (latency); + + ping_iterator_get_info (iter, PING_INFO_LATENCY, + &latency, &buffer_len); + + unsigned int sequence = 0; + buffer_len = sizeof (sequence); + ping_iterator_get_info (iter, PING_INFO_SEQUENCE, + &sequence, &buffer_len); + + if ((ctx == NULL) || (ctx->window == NULL)) return (EINVAL); - werase (ctx->window); + /* werase (ctx->window); */ box (ctx->window, 0, 0); wattron (ctx->window, A_BOLD); @@ -653,6 +810,9 @@ static int update_stats_from_context (ping_context_t *ctx) /* {{{ */ deviation); } + if (has_colors () == TRUE) + update_prettyping_graph (ctx, latency, sequence); + wrefresh (ctx->window); return (0); @@ -669,7 +829,7 @@ static int on_resize (pingobj_t *ping) /* {{{ */ if ((height < 1) || (width < 1)) return (EINVAL); - main_win_height = height - (4 * host_num); + main_win_height = height - (5 * host_num); wresize (main_win, main_win_height, /* width = */ width); /* Allow scrolling */ scrollok (main_win, TRUE); @@ -693,9 +853,9 @@ static int on_resize (pingobj_t *ping) /* {{{ */ delwin (context->window); context->window = NULL; } - context->window = newwin (/* height = */ 4, + context->window = newwin (/* height = */ 5, /* width = */ width, - /* y = */ main_win_height + (4 * context->index), + /* y = */ main_win_height + (5 * context->index), /* x = */ 0); } @@ -743,9 +903,12 @@ static int pre_loop_hook (pingobj_t *ping) /* {{{ */ init_pair (OPING_GREEN, COLOR_GREEN, /* default = */ 0); init_pair (OPING_YELLOW, COLOR_YELLOW, /* default = */ 0); init_pair (OPING_RED, COLOR_RED, /* default = */ 0); + init_pair (OPING_GREEN_HIST, COLOR_GREEN, COLOR_BLACK); + init_pair (OPING_YELLOW_HIST, COLOR_YELLOW, COLOR_GREEN); + init_pair (OPING_RED_HIST, COLOR_RED, COLOR_YELLOW); } - main_win_height = height - (4 * host_num); + main_win_height = height - (5 * host_num); main_win = newwin (/* height = */ main_win_height, /* width = */ width, /* y = */ 0, /* x = */ 0); @@ -772,9 +935,9 @@ static int pre_loop_hook (pingobj_t *ping) /* {{{ */ delwin (context->window); context->window = NULL; } - context->window = newwin (/* height = */ 4, + context->window = newwin (/* height = */ 5, /* width = */ width, - /* y = */ main_win_height + (4 * context->index), + /* y = */ main_win_height + (5 * context->index), /* x = */ 0); } @@ -967,7 +1130,7 @@ static void update_host_hook (pingobj_iter_t *iter, /* {{{ */ } #if USE_NCURSES - update_stats_from_context (context); + update_stats_from_context (context, iter); wrefresh (main_win); #endif } /* }}} void update_host_hook */ @@ -1058,6 +1221,7 @@ int main (int argc, char **argv) /* {{{ */ } #endif + setlocale(LC_ALL, ""); optind = read_options (argc, argv); #if !_POSIX_SAVED_IDS debian/patches/series0000664000000000000000000000007112265237571012044 0ustar 0001-z-option.patch 0002-prettyping.patch debian-changes debian/patches/debian-changes0000644000000000000000000001177712265237571013417 0ustar Description: TODO: Put a short summary on the line above and replace this paragraph with a longer explanation of this change. Complete the meta-information with other relevant fields (see below for details). To make it easier, the information below has been extracted from the changelog. Adjust it or drop it. . liboping (1.6.2-4) unstable; urgency=low . * always rebuild man pages (closes: 733341) Author: Barak A. Pearlmutter Bug-Debian: http://bugs.debian.org/733341 --- The information above should follow the Patch Tagging Guidelines, please checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here are templates for supplementary fields that you might want to add: Origin: , Bug: Bug-Debian: http://bugs.debian.org/ Bug-Ubuntu: https://launchpad.net/bugs/ Forwarded: Reviewed-By: Last-Update: --- /dev/null +++ liboping-1.6.2/contrib/liboping.spec @@ -0,0 +1,120 @@ +# +# SPEC file for liboping +# +# This SPEC file is provided as a starting point for your own package of +# liboping. It may use distribution specific commands or tags and may not be +# suited for your distribution in its verbatim form. If at all possible, please +# use a source-RPM (SRPM) provided by your distributor. +# +# That being said, bug reports concerning this SPEC file are welcome, of +# course. Please report any bugs you find to liboping's mailing list at +# . Thanks to Benjamin Petrin for providing this +# file. --octo +# +Name: liboping +Version: 1.3.4 +Release: 1%{?dist} +Summary: Ping library intended for use in network monitoring applications + +Group: System Environment/Libraries +License: GPLv2 +URL: http://verplant.org/liboping/ +Source0: http://verplant.org/liboping/files/liboping-%{version}.tar.gz +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) + +#TODO - find all build requirements using a clean system +#BuildRequires: + +%description +The %{name} package is a C library to generate ICMP echo requests, better known +as “ping packets”. It is intended for use in network monitoring applications or +applications that would otherwise need to fork ping(1) frequently. It is like +ping, ping6, and fping rolled into one. + +%package devel +Summary: Development files for %{name} +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} + +%description devel +The %{name}-devel package contains libraries and header files for +developing applications that use %{name}. + +%package perl +Summary: Perl bindings for %{name} +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} +Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version)) + +%description perl +The %{name}-perl package contains a perl module for perl programs +that use %{name}. + + +%prep +%setup -q + + +%build +#Install perl bindings to vendor_perl instead of site_perl +%configure --disable-static --with-perl-bindings='INSTALLDIRS=vendor OPTIMIZE="%{optflags}"' +#The application uses a local copy of libtool, we need to remove rpath with the +#following two lines (see https://fedoraproject.org/wiki/Packaging/Guidelines#Beware_of_Rpath) +sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool +sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool +make %{?_smp_mflags} + + +%install +rm -rf %{buildroot} +make install DESTDIR=%{buildroot} +chmod -R u+w %{buildroot}/* +find %{buildroot} -name '*.la' -exec rm -f {} ';' +find %{buildroot} -type f -name .packlist -exec rm -f {} ';' +find %{buildroot} -type f -name '*.bs' -a -size 0 -exec rm -f {} ';' +find %{buildroot} -depth -type d -exec rmdir {} 2>/dev/null ';' +find %{buildroot} -type f -name perllocal.pod -exec rm -f {} ';' + +%clean +rm -rf %{buildroot} + + +%post -p /sbin/ldconfig + +%postun -p /sbin/ldconfig + + +%files +%defattr(-,root,root,-) +%doc AUTHORS COPYING NEWS README ChangeLog +%{_libdir}/*.so.* +%{_bindir}/oping +%{_mandir}/man8/oping.8* + + +%files devel +%defattr(-,root,root,-) +%{_includedir}/* +%{_libdir}/*.so +%{_mandir}/man3/liboping.3* +%{_mandir}/man3/ping_construct.3* +%{_mandir}/man3/ping_get_error.3* +%{_mandir}/man3/ping_host_add.3* +%{_mandir}/man3/ping_iterator_get.3* +%{_mandir}/man3/ping_iterator_get_context.3* +%{_mandir}/man3/ping_iterator_get_info.3* +%{_mandir}/man3/ping_send.3* +%{_mandir}/man3/ping_setopt.3* + +%files perl +%defattr(-,root,root,-) +%doc bindings/perl/README bindings/perl/Changes +# For arch-specific packages: vendorarch +%{perl_vendorarch}/* +%exclude %dir %{perl_vendorarch}/auto/ +%{_mandir}/man3/Net::Oping.3pm* + + +%changelog +* Fri Jan 22 2010 Benjamin Petrin - 1.3.4-1 +- Initial package debian/rules0000775000000000000000000000172212265237455010265 0ustar #!/usr/bin/make -f # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 LIBPERL_VERSION := $(shell \ pm_ver=$$(perl -MExtUtils::MM -e 'print MM->parse_version("bindings/perl/lib/Net/Oping.pm");'); \ pkg_ver=$$(dpkg-parsechangelog | egrep '^Version:' | cut -d' ' -f2); \ echo -n "$${pkg_ver%-*}-$${pm_ver}-$${pkg_ver\#\#*-}") %: dh $@ --with autoreconf --parallel override_dh_autoreconf: -mkdir -p m4 dh_autoreconf override_dh_auto_configure: dh_auto_configure -- --with-perl-bindings="INSTALLDIRS=vendor" override_dh_auto_build: -rm --verbose src/mans/*.[1-8] # always rebuild man pages dh_auto_build -chrpath --list bindings/perl/blib/arch/auto/Net/Oping/Oping.so chrpath --delete bindings/perl/blib/arch/auto/Net/Oping/Oping.so override_dh_fixperms: dh_fixperms chmod u+s debian/oping/usr/bin/oping debian/oping/usr/bin/noping override_dh_gencontrol: dh_gencontrol -Nlibnet-oping-perl dh_gencontrol -plibnet-oping-perl -- -v$(LIBPERL_VERSION) debian/source/0000775000000000000000000000000012265236144010475 5ustar debian/source/format0000664000000000000000000000001412265236144011703 0ustar 3.0 (quilt) debian/watch0000664000000000000000000000010512265236144010222 0ustar version=3 http://verplant.org/liboping/files/ liboping-(.*)\.tar\.gz