summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_disk.c15
-rw-r--r--plugins/netutils.c34
-rw-r--r--plugins/netutils.h34
3 files changed, 47 insertions, 36 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index f6966721..bd060218 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -233,9 +233,10 @@ process_arguments (int argc, char **argv)
233 struct name_list **fstail = &fs_exclude_list; 233 struct name_list **fstail = &fs_exclude_list;
234 struct name_list **dptail = &dp_exclude_list; 234 struct name_list **dptail = &dp_exclude_list;
235 struct name_list *temp_list; 235 struct name_list *temp_list;
236 unsigned long l;
237 int result = OK; 236 int result = OK;
238 237
238 unsigned long l;
239
239 int option_index = 0; 240 int option_index = 0;
240 static struct option long_options[] = { 241 static struct option long_options[] = {
241 {"timeout", required_argument, 0, 't'}, 242 {"timeout", required_argument, 0, 't'},
@@ -322,6 +323,8 @@ process_arguments (int argc, char **argv)
322 usage (_("Critical threshold must be integer or percentage!\n")); 323 usage (_("Critical threshold must be integer or percentage!\n"));
323 } 324 }
324 case 'u': 325 case 'u':
326 if (units)
327 free(units);
325 if (! strcmp (optarg, "bytes")) { 328 if (! strcmp (optarg, "bytes")) {
326 mult = (uintmax_t)1; 329 mult = (uintmax_t)1;
327 units = strdup ("B"); 330 units = strdup ("B");
@@ -340,13 +343,19 @@ process_arguments (int argc, char **argv)
340 } else { 343 } else {
341 die (STATE_UNKNOWN, _("unit type %s not known\n"), optarg); 344 die (STATE_UNKNOWN, _("unit type %s not known\n"), optarg);
342 } 345 }
346 if (units == NULL)
347 die (STATE_UNKNOWN, _("failed allocating storage for '%s'\n"), "units");
343 break; 348 break;
344 case 'k': /* display mountpoint */ 349 case 'k': /* display mountpoint */
345 mult = 1024; 350 mult = 1024;
351 if (units)
352 free(units);
346 units = strdup ("kB"); 353 units = strdup ("kB");
347 break; 354 break;
348 case 'm': /* display mountpoint */ 355 case 'm': /* display mountpoint */
349 mult = 1024 * 1024; 356 mult = 1024 * 1024;
357 if (units)
358 free(units);
350 units = strdup ("kB"); 359 units = strdup ("kB");
351 break; 360 break;
352 case 'l': 361 case 'l':
@@ -475,8 +484,10 @@ INPUT ERROR: C_DF (%lu) should be less than W_DF (%lu) and both should be greate
475 return ERROR; 484 return ERROR;
476 } 485 }
477 486
478 if (units == NULL) 487 if (units == NULL) {
479 units = strdup ("MB"); 488 units = strdup ("MB");
489 mult = (uintmax_t)1024 * 1024;
490 }
480 return OK; 491 return OK;
481} 492}
482 493
diff --git a/plugins/netutils.c b/plugins/netutils.c
index 92fd1420..58b3fb48 100644
--- a/plugins/netutils.c
+++ b/plugins/netutils.c
@@ -53,8 +53,8 @@ socket_timeout_alarm_handler (int sig)
53/* connects to a host on a specified TCP port, sends a string, 53/* connects to a host on a specified TCP port, sends a string,
54 and gets a response */ 54 and gets a response */
55int 55int
56process_tcp_request (char *server_address, int server_port, 56process_tcp_request (const char *server_address, int server_port,
57 char *send_buffer, char *recv_buffer, int recv_size) 57 const char *send_buffer, char *recv_buffer, int recv_size)
58{ 58{
59 int result; 59 int result;
60 60
@@ -68,8 +68,8 @@ process_tcp_request (char *server_address, int server_port,
68/* connects to a host on a specified UDP port, sends a string, and gets a 68/* connects to a host on a specified UDP port, sends a string, and gets a
69 response */ 69 response */
70int 70int
71process_udp_request (char *server_address, int server_port, 71process_udp_request (const char *server_address, int server_port,
72 char *send_buffer, char *recv_buffer, int recv_size) 72 const char *send_buffer, char *recv_buffer, int recv_size)
73{ 73{
74 int result; 74 int result;
75 75
@@ -85,8 +85,8 @@ process_udp_request (char *server_address, int server_port,
85 response. loops on select-recv until timeout or eof to get all of a 85 response. loops on select-recv until timeout or eof to get all of a
86 multi-packet answer */ 86 multi-packet answer */
87int 87int
88process_tcp_request2 (char *server_address, int server_port, 88process_tcp_request2 (const char *server_address, int server_port,
89 char *send_buffer, char *recv_buffer, int recv_size) 89 const char *send_buffer, char *recv_buffer, int recv_size)
90{ 90{
91 91
92 int result; 92 int result;
@@ -163,8 +163,8 @@ process_tcp_request2 (char *server_address, int server_port,
163/* connects to a host on a specified port, sends a string, and gets a 163/* connects to a host on a specified port, sends a string, and gets a
164 response */ 164 response */
165int 165int
166process_request (char *server_address, int server_port, int proto, 166process_request (const char *server_address, int server_port, int proto,
167 char *send_buffer, char *recv_buffer, int recv_size) 167 const char *send_buffer, char *recv_buffer, int recv_size)
168{ 168{
169 int result; 169 int result;
170 int send_result; 170 int send_result;
@@ -223,7 +223,7 @@ process_request (char *server_address, int server_port, int proto,
223 223
224/* opens a connection to a remote host/tcp port */ 224/* opens a connection to a remote host/tcp port */
225int 225int
226my_tcp_connect (char *host_name, int port, int *sd) 226my_tcp_connect (const char *host_name, int port, int *sd)
227{ 227{
228 int result; 228 int result;
229 229
@@ -235,7 +235,7 @@ my_tcp_connect (char *host_name, int port, int *sd)
235 235
236/* opens a connection to a remote host/udp port */ 236/* opens a connection to a remote host/udp port */
237int 237int
238my_udp_connect (char *host_name, int port, int *sd) 238my_udp_connect (const char *host_name, int port, int *sd)
239{ 239{
240 int result; 240 int result;
241 241
@@ -247,7 +247,7 @@ my_udp_connect (char *host_name, int port, int *sd)
247 247
248/* opens a tcp or udp connection to a remote host */ 248/* opens a tcp or udp connection to a remote host */
249int 249int
250my_connect (char *host_name, int port, int *sd, int proto) 250my_connect (const char *host_name, int port, int *sd, int proto)
251{ 251{
252 struct addrinfo hints; 252 struct addrinfo hints;
253 struct addrinfo *res; 253 struct addrinfo *res;
@@ -315,7 +315,7 @@ my_connect (char *host_name, int port, int *sd, int proto)
315} 315}
316 316
317int 317int
318is_host (char *address) 318is_host (const char *address)
319{ 319{
320 if (is_addr (address) || is_hostname (address)) 320 if (is_addr (address) || is_hostname (address))
321 return (TRUE); 321 return (TRUE);
@@ -324,7 +324,7 @@ is_host (char *address)
324} 324}
325 325
326int 326int
327is_addr (char *address) 327is_addr (const char *address)
328{ 328{
329#ifdef USE_IPV6 329#ifdef USE_IPV6
330 if (is_inet_addr (address) && address_family != AF_INET6) 330 if (is_inet_addr (address) && address_family != AF_INET6)
@@ -342,7 +342,7 @@ is_addr (char *address)
342} 342}
343 343
344int 344int
345resolve_host_or_addr (char *address, int family) 345resolve_host_or_addr (const char *address, int family)
346{ 346{
347 struct addrinfo hints; 347 struct addrinfo hints;
348 struct addrinfo *res; 348 struct addrinfo *res;
@@ -361,21 +361,21 @@ resolve_host_or_addr (char *address, int family)
361} 361}
362 362
363int 363int
364is_inet_addr (char *address) 364is_inet_addr (const char *address)
365{ 365{
366 return resolve_host_or_addr (address, AF_INET); 366 return resolve_host_or_addr (address, AF_INET);
367} 367}
368 368
369#ifdef USE_IPV6 369#ifdef USE_IPV6
370int 370int
371is_inet6_addr (char *address) 371is_inet6_addr (const char *address)
372{ 372{
373 return resolve_host_or_addr (address, AF_INET6); 373 return resolve_host_or_addr (address, AF_INET6);
374} 374}
375#endif 375#endif
376 376
377int 377int
378is_hostname (char *s1) 378is_hostname (const char *s1)
379{ 379{
380#ifdef USE_IPV6 380#ifdef USE_IPV6
381 return resolve_host_or_addr (s1, address_family); 381 return resolve_host_or_addr (s1, address_family);
diff --git a/plugins/netutils.h b/plugins/netutils.h
index f5df7af6..c560f449 100644
--- a/plugins/netutils.h
+++ b/plugins/netutils.h
@@ -36,27 +36,27 @@
36 36
37RETSIGTYPE socket_timeout_alarm_handler (int) __attribute__((noreturn)); 37RETSIGTYPE socket_timeout_alarm_handler (int) __attribute__((noreturn));
38 38
39int process_tcp_request2 (char *address, int port, char *sbuffer, 39int process_tcp_request2 (const char *address, int port,
40 char *rbuffer, int rsize); 40 const char *sbuffer, char *rbuffer, int rsize);
41int process_tcp_request (char *address, int port, char *sbuffer, 41int process_tcp_request (const char *address, int port,
42 char *rbuffer, int rsize); 42 const char *sbuffer, char *rbuffer, int rsize);
43int process_udp_request (char *address, int port, char *sbuffer, 43int process_udp_request (const char *address, int port,
44 char *rbuffer, int rsize); 44 const char *sbuffer, char *rbuffer, int rsize);
45int process_request (char *address, int port, int proto, char *sbuffer, 45int process_request (const char *address, int port, int proto,
46 char *rbuffer, int rsize); 46 const char *sbuffer, char *rbuffer, int rsize);
47 47
48int my_tcp_connect (char *address, int port, int *sd); 48int my_tcp_connect (const char *address, int port, int *sd);
49int my_udp_connect (char *address, int port, int *sd); 49int my_udp_connect (const char *address, int port, int *sd);
50int my_connect (char *address, int port, int *sd, int proto); 50int my_connect (const char *address, int port, int *sd, int proto);
51 51
52int is_host (char *); 52int is_host (const char *);
53int is_addr (char *); 53int is_addr (const char *);
54int resolve_host_or_addr (char *, int); 54int resolve_host_or_addr (const char *, int);
55int is_inet_addr (char *); 55int is_inet_addr (const char *);
56#ifdef USE_IPV6 56#ifdef USE_IPV6
57int is_inet6_addr (char *); 57int is_inet6_addr (const char *);
58#endif 58#endif
59int is_hostname (char *); 59int is_hostname (const char *);
60 60
61extern unsigned int socket_timeout; 61extern unsigned int socket_timeout;
62extern int econn_refuse_state; 62extern int econn_refuse_state;