summaryrefslogtreecommitdiffstats
path: root/plugins-root
diff options
context:
space:
mode:
authorJacob Hansen <jhansen@op5.com>2018-12-03 14:19:27 +0000
committerJacob Hansen <jhansen@op5.com>2018-12-07 09:51:21 +0000
commite3ade3374a99155c8c70d89a8d8116240d5c8df0 (patch)
tree56507af1512bcaa859b7e24f43048c2227198efb /plugins-root
parent8edac9421f8ce28ab51917de4e056ac609eadd49 (diff)
downloadmonitoring-plugins-e3ade3374a99155c8c70d89a8d8116240d5c8df0.tar.gz
check_icmp: process protocol version args first
Detection of protocol version is in the previous patch implemented in the add_target() function, which is called when adding the -H command line argument. That means that if a protocal version argument (-4, -6) is added after the -H then the protocol version might be incorrectly set. This patch ensures that we first process the protocol version arguments, and then we process the rest of the arguments. Signed-off-by: Jacob Hansen <jhansen@op5.com>
Diffstat (limited to 'plugins-root')
-rw-r--r--plugins-root/check_icmp.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index cab69fda..b978ee1e 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -460,6 +460,28 @@ main(int argc, char **argv)
460 packets = 5; 460 packets = 5;
461 } 461 }
462 462
463 /* Parse protocol arguments first */
464 for(i = 1; i < argc; i++) {
465 while((arg = getopt(argc, argv, "vhVw:c:n:p:t:H:s:i:b:I:l:m:64")) != EOF) {
466 unsigned short size;
467 switch(arg) {
468 case '4':
469 address_family = AF_INET;
470 break;
471 case '6':
472#ifdef USE_IPV6
473 address_family = AF_INET6;
474#else
475 usage (_("IPv6 support not available\n"));
476#endif
477 break;
478 }
479 }
480 }
481
482 /* Reset argument scanning */
483 optind = 1;
484
463 /* parse the arguments */ 485 /* parse the arguments */
464 for(i = 1; i < argc; i++) { 486 for(i = 1; i < argc; i++) {
465 while((arg = getopt(argc, argv, "vhVw:c:n:p:t:H:s:i:b:I:l:m:64")) != EOF) { 487 while((arg = getopt(argc, argv, "vhVw:c:n:p:t:H:s:i:b:I:l:m:64")) != EOF) {
@@ -524,16 +546,6 @@ main(int argc, char **argv)
524 print_help (); 546 print_help ();
525 exit (STATE_UNKNOWN); 547 exit (STATE_UNKNOWN);
526 break; 548 break;
527 case '4':
528 address_family = AF_INET;
529 break;
530 case '6':
531#ifdef USE_IPV6
532 address_family = AF_INET6;
533#else
534 usage (_("IPv6 support not available\n"));
535#endif
536 break;
537 } 549 }
538 } 550 }
539 } 551 }