[monitoring-plugins] check_icmp: emit error if multiple protocol ...

Jacob Hansen <[email protected]> Tue, 19 Feb 2019 15:50:17 +0100 (CET)
Newsgroups gmane.network.nagios.cvs
Message-ID <[email protected]>
 Module: monitoring-plugins
 Branch: master
 Commit: ca6efcd02b203e9e07b869af050c1b9849e04608
 Author: Jacob Hansen <[email protected]>
   Date: Mon Dec 10 13:49:13 2018 +0000
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=ca6efcd

check_icmp: emit error if multiple protocol version

As we do not support checking both IPv4 and IPv6 hosts in one execution
we emit an error if multiple protocol versions are defined in the cmd
line args.

Signed-off-by: Jacob Hansen <[email protected]>

---

 plugins-root/check_icmp.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 6a883a8..98891f0 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -467,10 +467,14 @@ main(int argc, char **argv)
 			unsigned short size;
 			switch(arg) {
 			case '4':
+				if (address_family != -1)
+					crash("Multiple protocol versions not supported");
 				address_family = AF_INET;
 				break;
 			case '6':
 #ifdef USE_IPV6
+				if (address_family != -1)
+					crash("Multiple protocol versions not supported");
 				address_family = AF_INET6;
 #else
 				usage (_("IPv6 support not available\n"));