99 |
static void decode_type (const char *optarg); |
static void decode_type (const char *optarg); |
100 |
static int send_echo (PING *ping); |
static int send_echo (PING *ping); |
101 |
|
|
102 |
|
#define MIN_USER_INTERVAL (200000/PING_PRECISION) |
103 |
|
|
104 |
int |
int |
105 |
main (int argc, char **argv) |
main (int argc, char **argv) |
106 |
{ |
{ |
158 |
break; |
break; |
159 |
|
|
160 |
case 'i': |
case 'i': |
161 |
options |= OPT_INTERVAL; |
{ |
162 |
interval = ping_cvt_number (optarg, 0, 0); |
double v; |
163 |
|
|
164 |
|
v = strtod (optarg, &p); |
165 |
|
if (*p) |
166 |
|
{ |
167 |
|
fprintf (stderr, "Invalid value (`%s' near `%s')\n", |
168 |
|
optarg, p); |
169 |
|
exit (1); |
170 |
|
} |
171 |
|
|
172 |
|
options |= OPT_INTERVAL; |
173 |
|
interval = v * PING_PRECISION; |
174 |
|
if (!is_root && interval < MIN_USER_INTERVAL) |
175 |
|
{ |
176 |
|
fprintf (stderr, "Option value too small: %s\n", optarg); |
177 |
|
exit (1); |
178 |
|
} |
179 |
|
} |
180 |
break; |
break; |
181 |
|
|
182 |
case 'p': |
case 'p': |
205 |
break; |
break; |
206 |
|
|
207 |
case 'l': |
case 'l': |
208 |
if (is_root == false) |
if (!is_root) |
209 |
{ |
{ |
210 |
fprintf (stderr, "ping: option not allowed: --preload\n"); |
fprintf (stderr, "ping: option not allowed: --preload\n"); |
211 |
exit (1); |
exit (1); |
351 |
intvl.tv_usec = 10000; |
intvl.tv_usec = 10000; |
352 |
} |
} |
353 |
else |
else |
354 |
{ |
PING_SET_INTERVAL(intvl, ping->ping_interval); |
|
intvl.tv_sec = ping->ping_interval; |
|
|
intvl.tv_usec = 0; |
|
|
} |
|
355 |
|
|
356 |
gettimeofday (&last, NULL); |
gettimeofday (&last, NULL); |
357 |
send_echo (ping); |
send_echo (ping); |