From owner-svn-src-all@FreeBSD.ORG Mon Feb 3 03:34:37 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3C9F5515; Mon, 3 Feb 2014 03:34:37 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 0EA3F162B; Mon, 3 Feb 2014 03:34:37 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s133YaVJ003467; Mon, 3 Feb 2014 03:34:36 GMT (envelope-from gnn@svn.freebsd.org) Received: (from gnn@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s133Ya5p003466; Mon, 3 Feb 2014 03:34:36 GMT (envelope-from gnn@svn.freebsd.org) Message-Id: <201402030334.s133Ya5p003466@svn.freebsd.org> From: "George V. Neville-Neil" Date: Mon, 3 Feb 2014 03:34:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r261426 - stable/10/tools/tools/mcgrab X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Feb 2014 03:34:37 -0000 Author: gnn Date: Mon Feb 3 03:34:36 2014 New Revision: 261426 URL: http://svnweb.freebsd.org/changeset/base/261426 Log: MFC: 260791 Add a command line argument to turn off blocking waiting for the user to press Ctrl-C (-b). This allows tests with tight loops of mcgrabs that can stress the multicast tables. Modified: stable/10/tools/tools/mcgrab/mcgrab.cc Directory Properties: stable/10/ (props changed) Modified: stable/10/tools/tools/mcgrab/mcgrab.cc ============================================================================== --- stable/10/tools/tools/mcgrab/mcgrab.cc Mon Feb 3 03:31:35 2014 (r261425) +++ stable/10/tools/tools/mcgrab/mcgrab.cc Mon Feb 3 03:34:36 2014 (r261426) @@ -88,7 +88,7 @@ void usage(string message) // // @return 0 for 0K, -1 for error, sets errno // -void grab(char *interface, struct in_addr *group, int number) { +void grab(char *interface, struct in_addr *group, int number, int block) { int sock; @@ -138,8 +138,10 @@ void grab(char *interface, struct in_add group->s_addr = htonl(ntohl(group->s_addr) + 1); } - printf("Press Control-C to exit.\n"); - sleep(INT_MAX); + if (block > 0) { + printf("Press Control-C to exit.\n"); + sleep(INT_MAX); + } } @@ -160,11 +162,12 @@ int main(int argc, char**argv) char* interface = 0; ///< Name of the interface struct in_addr *group = NULL; ///< the multicast group address int number = 0; ///< Number of addresses to grab + int block = 1; ///< Do we block or just return? - if (argc != 7) + if ((argc < 7) || (argc > 8)) usage(); - while ((ch = getopt(argc, argv, "g:i:n:h")) != -1) { + while ((ch = getopt(argc, argv, "g:i:n:bh")) != -1) { switch (ch) { case 'g': group = new (struct in_addr ); @@ -178,12 +181,15 @@ int main(int argc, char**argv) case 'n': number = atoi(optarg); break; + case 'b': + block = 0; + break; case 'h': usage(string("Help\n")); break; } } - grab(interface, group, number); + grab(interface, group, number, block); }