*** check_ping.c.orig Mon Jan 13 20:15:16 2003 --- check_ping.c Wed Jul 23 14:38:19 2003 *************** *** 19,25 **** #define OPTIONS "\ -H -w ,%% -c ,%%\n\ ! [-p packets] [-t timeout] [-L]\n" #define LONGOPTIONS "\ -H, --hostname=HOST\n\ --- 19,26 ---- #define OPTIONS "\ -H -w ,%% -c ,%%\n\ ! [-p packets] [-t timeout] [-6] [-L]\n" ! #define LONGOPTIONS "\ -H, --hostname=HOST\n\ *************** *** 32,37 **** --- 33,40 ---- number of ICMP ECHO packets to send (Default: %d)\n\ -t, --timeout=INTEGER\n\ optional specified timeout in second (Default: %d)\n\ + -6, --use-ping6\n\ + use ping6 for ICMPv6 instead of ping for IPv4\n\ -L, --link\n\ show HTML in the plugin output (obsoleted by urlize)\n\ THRESHOLD is ,%% where is the round trip average travel\n\ *************** *** 70,81 **** --- 73,87 ---- char *server_address = NULL; int max_packets = -1; int verbose = FALSE; + int ipv6 = FALSE; float rta = UNKNOWN_TRIP_TIME; int pl = UNKNOWN_PACKET_LOSS; char *warn_text = NULL; + #define PING6_COMMAND "/sbin/ping6 -n -c %d %s" + int main (int argc, char **argv) { *************** *** 86,98 **** usage ("Could not parse arguments"); exit; /* does the host address of number of packets argument come first? */ #ifdef PING_PACKETS_FIRST asprintf (&command_line, PING_COMMAND, max_packets, server_address); #else asprintf (&command_line, PING_COMMAND, server_address, max_packets); #endif ! /* Set signal handling and alarm */ if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR) { printf ("Cannot catch SIGALRM"); --- 92,108 ---- usage ("Could not parse arguments"); exit; + #ifdef PING6_COMMAND + asprintf (&command_line, ipv6 ? PING6_COMMAND : PING_COMMAND, max_packets, server_address); + #else + /* does the host address of number of packets argument come first? */ #ifdef PING_PACKETS_FIRST asprintf (&command_line, PING_COMMAND, max_packets, server_address); #else asprintf (&command_line, PING_COMMAND, server_address, max_packets); #endif ! #endif /* Set signal handling and alarm */ if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR) { printf ("Cannot catch SIGALRM"); *************** *** 157,167 **** {"packets", required_argument, 0, 'p'}, {"nohtml", no_argument, 0, 'n'}, {"link", no_argument, 0, 'L'}, {0, 0, 0, 0} }; #endif ! #define OPTCHARS "Vvht:c:w:H:p:nL" if (argc < 2) return ERROR; --- 167,178 ---- {"packets", required_argument, 0, 'p'}, {"nohtml", no_argument, 0, 'n'}, {"link", no_argument, 0, 'L'}, + {"use-ping6", no_argument, 0, '6'}, {0, 0, 0, 0} }; #endif ! #define OPTCHARS "Vvht:c:w:H:p:n6L" if (argc < 2) return ERROR; *************** *** 213,218 **** --- 224,232 ---- break; case 'L': /* show HTML */ display_html = TRUE; + break; + case '6': + ipv6 = TRUE; break; case 'c': get_threshold (optarg, &crta, &cpl);