summaryrefslogtreecommitdiffstats
path: root/web/attachments/56819-ping.diff
blob: 8a849a16bf20c56725dae3189cb786588fadeeef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
*** 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 <host_address> -w <wrta>,<wpl>%% -c <crta>,<cpl>%%\n\
!        [-p packets] [-t timeout] [-L]\n"
  
  #define LONGOPTIONS "\
  -H, --hostname=HOST\n\
--- 19,26 ----
  
  #define OPTIONS "\
  -H <host_address> -w <wrta>,<wpl>%% -c <crta>,<cpl>%%\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 <rta>,<pl>%% where <rta> 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);