mirror of
https://github.com/monitoring-plugins/monitoring-plugins.git
synced 2026-05-28 04:35:40 -04:00
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>
This commit is contained in:
parent
8edac9421f
commit
e3ade3374a
1 changed files with 22 additions and 10 deletions
|
|
@ -460,6 +460,28 @@ main(int argc, char **argv)
|
|||
packets = 5;
|
||||
}
|
||||
|
||||
/* Parse protocol arguments first */
|
||||
for(i = 1; i < argc; i++) {
|
||||
while((arg = getopt(argc, argv, "vhVw:c:n:p:t:H:s:i:b:I:l:m:64")) != EOF) {
|
||||
unsigned short size;
|
||||
switch(arg) {
|
||||
case '4':
|
||||
address_family = AF_INET;
|
||||
break;
|
||||
case '6':
|
||||
#ifdef USE_IPV6
|
||||
address_family = AF_INET6;
|
||||
#else
|
||||
usage (_("IPv6 support not available\n"));
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Reset argument scanning */
|
||||
optind = 1;
|
||||
|
||||
/* parse the arguments */
|
||||
for(i = 1; i < argc; i++) {
|
||||
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)
|
|||
print_help ();
|
||||
exit (STATE_UNKNOWN);
|
||||
break;
|
||||
case '4':
|
||||
address_family = AF_INET;
|
||||
break;
|
||||
case '6':
|
||||
#ifdef USE_IPV6
|
||||
address_family = AF_INET6;
|
||||
#else
|
||||
usage (_("IPv6 support not available\n"));
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue