From owner-svn-src-head@FreeBSD.ORG Thu Jan 16 21:46:44 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2106ACC5; Thu, 16 Jan 2014 21:46:44 +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 E64241D0F; Thu, 16 Jan 2014 21:46:43 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0GLkh3R015911; Thu, 16 Jan 2014 21:46:43 GMT (envelope-from gnn@svn.freebsd.org) Received: (from gnn@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0GLkhdB015910; Thu, 16 Jan 2014 21:46:43 GMT (envelope-from gnn@svn.freebsd.org) Message-Id: <201401162146.s0GLkhdB015910@svn.freebsd.org> From: "George V. Neville-Neil" Date: Thu, 16 Jan 2014 21:46:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r260791 - head/tools/tools/mcgrab X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Jan 2014 21:46:44 -0000 Author: gnn Date: Thu Jan 16 21:46:43 2014 New Revision: 260791 URL: http://svnweb.freebsd.org/changeset/base/260791 Log: 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. MFC after: 2 weeks Modified: head/tools/tools/mcgrab/mcgrab.cc Modified: head/tools/tools/mcgrab/mcgrab.cc ============================================================================== --- head/tools/tools/mcgrab/mcgrab.cc Thu Jan 16 20:40:02 2014 (r260790) +++ head/tools/tools/mcgrab/mcgrab.cc Thu Jan 16 21:46:43 2014 (r260791) @@ -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); }