summaryrefslogtreecommitdiffstats
path: root/plugins/netutils.c
diff options
context:
space:
mode:
authorRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2023-10-18 18:46:16 (GMT)
committerRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2023-10-18 18:46:16 (GMT)
commita51e8f82e7c5a51893d43c7d00495ceba6a661ab (patch)
tree4042a9240d695207bd1865dc177d4eb086f0c384 /plugins/netutils.c
parentc2ceefd783043235ac24aa4f529bb42c95df905c (diff)
downloadmonitoring-plugins-a51e8f82e7c5a51893d43c7d00495ceba6a661ab.tar.gz
plugins/netutils: Use C99 booleans
Diffstat (limited to 'plugins/netutils.c')
-rw-r--r--plugins/netutils.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/plugins/netutils.c b/plugins/netutils.c
index 1bb4f07..c6af248 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}