summaryrefslogtreecommitdiffstats
path: root/plugins/netutils.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/netutils.c')
-rw-r--r--plugins/netutils.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/plugins/netutils.c b/plugins/netutils.c
index 0044046..83f8942 100644
--- a/plugins/netutils.c
+++ b/plugins/netutils.c
@@ -167,11 +167,12 @@ np_net_connect (const char *host_name, int port, int *sd, int proto)
167 char port_str[6], host[MAX_HOST_ADDRESS_LENGTH]; 167 char port_str[6], host[MAX_HOST_ADDRESS_LENGTH];
168 size_t len; 168 size_t len;
169 int socktype, result; 169 int socktype, result;
170 short is_socket = (host_name[0] == '/');
170 171
171 socktype = (proto == IPPROTO_UDP) ? SOCK_DGRAM : SOCK_STREAM; 172 socktype = (proto == IPPROTO_UDP) ? SOCK_DGRAM : SOCK_STREAM;
172 173
173 /* as long as it doesn't start with a '/', it's assumed a host or ip */ 174 /* as long as it doesn't start with a '/', it's assumed a host or ip */
174 if(host_name[0] != '/'){ 175 if (!is_socket){
175 memset (&hints, 0, sizeof (hints)); 176 memset (&hints, 0, sizeof (hints));
176 hints.ai_family = address_family; 177 hints.ai_family = address_family;
177 hints.ai_protocol = proto; 178 hints.ai_protocol = proto;
@@ -253,7 +254,11 @@ np_net_connect (const char *host_name, int port, int *sd, int proto)
253 return econn_refuse_state; 254 return econn_refuse_state;
254 break; 255 break;
255 case STATE_CRITICAL: /* user did not set econn_refuse_state */ 256 case STATE_CRITICAL: /* user did not set econn_refuse_state */
256 printf ("%s\n", strerror(errno)); 257 if (is_socket)
258 printf("connect to file socket %s: %s\n", host_name, strerror(errno));
259 else
260 printf("connect to address %s and port %d: %s\n",
261 host_name, port, strerror(errno));
257 return econn_refuse_state; 262 return econn_refuse_state;
258 break; 263 break;
259 default: /* it's a logic error if we do not end up in STATE_(OK|WARNING|CRITICAL) */ 264 default: /* it's a logic error if we do not end up in STATE_(OK|WARNING|CRITICAL) */
@@ -262,7 +267,11 @@ np_net_connect (const char *host_name, int port, int *sd, int proto)
262 } 267 }
263 } 268 }
264 else { 269 else {
265 printf ("%s\n", strerror(errno)); 270 if (is_socket)
271 printf("connect to file socket %s: %s\n", host_name, strerror(errno));
272 else
273 printf("connect to address %s and port %d: %s\n",
274 host_name, port, strerror(errno));
266 return STATE_CRITICAL; 275 return STATE_CRITICAL;
267 } 276 }
268} 277}