diff options
Diffstat (limited to 'plugins/netutils.h')
-rw-r--r-- | plugins/netutils.h | 152 |
1 files changed, 76 insertions, 76 deletions
diff --git a/plugins/netutils.h b/plugins/netutils.h index a95057e0..c4461113 100644 --- a/plugins/netutils.h +++ b/plugins/netutils.h | |||
@@ -1,120 +1,120 @@ | |||
1 | /***************************************************************************** | 1 | /***************************************************************************** |
2 | * | 2 | * |
3 | * Monitoring Plugins net utilities include file | 3 | * Monitoring Plugins net utilities include file |
4 | * | 4 | * |
5 | * License: GPL | 5 | * License: GPL |
6 | * Copyright (c) 1999 Ethan Galstad (nagios@nagios.org) | 6 | * Copyright (c) 1999 Ethan Galstad (nagios@nagios.org) |
7 | * Copyright (c) 2003-2007 Monitoring Plugins Development Team | 7 | * Copyright (c) 2003-2007 Monitoring Plugins Development Team |
8 | * | 8 | * |
9 | * Description: | 9 | * Description: |
10 | * | 10 | * |
11 | * This file contains common include files and function definitions | 11 | * This file contains common include files and function definitions |
12 | * used in many of the plugins. | 12 | * used in many of the plugins. |
13 | * | 13 | * |
14 | * | 14 | * |
15 | * This program is free software: you can redistribute it and/or modify | 15 | * This program is free software: you can redistribute it and/or modify |
16 | * it under the terms of the GNU General Public License as published by | 16 | * it under the terms of the GNU General Public License as published by |
17 | * the Free Software Foundation, either version 3 of the License, or | 17 | * the Free Software Foundation, either version 3 of the License, or |
18 | * (at your option) any later version. | 18 | * (at your option) any later version. |
19 | * | 19 | * |
20 | * This program is distributed in the hope that it will be useful, | 20 | * This program is distributed in the hope that it will be useful, |
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23 | * GNU General Public License for more details. | 23 | * GNU General Public License for more details. |
24 | * | 24 | * |
25 | * You should have received a copy of the GNU General Public License | 25 | * You should have received a copy of the GNU General Public License |
26 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 26 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
27 | * | 27 | * |
28 | * | 28 | * |
29 | *****************************************************************************/ | 29 | *****************************************************************************/ |
30 | 30 | ||
31 | #ifndef _NETUTILS_H_ | 31 | #ifndef _NETUTILS_H_ |
32 | #define _NETUTILS_H_ | 32 | #define _NETUTILS_H_ |
33 | 33 | ||
34 | #include "common.h" | 34 | #include "output.h" |
35 | #include "states.h" | ||
35 | #include "utils.h" | 36 | #include "utils.h" |
36 | #include <netinet/in.h> | 37 | #include <netinet/in.h> |
37 | #include <arpa/inet.h> | 38 | #include <arpa/inet.h> |
38 | #include <netdb.h> | 39 | #include <netdb.h> |
39 | 40 | ||
40 | #ifdef HAVE_SYS_UN_H | 41 | #ifdef HAVE_SYS_UN_H |
41 | # include <sys/un.h> | 42 | # include <sys/un.h> |
42 | # ifndef UNIX_PATH_MAX | 43 | # ifndef UNIX_PATH_MAX |
43 | /* linux uses this, on sun it's hard-coded at 108 without a define, on BSD at 104 */ | 44 | /* linux uses this, on sun it's hard-coded at 108 without a define, on BSD at 104 */ |
44 | # define UNIX_PATH_MAX 104 | 45 | # define UNIX_PATH_MAX 104 |
45 | # endif /* UNIX_PATH_MAX */ | 46 | # endif /* UNIX_PATH_MAX */ |
46 | #endif /* HAVE_SYS_UN_H */ | 47 | #endif /* HAVE_SYS_UN_H */ |
47 | 48 | ||
48 | #ifndef HOST_MAX_BYTES | 49 | #ifndef HOST_MAX_BYTES |
49 | # define HOST_MAX_BYTES 255 | 50 | # define HOST_MAX_BYTES 255 |
50 | #endif | 51 | #endif |
51 | 52 | ||
52 | /* process_request and wrapper macros */ | 53 | /* process_request and wrapper macros */ |
53 | #define process_tcp_request(addr, port, sbuf, rbuf, rsize) \ | 54 | #define process_tcp_request(addr, port, sbuf, rbuf, rsize) \ |
54 | process_request(addr, port, IPPROTO_TCP, sbuf, rbuf, rsize) | 55 | process_request(addr, port, IPPROTO_TCP, sbuf, rbuf, rsize) |
55 | #define process_udp_request(addr, port, sbuf, rbuf, rsize) \ | 56 | #define process_udp_request(addr, port, sbuf, rbuf, rsize) \ |
56 | process_request(addr, port, IPPROTO_UDP, sbuf, rbuf, rsize) | 57 | process_request(addr, port, IPPROTO_UDP, sbuf, rbuf, rsize) |
57 | int process_tcp_request2 (const char *address, int port, | 58 | mp_state_enum process_tcp_request2(const char *server_address, int server_port, |
58 | const char *sbuffer, char *rbuffer, int rsize); | 59 | const char *send_buffer, char *recv_buffer, int recv_size); |
59 | int process_request (const char *address, int port, int proto, | 60 | mp_state_enum process_request(const char *server_address, int server_port, int proto, |
60 | const char *sbuffer, char *rbuffer, int rsize); | 61 | const char *send_buffer, char *recv_buffer, int recv_size); |
61 | 62 | ||
62 | /* my_connect and wrapper macros */ | 63 | /* my_connect and wrapper macros */ |
63 | #define my_tcp_connect(addr, port, s) np_net_connect(addr, port, s, IPPROTO_TCP) | 64 | #define my_tcp_connect(addr, port, s) np_net_connect(addr, port, s, IPPROTO_TCP) |
64 | #define my_udp_connect(addr, port, s) np_net_connect(addr, port, s, IPPROTO_UDP) | 65 | #define my_udp_connect(addr, port, s) np_net_connect(addr, port, s, IPPROTO_UDP) |
65 | int np_net_connect(const char *address, int port, int *sd, int proto); | 66 | mp_state_enum np_net_connect(const char *host_name, int port, int *socketDescriptor, int proto); |
66 | 67 | ||
67 | /* send_request and wrapper macros */ | 68 | /* send_request and wrapper macros */ |
68 | #define send_tcp_request(s, sbuf, rbuf, rsize) \ | 69 | #define send_tcp_request(s, sbuf, rbuf, rsize) send_request(s, IPPROTO_TCP, sbuf, rbuf, rsize) |
69 | send_request(s, IPPROTO_TCP, sbuf, rbuf, rsize) | 70 | #define send_udp_request(s, sbuf, rbuf, rsize) send_request(s, IPPROTO_UDP, sbuf, rbuf, rsize) |
70 | #define send_udp_request(s, sbuf, rbuf, rsize) \ | 71 | mp_state_enum send_request(int socket, int proto, const char *send_buffer, char *recv_buffer, |
71 | send_request(s, IPPROTO_UDP, sbuf, rbuf, rsize) | 72 | int recv_size); |
72 | int send_request (int sd, int proto, const char *send_buffer, char *recv_buffer, int recv_size); | ||
73 | |||
74 | 73 | ||
75 | /* "is_*" wrapper macros and functions */ | 74 | /* "is_*" wrapper macros and functions */ |
76 | bool is_host (const char *); | 75 | bool is_host(const char *); |
77 | bool is_addr (const char *); | 76 | bool is_addr(const char *); |
78 | int dns_lookup (const char *, struct sockaddr_storage *, int); | 77 | bool dns_lookup(const char *, struct sockaddr_storage *, int); |
79 | void host_or_die(const char *str); | 78 | void host_or_die(const char *str); |
80 | #define resolve_host_or_addr(addr, family) dns_lookup(addr, NULL, family) | 79 | #define resolve_host_or_addr(addr, family) dns_lookup(addr, NULL, family) |
81 | #define is_inet_addr(addr) resolve_host_or_addr(addr, AF_INET) | 80 | #define is_inet_addr(addr) resolve_host_or_addr(addr, AF_INET) |
82 | #ifdef USE_IPV6 | 81 | #ifdef USE_IPV6 |
83 | # define is_inet6_addr(addr) resolve_host_or_addr(addr, AF_INET6) | 82 | # define is_inet6_addr(addr) resolve_host_or_addr(addr, AF_INET6) |
84 | # define is_hostname(addr) resolve_host_or_addr(addr, address_family) | 83 | # define is_hostname(addr) resolve_host_or_addr(addr, address_family) |
85 | #else | 84 | #else |
86 | # define is_hostname(addr) resolve_host_or_addr(addr, AF_INET) | 85 | # define is_hostname(addr) resolve_host_or_addr(addr, AF_INET) |
87 | #endif | 86 | #endif |
88 | 87 | ||
89 | extern unsigned int socket_timeout; | 88 | extern unsigned int socket_timeout; |
90 | extern unsigned int socket_timeout_state; | 89 | extern mp_state_enum socket_timeout_state; |
91 | extern int econn_refuse_state; | 90 | extern mp_state_enum econn_refuse_state; |
92 | extern bool was_refused; | 91 | extern bool was_refused; |
93 | extern int address_family; | 92 | extern int address_family; |
94 | 93 | ||
95 | void socket_timeout_alarm_handler (int) __attribute__((noreturn)); | 94 | void socket_timeout_alarm_handler(int) __attribute__((noreturn)); |
96 | 95 | ||
97 | /* SSL-Related functionality */ | 96 | /* SSL-Related functionality */ |
98 | #ifdef HAVE_SSL | 97 | #ifdef HAVE_SSL |
99 | # define MP_SSLv2 1 | 98 | # define MP_SSLv2 1 |
100 | # define MP_SSLv3 2 | 99 | # define MP_SSLv3 2 |
101 | # define MP_TLSv1 3 | 100 | # define MP_TLSv1 3 |
102 | # define MP_TLSv1_1 4 | 101 | # define MP_TLSv1_1 4 |
103 | # define MP_TLSv1_2 5 | 102 | # define MP_TLSv1_2 5 |
104 | # define MP_SSLv2_OR_NEWER 6 | 103 | # define MP_SSLv2_OR_NEWER 6 |
105 | # define MP_SSLv3_OR_NEWER 7 | 104 | # define MP_SSLv3_OR_NEWER 7 |
106 | # define MP_TLSv1_OR_NEWER 8 | 105 | # define MP_TLSv1_OR_NEWER 8 |
107 | # define MP_TLSv1_1_OR_NEWER 9 | 106 | # define MP_TLSv1_1_OR_NEWER 9 |
108 | # define MP_TLSv1_2_OR_NEWER 10 | 107 | # define MP_TLSv1_2_OR_NEWER 10 |
109 | /* maybe this could be merged with the above np_net_connect, via some flags */ | 108 | /* maybe this could be merged with the above np_net_connect, via some flags */ |
110 | int np_net_ssl_init(int sd); | 109 | int np_net_ssl_init(int socket); |
111 | int np_net_ssl_init_with_hostname(int sd, char *host_name); | 110 | int np_net_ssl_init_with_hostname(int socket, char *host_name); |
112 | int np_net_ssl_init_with_hostname_and_version(int sd, char *host_name, int version); | 111 | int np_net_ssl_init_with_hostname_and_version(int socket, char *host_name, int version); |
113 | int np_net_ssl_init_with_hostname_version_and_cert(int sd, char *host_name, int version, char *cert, char *privkey); | 112 | int np_net_ssl_init_with_hostname_version_and_cert(int socket, char *host_name, int version, |
114 | void np_net_ssl_cleanup(); | 113 | char *cert, char *privkey); |
114 | void np_net_ssl_cleanup(void); | ||
115 | int np_net_ssl_write(const void *buf, int num); | 115 | int np_net_ssl_write(const void *buf, int num); |
116 | int np_net_ssl_read(void *buf, int num); | 116 | int np_net_ssl_read(void *buf, int num); |
117 | int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit); | 117 | mp_state_enum np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit); |
118 | mp_subcheck mp_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit); | ||
118 | #endif /* HAVE_SSL */ | 119 | #endif /* HAVE_SSL */ |
119 | |||
120 | #endif /* _NETUTILS_H_ */ | 120 | #endif /* _NETUTILS_H_ */ |