diff options
Diffstat (limited to 'plugins/netutils.c')
-rw-r--r-- | plugins/netutils.c | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/plugins/netutils.c b/plugins/netutils.c index 1bb4f076..c6af248e 100644 --- a/plugins/netutils.c +++ b/plugins/netutils.c | |||
@@ -34,7 +34,7 @@ unsigned int socket_timeout = DEFAULT_SOCKET_TIMEOUT; | |||
34 | unsigned int socket_timeout_state = STATE_CRITICAL; | 34 | unsigned int socket_timeout_state = STATE_CRITICAL; |
35 | 35 | ||
36 | int econn_refuse_state = STATE_CRITICAL; | 36 | int econn_refuse_state = STATE_CRITICAL; |
37 | int was_refused = FALSE; | 37 | bool was_refused = false; |
38 | #if USE_IPV6 | 38 | #if USE_IPV6 |
39 | int address_family = AF_UNSPEC; | 39 | int address_family = AF_UNSPEC; |
40 | #else | 40 | #else |
@@ -215,14 +215,14 @@ np_net_connect (const char *host_name, int port, int *sd, int proto) | |||
215 | result = connect (*sd, r->ai_addr, r->ai_addrlen); | 215 | result = connect (*sd, r->ai_addr, r->ai_addrlen); |
216 | 216 | ||
217 | if (result == 0) { | 217 | if (result == 0) { |
218 | was_refused = FALSE; | 218 | was_refused = false; |
219 | break; | 219 | break; |
220 | } | 220 | } |
221 | 221 | ||
222 | if (result < 0) { | 222 | if (result < 0) { |
223 | switch (errno) { | 223 | switch (errno) { |
224 | case ECONNREFUSED: | 224 | case ECONNREFUSED: |
225 | was_refused = TRUE; | 225 | was_refused = true; |
226 | break; | 226 | break; |
227 | } | 227 | } |
228 | } | 228 | } |
@@ -246,7 +246,7 @@ np_net_connect (const char *host_name, int port, int *sd, int proto) | |||
246 | } | 246 | } |
247 | result = connect(*sd, (struct sockaddr *)&su, sizeof(su)); | 247 | result = connect(*sd, (struct sockaddr *)&su, sizeof(su)); |
248 | if (result < 0 && errno == ECONNREFUSED) | 248 | if (result < 0 && errno == ECONNREFUSED) |
249 | was_refused = TRUE; | 249 | was_refused = true; |
250 | } | 250 | } |
251 | 251 | ||
252 | if (result == 0) | 252 | if (result == 0) |
@@ -326,13 +326,11 @@ send_request (int sd, int proto, const char *send_buffer, char *recv_buffer, int | |||
326 | } | 326 | } |
327 | 327 | ||
328 | 328 | ||
329 | int | 329 | bool is_host (const char *address) { |
330 | is_host (const char *address) | ||
331 | { | ||
332 | if (is_addr (address) || is_hostname (address)) | 330 | if (is_addr (address) || is_hostname (address)) |
333 | return (TRUE); | 331 | return (true); |
334 | 332 | ||
335 | return (FALSE); | 333 | return (false); |
336 | } | 334 | } |
337 | 335 | ||
338 | void | 336 | void |
@@ -342,20 +340,18 @@ host_or_die(const char *str) | |||
342 | usage_va(_("Invalid hostname/address - %s"), str); | 340 | usage_va(_("Invalid hostname/address - %s"), str); |
343 | } | 341 | } |
344 | 342 | ||
345 | int | 343 | bool is_addr (const char *address) { |
346 | is_addr (const char *address) | ||
347 | { | ||
348 | #ifdef USE_IPV6 | 344 | #ifdef USE_IPV6 |
349 | if (address_family == AF_INET && is_inet_addr (address)) | 345 | if (address_family == AF_INET && is_inet_addr (address)) |
350 | return TRUE; | 346 | return true; |
351 | else if (address_family == AF_INET6 && is_inet6_addr (address)) | 347 | else if (address_family == AF_INET6 && is_inet6_addr (address)) |
352 | return TRUE; | 348 | return true; |
353 | #else | 349 | #else |
354 | if (is_inet_addr (address)) | 350 | if (is_inet_addr (address)) |
355 | return (TRUE); | 351 | return (true); |
356 | #endif | 352 | #endif |
357 | 353 | ||
358 | return (FALSE); | 354 | return (false); |
359 | } | 355 | } |
360 | 356 | ||
361 | int | 357 | int |
@@ -370,10 +366,10 @@ dns_lookup (const char *in, struct sockaddr_storage *ss, int family) | |||
370 | 366 | ||
371 | retval = getaddrinfo (in, NULL, &hints, &res); | 367 | retval = getaddrinfo (in, NULL, &hints, &res); |
372 | if (retval != 0) | 368 | if (retval != 0) |
373 | return FALSE; | 369 | return false; |
374 | 370 | ||
375 | if (ss != NULL) | 371 | if (ss != NULL) |
376 | memcpy (ss, res->ai_addr, res->ai_addrlen); | 372 | memcpy (ss, res->ai_addr, res->ai_addrlen); |
377 | freeaddrinfo (res); | 373 | freeaddrinfo (res); |
378 | return TRUE; | 374 | return true; |
379 | } | 375 | } |