From 986b2479465648c49a7eefc3fbf4df8860e3e4b7 Mon Sep 17 00:00:00 2001 From: ghciv6 Date: Mon, 20 Dec 2021 22:39:57 +0000 Subject: - delay set_source_ip() until address_family is detected - add a test to check '-s' --- plugins-root/check_icmp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'plugins-root/check_icmp.c') diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c index 01ae174a..f97b0ed7 100644 --- a/plugins-root/check_icmp.c +++ b/plugins-root/check_icmp.c @@ -410,6 +410,7 @@ main(int argc, char **argv) #ifdef SO_TIMESTAMP int on = 1; #endif + char *source_ip = NULL; char * opts_str = "vhVw:c:n:p:t:H:s:i:b:I:l:m:64"; setlocale (LC_ALL, ""); @@ -542,7 +543,7 @@ main(int argc, char **argv) } break; case 's': /* specify source IP address */ - set_source_ip(optarg); + source_ip = optarg; break; case 'V': /* version */ print_revision (progname, NP_VERSION); @@ -597,6 +598,8 @@ main(int argc, char **argv) sockets |= HAVE_ICMP; else icmp_sockerrno = errno; + if( source_ip ) + set_source_ip(source_ip); #ifdef SO_TIMESTAMP if(setsockopt(icmp_sock, SOL_SOCKET, SO_TIMESTAMP, &on, sizeof(on))) -- cgit v1.2.3