Hello community, here is the log from the commit of package mcjoin for openSUSE:Factory checked in at 2019-04-30 13:06:08 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/mcjoin (Old) and /work/SRC/openSUSE:Factory/.mcjoin.new.5536 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "mcjoin" Tue Apr 30 13:06:08 2019 rev:2 rq:699387 version:2.3 Changes: -------- --- /work/SRC/openSUSE:Factory/mcjoin/mcjoin.changes 2018-06-29 22:32:13.970217443 +0200 +++ /work/SRC/openSUSE:Factory/.mcjoin.new.5536/mcjoin.changes 2019-04-30 13:06:10.497822285 +0200 @@ -1,0 +2,10 @@ +Thu Apr 4 19:41:39 UTC 2019 - Martin Hauke <mardnh@gmx.de> + +- Update to version 2.3 + * Automatically detect default interface + * Enable support for multiple mcjoin receivers on one host using + the same destination (Internet) port + * Fix #1: Receiver does not stop after count received packets + * Avoid using GLIBC extension `__progname` + +------------------------------------------------------------------- Old: ---- mcjoin-2.2.tar.gz New: ---- mcjoin-2.3.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ mcjoin.spec ++++++ --- /var/tmp/diff_new_pack.0ujGrs/_old 2019-04-30 13:06:11.725802541 +0200 +++ /var/tmp/diff_new_pack.0ujGrs/_new 2019-04-30 13:06:11.725802541 +0200 @@ -1,6 +1,7 @@ # # spec file for package mcjoin # +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # Copyright (c) 2018, Martin Hauke <mardnh@gmx.de> # # All modifications and additions to the file contributed by third parties @@ -12,12 +13,12 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # Name: mcjoin -Version: 2.2 +Version: 2.3 Release: 0 Summary: IPv4 tool for verifying multicast connectivity License: ISC ++++++ mcjoin-2.2.tar.gz -> mcjoin-2.3.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mcjoin-2.2/.gitignore new/mcjoin-2.3/.gitignore --- old/mcjoin-2.2/.gitignore 2016-09-08 00:06:51.000000000 +0200 +++ new/mcjoin-2.3/.gitignore 2018-09-20 20:55:39.000000000 +0200 @@ -1,4 +1,5 @@ *~ +*.o /.deps/* /autom4te.cache/* /Makefile @@ -13,9 +14,10 @@ /depcomp /install-sh /mcjoin -/mcjoin-mcjoin.o /missing /stamp-h1 +/debian/.debhelper/* +/debian/debhelper-build-stamp /debian/mcjoin/* /debian/mcjoin.debhelper.log /debian/mcjoin.substvars diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mcjoin-2.2/ChangeLog.md new/mcjoin-2.3/ChangeLog.md --- old/mcjoin-2.2/ChangeLog.md 2016-09-08 00:06:51.000000000 +0200 +++ new/mcjoin-2.3/ChangeLog.md 2018-09-20 20:55:39.000000000 +0200 @@ -4,6 +4,17 @@ All notable changes to the project are documented in this file. +[v2.3][] - 2018-09-20 +--------------------- + +- Automatically detect default interface +- Enable support for multiple mcjoin receivers on one host using the + same destination (Internet) port +- Fix #1: Receiver does not stop after count received packets +- Avoid using GLIBC extension `__progname` +- Updated build instructions in README + + [v2.2][] - 2016-09-08 --------------------- @@ -58,7 +69,8 @@ and developed further by Joachim Nilsson, on his spare time. -[UNRELEASED]: https://github.com/troglobit/mcjoin/compare/v2.2...HEAD +[UNRELEASED]: https://github.com/troglobit/mcjoin/compare/v2.3...HEAD +[v2.3]: https://github.com/troglobit/mcjoin/compare/v2.2...v2.3 [v2.2]: https://github.com/troglobit/mcjoin/compare/v2.1...v2.2 [v2.1]: https://github.com/troglobit/mcjoin/compare/v2.0...v2.1 [v2.0]: https://github.com/troglobit/mcjoin/compare/v1.5...v2.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mcjoin-2.2/LICENSE new/mcjoin-2.3/LICENSE --- old/mcjoin-2.2/LICENSE 2016-09-08 00:06:51.000000000 +0200 +++ new/mcjoin-2.3/LICENSE 2018-09-20 20:55:39.000000000 +0200 @@ -1,7 +1,7 @@ Join a multicast group and/or generate UDP test data Copyright (C) 2004 David Stevens <dlstevens()us!ibm!com> -Copyright (C) 2008-2016 Joachim Nilsson <troglobit()gmail!com> +Copyright (C) 2008-2018 Joachim Nilsson <troglobit()gmail!com> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mcjoin-2.2/Makefile.am new/mcjoin-2.3/Makefile.am --- old/mcjoin-2.2/Makefile.am 2016-09-08 00:06:51.000000000 +0200 +++ new/mcjoin-2.3/Makefile.am 2018-09-20 20:55:39.000000000 +0200 @@ -1,27 +1,49 @@ bin_PROGRAMS = mcjoin dist_man1_MANS = mcjoin.1 -mcjoin_SOURCES = mcjoin.c +mcjoin_SOURCES = mcjoin.c addr.c mcjoin_CFLAGS = -W -Wall -Wextra -std=gnu99 doc_DATA = README.md LICENSE EXTRA_DIST = README.md LICENSE ChangeLog.md +# lintian --profile debian -i -I --show-overrides ../$PKG.changes package: - gbp buildpackage --git-ignore-new --git-ignore-branch \ - --git-no-create-orig --git-upstream-branch=master + dpkg-buildpackage -uc -us -B -## Target to run when building a release -release: dist package +## Generate MD5 checksum file +MD5 = md5sum +md5-dist: @for file in $(DIST_ARCHIVES); do \ - md5sum $$file > ../$$file.md5; \ + $(MD5) $$file > ../$$file.md5; \ done + +## Check if tagged in git +release-hook: + if [ ! `git tag | grep $(PACKAGE_VERSION)` ]; then \ + echo; \ + printf "\e[1m\e[41mCannot find release tag $(PACKAGE_VERSION)\e[0m\n"; \ + printf "\e[1m\e[5mDo release anyway?\e[0m "; read yorn; \ + if [ "$$yorn" != "y" -a "$$yorn" != "Y" ]; then \ + printf "OK, aborting release.\n"; \ + exit 1; \ + fi; \ + echo; \ + else \ + echo; \ + printf "\e[1m\e[42mFound GIT release tag $(PACKAGE_VERSION)\e[0m\n"; \ + printf "\e[1m\e[44m>>Remember to push tags!\e[0m\n"; \ + echo; \ + fi + +## Target to run when building a release +release: release-hook distcheck package md5-dist @mv $(DIST_ARCHIVES) ../ @echo @echo "Resulting release files:" @echo "=================================================================" @for file in $(DIST_ARCHIVES); do \ - printf "$$file \tDistribution tarball\n"; \ - printf "$$file.md5\t"; cat ../$$file.md5 | cut -f1 -d' '; \ + printf "%-32s Distribution tarball\n" $$file; \ + printf "%-32s " $$file.md5; cat ../$$file.md5 | cut -f1 -d' '; \ done - @for file in `ls ../$(PACKAGE)_$(VERSION)-*`; do \ - printf "$$file \tDebian/Ubuntu file\n"; \ + @for file in `cd ..; ls $(PACKAGE)_$(VERSION)*`; do \ + printf "%-32s Debian/Ubuntu package\n" $$file; \ done diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mcjoin-2.2/README.md new/mcjoin-2.3/README.md --- old/mcjoin-2.2/README.md 2016-09-08 00:06:51.000000000 +0200 +++ new/mcjoin-2.3/README.md 2018-09-20 20:55:39.000000000 +0200 @@ -115,6 +115,45 @@ bet most developer's don't know about this. +build & install +--------------- + +the GNU Configure & Build system use `/usr/local` as the default install +prefix. for most use-cases this is fine, but if you want to change this +to `/usr` use the `--prefix=/usr` configure option: + + $ ./configure --prefix=/usr + $ make -j5 + $ sudo make install-strip + + +building from git +----------------- + +if you want to contribute, or simply just try out the latest but +unreleased features, then you need to know a few things about the +[GNU build system][buildsystem]: + +- `configure.ac` and a per-directory `Makefile.am` are key files +- `configure` and `Makefile.in` are generated from `autogen.sh`, + they are not stored in GIT but automatically generated for the + release tarballs +- `Makefile` is generated by `configure` script + +to build from GIT you first need to clone the repository and run the +`autogen.sh` script. this requires `automake` and `autoconf` to be +installed on your system. + + git clone https://github.com/troglobit/mcjoin.git + cd mcjoin/ + ./autogen.sh + ./configure && make + sudo make install-strip + +**NOTE:** GIT sources are a moving target and are not recommended for + production systems, unless you know what you are doing! + + [Travis]: https://travis-ci.org/troglobit/mcjoin [Travis Status]: https://travis-ci.org/troglobit/mcjoin.png?branch=master [Coverity Scan]: https://scan.coverity.com/projects/9108 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mcjoin-2.2/addr.c new/mcjoin-2.3/addr.c --- old/mcjoin-2.2/addr.c 1970-01-01 01:00:00.000000000 +0100 +++ new/mcjoin-2.3/addr.c 2018-09-20 20:55:39.000000000 +0200 @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2018 Joachim Nilsson <troglobit@gmail.com> + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#include <ifaddrs.h> +#include <netdb.h> +#include <stdio.h> +#include <stdint.h> +#include <string.h> +#include <net/if.h> +#include <arpa/inet.h> +#include <netinet/in.h> +#include <sys/socket.h> +#include <sys/types.h> + +#ifndef IN_ZERONET +#define IN_ZERONET(addr) ((addr & IN_CLASSA_NET) == 0) +#endif + +#ifndef IN_LOOPBACK +#define IN_LOOPBACK(addr) ((addr & IN_CLASSA_NET) == 0x7f000000) +#endif + +#ifndef IN_LINKLOCAL +#define IN_LINKLOCALNETNUM 0xa9fe0000 +#define IN_LINKLOCAL(addr) ((addr & IN_CLASSB_NET) == IN_LINKLOCALNETNUM) +#endif + +/* Find default outbound *LAN* interface, i.e. skipping tunnels */ +char *getifname(char *ifname, size_t len) +{ + uint32_t dest, gw, mask; + char buf[256], name[17]; + FILE *fp; + int rc, flags, cnt, use, metric, mtu, win, irtt; + int found = 0; + + fp = fopen("/proc/net/route", "r"); + if (!fp) + return NULL; + + while (fgets(buf, sizeof(buf), fp) != NULL) { + rc = sscanf(buf, "%16s %X %X %X %d %d %d %X %d %d %d\n", + name, &dest, &gw, &flags, &cnt, &use, &metric, + &mask, &mtu, &win, &irtt); + + if (rc < 10 || !(flags & 1)) /* IFF_UP */ + continue; + + if (dest != 0 || mask != 0) + continue; + + if (!ifname[0] || !strncmp(ifname, "tun", 3)) { + strncpy(ifname, name, len); + found = 1; + break; + } + } + fclose(fp); + + if (found) + return ifname; + + return NULL; +} + +/* Check if valid address */ +static int valid_addr(struct in_addr *ina) +{ + in_addr_t addr; + + addr = ntohl(ina->s_addr); + if (IN_ZERONET(addr) || IN_LOOPBACK(addr) || IN_LINKLOCAL(addr)) + return 0; + + return 1; +} + +/* Find IPv4 address of default outbound LAN interface */ +int getaddr(char *iface, struct in_addr *ina) +{ + struct ifaddrs *ifaddr, *ifa; + char ifname[17] = { 0 }; + char buf[20] = { 0 }; + int rc = -1; + + if (!iface) + iface = getifname(ifname, sizeof(ifname)); + + rc = getifaddrs(&ifaddr); + if (rc) + return -1; + + for (ifa = ifaddr; ifa; ifa = ifa->ifa_next) { + if (!ifa->ifa_addr) + continue; + + if (ifa->ifa_flags & IFF_LOOPBACK) + continue; + + if (!(ifa->ifa_flags & IFF_MULTICAST)) + continue; + + if (ifa->ifa_addr->sa_family != AF_INET) + continue; + + if (iface && strcmp(iface, ifa->ifa_name)) + continue; + + rc = getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in), + buf, sizeof(buf), NULL, 0, NI_NUMERICHOST); + if (!rc) { + if (!inet_aton(buf, ina)) + continue; + if (!valid_addr(ina)) + continue; + break; + } + } + freeifaddrs(ifaddr); + + if (rc || IN_ZERONET(ntohl(ina->s_addr))) + return -1; + + return 0; +} + +/** + * Local Variables: + * indent-tabs-mode: t + * c-file-style: "linux" + * End: + */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mcjoin-2.2/configure.ac new/mcjoin-2.3/configure.ac --- old/mcjoin-2.2/configure.ac 2016-09-08 00:06:51.000000000 +0200 +++ new/mcjoin-2.3/configure.ac 2018-09-20 20:55:39.000000000 +0200 @@ -1,4 +1,4 @@ -AC_INIT(mcjoin, 2.2, https://github.com/troglobit/mcjoin/issues,, https://github.com/troglobit/mcjoin/) +AC_INIT(mcjoin, 2.3, https://github.com/troglobit/mcjoin/issues,, https://github.com/troglobit/mcjoin/) AM_INIT_AUTOMAKE([1.11 foreign no-dist-gzip dist-xz]) AC_CONFIG_SRCDIR([mcjoin.c]) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mcjoin-2.2/debian/changelog new/mcjoin-2.3/debian/changelog --- old/mcjoin-2.2/debian/changelog 2016-09-08 00:06:51.000000000 +0200 +++ new/mcjoin-2.3/debian/changelog 2018-09-20 20:55:39.000000000 +0200 @@ -1,3 +1,18 @@ +mcjoin (2.3) unstable; urgency=medium + + * New upstream release. Automatically detect default interface, fix bug + in `-c count` handling for receiver, as well as portability fixes and + fixes to run multiple mcjoin receivers on the same host:post. + + -- Joachim Nilsson <troglobit@gmail.com> Thu, 20 Sep 2018 20:48:20 +0200 + +mcjoin (2.2-1) xenial; urgency=medium + + * New upstream release. Bug fixes, increased sender rate (1/100 msec), + portability fixes, and a neat progress bar for the receiver. + + -- Joachim Nilsson <troglobit@gmail.com> Tue, 08 Sep 2016 00:15:00 +0100 + mcjoin (2.1-1) wily; urgency=medium * New upstream release, adding support for packet validation: check diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mcjoin-2.2/debian/control new/mcjoin-2.3/debian/control --- old/mcjoin-2.2/debian/control 2016-09-08 00:06:51.000000000 +0200 +++ new/mcjoin-2.3/debian/control 2018-09-20 20:55:39.000000000 +0200 @@ -3,7 +3,7 @@ Priority: optional Maintainer: Joachim Nilsson <troglobit@gmail.com> Homepage: https://github.com/troglobit/mcjoin -Build-Depends: debhelper (>= 9~), autoconf +Build-Depends: debhelper (>= 10) Vcs-Git: https://github.com/troglobit/mcjoin.git Vcs-Browser: https://github.com/troglobit/mcjoin/commits/ Standards-Version: 3.9.6 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mcjoin-2.2/debian/copyright new/mcjoin-2.3/debian/copyright --- old/mcjoin-2.2/debian/copyright 2016-09-08 00:06:51.000000000 +0200 +++ new/mcjoin-2.3/debian/copyright 2018-09-20 20:55:39.000000000 +0200 @@ -1,5 +1,5 @@ Copyright (C) 2004 David Stevens <dlstevens()us!ibm!com> -Copyright (C) 2008-2016 Joachim Nilsson <troglobit()gmail!com> +Copyright (C) 2008-2018 Joachim Nilsson <troglobit()gmail!com> License: ISC Permission to use, copy, modify, and/or distribute this software for any diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mcjoin-2.2/debian/rules new/mcjoin-2.3/debian/rules --- old/mcjoin-2.2/debian/rules 2016-09-08 00:06:51.000000000 +0200 +++ new/mcjoin-2.3/debian/rules 2018-09-20 20:55:39.000000000 +0200 @@ -1,8 +1,13 @@ #!/usr/bin/make -f +# export DH_VERBOSE=1 +export DEB_BUILD_MAINT_OPTIONS = hardening=+all %: dh $@ +override_dh_installchangelogs: + dh_installchangelogs ChangeLog.md + override_dh_auto_install: dh_auto_install find debian/ -name LICENSE -delete diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mcjoin-2.2/mcjoin.1 new/mcjoin-2.3/mcjoin.1 --- old/mcjoin-2.2/mcjoin.1 2016-09-08 00:06:51.000000000 +0200 +++ new/mcjoin-2.3/mcjoin.1 2018-09-20 20:55:39.000000000 +0200 @@ -33,7 +33,7 @@ Use the following options to adjust this behavior: .Bl -tag -width Ds .It Fl c Ar COUNT -Stop after sending/receiving COUNT number of packets +Stop sending/receiving after COUNT number of packets .It Fl d Debug output .It Fl h @@ -43,7 +43,7 @@ .It Fl j Join groups, default unless acting as sender .It Fl p Ar PORT -UDP port number to listen to, default: 1234 +UDP port number to send/listen to, default: 1234 .It Fl q Quiet mode .It Fl s diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mcjoin-2.2/mcjoin.c new/mcjoin-2.3/mcjoin.c --- old/mcjoin-2.2/mcjoin.c 2016-09-08 00:06:51.000000000 +0200 +++ new/mcjoin-2.3/mcjoin.c 2018-09-20 20:55:39.000000000 +0200 @@ -1,7 +1,7 @@ /* Join a multicast group and/or generate UDP test data * * Copyright (C) 2004 David Stevens <dlstevens()us!ibm!com> - * Copyright (C) 2008-2016 Joachim Nilsson <troglobit()gmail!com> + * Copyright (C) 2008-2018 Joachim Nilsson <troglobit()gmail!com> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -36,7 +36,6 @@ #define BUFSZ 100 #define MAX_NUM_GROUPS 250 -#define DEFAULT_IFNAME "eth0" #define DEFAULT_GROUP "225.1.2.3" #define DEFAULT_PORT 1234 #define MAGIC_KEY "Sender PID " @@ -76,9 +75,6 @@ struct sockaddr_in to; }; -/* Program meta data */ -extern char *__progname; - /* Mode flags */ int join = 1; int quiet = 0; @@ -92,6 +88,7 @@ size_t count = 0; int port = DEFAULT_PORT; unsigned char ttl = 1; +char *ident = PACKAGE_NAME; size_t group_num = 0; struct gr groups[MAX_NUM_GROUPS]; @@ -99,6 +96,9 @@ char iface[IFNAMSIZ + 1]; int num_joins = 0; +char *getifname(char *ifname, size_t len); +int getaddr(char *iface, struct in_addr *ina); + static int alloc_socket(struct in_addr group, int port) { @@ -112,6 +112,10 @@ } val = 1; +#ifdef SO_REUSEPORT + if (setsockopt(sd, SOL_SOCKET, SO_REUSEPORT, &val, sizeof(val))) + ERROR("Failed enabling SO_REUSEPORT: %s", strerror(errno)); +#endif if (setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val))) ERROR("Failed enabling SO_REUSEADDR: %s", strerror(errno)); @@ -171,61 +175,6 @@ return 1; } -static int is_address_valid(struct in_addr addr) -{ - char *address = inet_ntoa(addr); - in_addr_t ia; - - DEBUG("Checking IPv4 address %s ...", address); - - ia = ntohl(addr.s_addr); - if (IN_ZERONET(ia) || IN_LOOPBACK(ia) || IN_LINKLOCAL(ia) || - IN_MULTICAST(ia) || IN_EXPERIMENTAL(ia)) { - DEBUG("IP address %s is not a routable address.", address); - return 0; - } - - DEBUG("IPv4 address %s is valid.", address); - return 1; -} - -static int find_iface(char *ifname, struct in_addr *addr) -{ - struct ifaddrs *ifa, *ifap, *match = NULL; - struct in_addr cand; - - if (getifaddrs(&ifap) != 0) - return -1; - - for (ifa = ifap; ifa; ifa = ifa->ifa_next) { - DEBUG("Checking ifname %s against %s ...", ifname, ifa->ifa_name ?: "NULL"); - if (strcmp(ifa->ifa_name, ifname) != 0) - continue; - - if (ifa->ifa_addr == NULL) - continue; - - if (ifa->ifa_addr->sa_family != AF_INET) - continue; /* Don't understand IPv6 yet ... */ - - cand = ((struct sockaddr_in *)ifa->ifa_addr)->sin_addr; - if (!is_address_valid(cand)) - continue; - - match = ifa; - break; - } - - freeifaddrs(ifap); - - if (match) { - *addr = cand; - return 0; - } - - return 1; -} - static void send_mcast(int signo) { size_t i; @@ -238,7 +187,7 @@ .s_addr = INADDR_ANY, }; - if (find_iface(iface, &addr)) { + if (getaddr(iface, &addr)) { ERROR("Failed locating (a valid address on) %s: %s", iface, strerror(errno)); return; } @@ -437,12 +386,10 @@ if (count > 0) { size_t total = count * group_num; - for (i = 0; i < group_num; i++) { - if (groups[i].count >= count) - total--; - } + for (i = 0; i < group_num; i++) + total -= groups[i].count; - if (!total) { + if (total <= 0) { running = 0; break; } @@ -474,28 +421,40 @@ static int usage(int code) { - printf("\nUsage: %s [dhjqsv] [-c COUNT] [-i IFACE] [-p PORT] [-r SEC] [-t TTL]\n" + printf("Usage: %s [-dhjqsv] [-c COUNT] [-i IFACE] [-p PORT] [-r SEC] [-t TTL]\n" " [GROUP0 .. GROUPN | GROUP+NUM]\n" - "\n" "Options:\n" - " -c COUNT Stop after sending/receiving COUNT number of packets\n" + " -c COUNT Stop sending/receiving after COUNT number of packets\n" " -d Debug output\n" " -h This help text\n" " -i IFACE Interface to use for sending/receiving multicast, default: %s\n" " -j Join groups, default unless acting as sender\n" - " -p PORT UDP port number to listen to, default: %d\n" + " -p PORT UDP port number to send/listen to, default: %d\n" " -q Quiet mode\n" " -r SEC Do a join/leave every SEC seconds (backwards compat. option)\n" " -s Act as sender, sends packets to select groups, default: no\n" " -t TTL TTL to use when sending multicast packets, default: 1\n" " -v Display program version\n" "\n" - "Bug report address: %-40s\n" - "Project homepage: %s\n\n", __progname, DEFAULT_IFNAME, DEFAULT_PORT, PACKAGE_BUGREPORT, PACKAGE_URL); + "Bug report address : %-40s\n" + "Project homepage : %s\n", ident, iface, DEFAULT_PORT, PACKAGE_BUGREPORT, PACKAGE_URL); return code; } +static char *progname(char *arg0) +{ + char *nm; + + nm = strrchr(arg0, '/'); + if (nm) + nm++; + else + nm = arg0; + + return nm; +} + int main(int argc, char *argv[]) { int i, c; @@ -506,14 +465,11 @@ }; extern int optind; - /* Default interface - * XXX - Should be the first, after lo, in the list at /proc/net/dev, or - * XXX - Iterate over /sys/class/net/.../link_mode */ - strncpy(iface, DEFAULT_IFNAME, sizeof(iface)); - + getifname(iface, sizeof(iface)); for (i = 0; i < MAX_NUM_GROUPS; i++) memset(&groups[i], 0, sizeof(groups[0])); + ident = progname(argv[0]); while ((c = getopt(argc, argv, "c:di:jp:qr:st:vh")) != EOF) { switch (c) { case 'c':