summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins-root/check_icmp.c5
-rw-r--r--plugins-root/t/check_icmp.t8
2 files changed, 11 insertions, 2 deletions
diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 01ae174..f97b0ed 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -410,6 +410,7 @@ main(int argc, char **argv)
410#ifdef SO_TIMESTAMP 410#ifdef SO_TIMESTAMP
411 int on = 1; 411 int on = 1;
412#endif 412#endif
413 char *source_ip = NULL;
413 char * opts_str = "vhVw:c:n:p:t:H:s:i:b:I:l:m:64"; 414 char * opts_str = "vhVw:c:n:p:t:H:s:i:b:I:l:m:64";
414 415
415 setlocale (LC_ALL, ""); 416 setlocale (LC_ALL, "");
@@ -542,7 +543,7 @@ main(int argc, char **argv)
542 } 543 }
543 break; 544 break;
544 case 's': /* specify source IP address */ 545 case 's': /* specify source IP address */
545 set_source_ip(optarg); 546 source_ip = optarg;
546 break; 547 break;
547 case 'V': /* version */ 548 case 'V': /* version */
548 print_revision (progname, NP_VERSION); 549 print_revision (progname, NP_VERSION);
@@ -597,6 +598,8 @@ main(int argc, char **argv)
597 sockets |= HAVE_ICMP; 598 sockets |= HAVE_ICMP;
598 else icmp_sockerrno = errno; 599 else icmp_sockerrno = errno;
599 600
601 if( source_ip )
602 set_source_ip(source_ip);
600 603
601#ifdef SO_TIMESTAMP 604#ifdef SO_TIMESTAMP
602 if(setsockopt(icmp_sock, SOL_SOCKET, SO_TIMESTAMP, &on, sizeof(on))) 605 if(setsockopt(icmp_sock, SOL_SOCKET, SO_TIMESTAMP, &on, sizeof(on)))
diff --git a/plugins-root/t/check_icmp.t b/plugins-root/t/check_icmp.t
index e043d4e..55edc31 100644
--- a/plugins-root/t/check_icmp.t
+++ b/plugins-root/t/check_icmp.t
@@ -12,7 +12,7 @@ my $allow_sudo = getTestParameter( "NP_ALLOW_SUDO",
12 "no" ); 12 "no" );
13 13
14if ($allow_sudo eq "yes" or $> == 0) { 14if ($allow_sudo eq "yes" or $> == 0) {
15 plan tests => 16; 15 plan tests => 18;
16} else { 16} else {
17 plan skip_all => "Need sudo to test check_icmp"; 17 plan skip_all => "Need sudo to test check_icmp";
18} 18}
@@ -83,3 +83,9 @@ $res = NPTest->testCmd(
83is( $res->return_code, 2, "One of two host nonresponsive - two required" ); 83is( $res->return_code, 2, "One of two host nonresponsive - two required" );
84like( $res->output, $failureOutput, "Output OK" ); 84like( $res->output, $failureOutput, "Output OK" );
85 85
86$res = NPTest->testCmd(
87 "$sudo ./check_icmp -H $host_responsive -s 127.0.15.15 -w 10000ms,100% -c 10000ms,100% -n 1 -m 2"
88 );
89is( $res->return_code, 0, "IPv4 source_ip accepted" );
90like( $res->output, $successOutput, "Output OK" );
91