summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/netutils.c32
-rw-r--r--plugins/netutils.h6
2 files changed, 17 insertions, 21 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;
34unsigned int socket_timeout_state = STATE_CRITICAL; 34unsigned int socket_timeout_state = STATE_CRITICAL;
35 35
36int econn_refuse_state = STATE_CRITICAL; 36int econn_refuse_state = STATE_CRITICAL;
37int was_refused = FALSE; 37bool was_refused = false;
38#if USE_IPV6 38#if USE_IPV6
39int address_family = AF_UNSPEC; 39int 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
329int 329bool is_host (const char *address) {
330is_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
338void 336void
@@ -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
345int 343bool is_addr (const char *address) {
346is_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
361int 357int
@@ -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}
diff --git a/plugins/netutils.h b/plugins/netutils.h
index ea653e72..a95057e0 100644
--- a/plugins/netutils.h
+++ b/plugins/netutils.h
@@ -73,8 +73,8 @@ int send_request (int sd, int proto, const char *send_buffer, char *recv_buffer,
73 73
74 74
75/* "is_*" wrapper macros and functions */ 75/* "is_*" wrapper macros and functions */
76int is_host (const char *); 76bool is_host (const char *);
77int is_addr (const char *); 77bool is_addr (const char *);
78int dns_lookup (const char *, struct sockaddr_storage *, int); 78int dns_lookup (const char *, struct sockaddr_storage *, int);
79void host_or_die(const char *str); 79void host_or_die(const char *str);
80#define resolve_host_or_addr(addr, family) dns_lookup(addr, NULL, family) 80#define resolve_host_or_addr(addr, family) dns_lookup(addr, NULL, family)
@@ -89,7 +89,7 @@ void host_or_die(const char *str);
89extern unsigned int socket_timeout; 89extern unsigned int socket_timeout;
90extern unsigned int socket_timeout_state; 90extern unsigned int socket_timeout_state;
91extern int econn_refuse_state; 91extern int econn_refuse_state;
92extern int was_refused; 92extern bool was_refused;
93extern int address_family; 93extern int address_family;
94 94
95void socket_timeout_alarm_handler (int) __attribute__((noreturn)); 95void socket_timeout_alarm_handler (int) __attribute__((noreturn));