summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorgnn <gnn@FreeBSD.org>2014-02-03 03:34:36 +0000
committergnn <gnn@FreeBSD.org>2014-02-03 03:34:36 +0000
commita2ab687e34bdc01ce26ec4e9739a05838e32c73e (patch)
tree27a5977eaebf2a72fb7fce7b45285984ba480190 /tools
parentdbf0fc2c5107f37c30259d02f0e37e061c589e7e (diff)
downloadFreeBSD-src-a2ab687e34bdc01ce26ec4e9739a05838e32c73e.zip
FreeBSD-src-a2ab687e34bdc01ce26ec4e9739a05838e32c73e.tar.gz
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.
Diffstat (limited to 'tools')
-rw-r--r--tools/tools/mcgrab/mcgrab.cc18
1 files changed, 12 insertions, 6 deletions
diff --git a/tools/tools/mcgrab/mcgrab.cc b/tools/tools/mcgrab/mcgrab.cc
index 5522f30..35687b8 100644
--- a/tools/tools/mcgrab/mcgrab.cc
+++ b/tools/tools/mcgrab/mcgrab.cc
@@ -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_addr *group, int number) {
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);
}
OpenPOWER on IntegriCloud