diff options
Diffstat (limited to 'plugins/netutils.c')
| -rw-r--r-- | plugins/netutils.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/plugins/netutils.c b/plugins/netutils.c index 5e00723e..1a5547e9 100644 --- a/plugins/netutils.c +++ b/plugins/netutils.c | |||
| @@ -35,7 +35,7 @@ | |||
| 35 | #include "common.h" | 35 | #include "common.h" |
| 36 | #include "netutils.h" | 36 | #include "netutils.h" |
| 37 | 37 | ||
| 38 | unsigned int socket_timeout = DEFAULT_SOCKET_TIMEOUT; | 38 | unsigned int socket_timeout = DEFAULT_SOCKET_TIMEOUT; |
| 39 | int econn_refuse_state = STATE_CRITICAL; | 39 | int econn_refuse_state = STATE_CRITICAL; |
| 40 | int was_refused = FALSE; | 40 | int was_refused = FALSE; |
| 41 | #if USE_IPV6 | 41 | #if USE_IPV6 |
| @@ -57,8 +57,8 @@ socket_timeout_alarm_handler (int sig) | |||
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | 59 | ||
| 60 | /* connects to a host on a specified tcp port, sends a string, and gets a | 60 | /* connects to a host on a specified tcp port, sends a string, and gets a |
| 61 | response. loops on select-recv until timeout or eof to get all of a | 61 | response. loops on select-recv until timeout or eof to get all of a |
| 62 | multi-packet answer */ | 62 | multi-packet answer */ |
| 63 | int | 63 | int |
| 64 | process_tcp_request2 (const char *server_address, int server_port, | 64 | process_tcp_request2 (const char *server_address, int server_port, |
| @@ -106,7 +106,7 @@ process_tcp_request2 (const char *server_address, int server_port, | |||
| 106 | } | 106 | } |
| 107 | else { /* it has */ | 107 | else { /* it has */ |
| 108 | recv_result = | 108 | recv_result = |
| 109 | recv (sd, recv_buffer + recv_length, | 109 | recv (sd, recv_buffer + recv_length, |
| 110 | (size_t)recv_size - recv_length - 1, 0); | 110 | (size_t)recv_size - recv_length - 1, 0); |
| 111 | if (recv_result == -1) { | 111 | if (recv_result == -1) { |
| 112 | /* recv failed, bail out */ | 112 | /* recv failed, bail out */ |
| @@ -137,7 +137,7 @@ process_tcp_request2 (const char *server_address, int server_port, | |||
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | 139 | ||
| 140 | /* connects to a host on a specified port, sends a string, and gets a | 140 | /* connects to a host on a specified port, sends a string, and gets a |
| 141 | response */ | 141 | response */ |
| 142 | int | 142 | int |
| 143 | process_request (const char *server_address, int server_port, int proto, | 143 | process_request (const char *server_address, int server_port, int proto, |
| @@ -229,7 +229,7 @@ np_net_connect (const char *host_name, int port, int *sd, int proto) | |||
| 229 | r = r->ai_next; | 229 | r = r->ai_next; |
| 230 | } | 230 | } |
| 231 | freeaddrinfo (res); | 231 | freeaddrinfo (res); |
| 232 | } | 232 | } |
| 233 | /* else the hostname is interpreted as a path to a unix socket */ | 233 | /* else the hostname is interpreted as a path to a unix socket */ |
| 234 | else { | 234 | else { |
| 235 | if(strlen(host_name) >= UNIX_PATH_MAX){ | 235 | if(strlen(host_name) >= UNIX_PATH_MAX){ |
| @@ -251,7 +251,7 @@ np_net_connect (const char *host_name, int port, int *sd, int proto) | |||
| 251 | return STATE_OK; | 251 | return STATE_OK; |
| 252 | else if (was_refused) { | 252 | else if (was_refused) { |
| 253 | switch (econn_refuse_state) { /* a user-defined expected outcome */ | 253 | switch (econn_refuse_state) { /* a user-defined expected outcome */ |
| 254 | case STATE_OK: | 254 | case STATE_OK: |
| 255 | case STATE_WARNING: /* user wants WARN or OK on refusal */ | 255 | case STATE_WARNING: /* user wants WARN or OK on refusal */ |
| 256 | return econn_refuse_state; | 256 | return econn_refuse_state; |
| 257 | break; | 257 | break; |
| @@ -285,7 +285,7 @@ send_request (int sd, int proto, const char *send_buffer, char *recv_buffer, int | |||
| 285 | result = STATE_WARNING; | 285 | result = STATE_WARNING; |
| 286 | } | 286 | } |
| 287 | 287 | ||
| 288 | /* wait up to the number of seconds for socket timeout minus one | 288 | /* wait up to the number of seconds for socket timeout minus one |
| 289 | for data from the host */ | 289 | for data from the host */ |
| 290 | tv.tv_sec = socket_timeout - 1; | 290 | tv.tv_sec = socket_timeout - 1; |
| 291 | tv.tv_usec = 0; | 291 | tv.tv_usec = 0; |
| @@ -340,7 +340,7 @@ is_addr (const char *address) | |||
| 340 | #ifdef USE_IPV6 | 340 | #ifdef USE_IPV6 |
| 341 | if (address_family == AF_INET && is_inet_addr (address)) | 341 | if (address_family == AF_INET && is_inet_addr (address)) |
| 342 | return TRUE; | 342 | return TRUE; |
| 343 | else if (address_family == AF_INET6 && is_inet6_addr (address)) | 343 | else if (address_family == AF_INET6 && is_inet6_addr (address)) |
| 344 | return TRUE; | 344 | return TRUE; |
| 345 | #else | 345 | #else |
| 346 | if (is_inet_addr (address)) | 346 | if (is_inet_addr (address)) |
