summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.in7
-rw-r--r--lib/Makefile.am6
-rw-r--r--plugins/Makefile.am53
-rw-r--r--plugins/getaddrinfo.c (renamed from lib/getaddrinfo.c)27
-rw-r--r--plugins/getaddrinfo.h (renamed from lib/getaddrinfo.h)1
-rw-r--r--plugins/gethostbyname.c (renamed from lib/gethostbyname.c)0
-rw-r--r--plugins/gethostbyname.h (renamed from lib/gethostbyname.h)0
-rw-r--r--plugins/netutils.c83
-rw-r--r--plugins/netutils.h13
-rw-r--r--plugins/utils.c81
-rw-r--r--plugins/utils.h8
11 files changed, 123 insertions, 156 deletions
diff --git a/configure.in b/configure.in
index ec3606e..eea01da 100644
--- a/configure.in
+++ b/configure.in
@@ -386,7 +386,7 @@ else
386 if test x$enable_emulate_getaddrinfo != xyes ; then 386 if test x$enable_emulate_getaddrinfo != xyes ; then
387 AC_MSG_ERROR([getaddrinfo not found: try --with-lwres or --enable-emulate-getaddrinfo]) 387 AC_MSG_ERROR([getaddrinfo not found: try --with-lwres or --enable-emulate-getaddrinfo])
388 fi 388 fi
389 LIBOBJS="$LIBOBJS getaddrinfo.o" 389 EXTRA_NETOBJS="$EXTRA_NETOBJS getaddrinfo.o"
390fi 390fi
391 391
392if test x"$enable_emulate_getaddrinfo" != xno ; then 392if test x"$enable_emulate_getaddrinfo" != xno ; then
@@ -414,7 +414,8 @@ if test x"$enable_emulate_getaddrinfo" != xno ; then
414 AC_SEARCH_LIBS(gethostbyname, resolv bind nsl, , 414 AC_SEARCH_LIBS(gethostbyname, resolv bind nsl, ,
415 [AC_MSG_ERROR([cannot find gethostbyname])]) 415 [AC_MSG_ERROR([cannot find gethostbyname])])
416 fi 416 fi
417 LIBOBJS="$LIBOBJS gethostbyname.o" 417 EXTRA_NETOBJS="$EXTRA_NETOBJS gethostbyname.o"
418 AC_DEFINE(EMULATE_GETADDRINFO,1,[Define if emulating getaddrinfo])
418 419
419fi 420fi
420 421
@@ -1451,7 +1452,7 @@ AC_TRY_COMPILE([#ifdef __STDC__
1451 [NEED_VA_LIST=-DNEED_VA_LIST AC_SUBST(NEED_VA_LIST) AC_MSG_RESULT(no)]) 1452 [NEED_VA_LIST=-DNEED_VA_LIST AC_SUBST(NEED_VA_LIST) AC_MSG_RESULT(no)])
1452 1453
1453AC_SUBST(EXTRAS) 1454AC_SUBST(EXTRAS)
1454AC_SUBST(LIBOBJS) 1455AC_SUBST(EXTRA_NETOBJS)
1455AC_SUBST(DEPLIBS) 1456AC_SUBST(DEPLIBS)
1456 1457
1457AC_DEFINE_UNQUOTED(PACKAGE_VERSION,"${VERSION}",[package version]) 1458AC_DEFINE_UNQUOTED(PACKAGE_VERSION,"${VERSION}",[package version])
diff --git a/lib/Makefile.am b/lib/Makefile.am
index b24bc40..9a26e41 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -2,12 +2,8 @@
2 2
3noinst_LIBRARIES = libnagiosplug.a 3noinst_LIBRARIES = libnagiosplug.a
4 4
5noinst_HEADERS = getopt.h getaddrinfo.h gethostbyname.h 5noinst_HEADERS = getopt.h
6 6
7libnagiosplug_a_SOURCES = getopt.c getopt1.c getloadavg.c snprintf.c 7libnagiosplug_a_SOURCES = getopt.c getopt1.c getloadavg.c snprintf.c
8 8
9libnagiosplug_a_DEPENDENCIES = @LIBOBJS@
10
11INCLUDES = -I$(srcdir) 9INCLUDES = -I$(srcdir)
12
13EXTRA_DIST = getaddrinfo.c gethostbyname.c
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 2524e1a..a884b45 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -14,14 +14,15 @@ EXTRA_PROGRAMS = check_mysql check_radius check_pgsql check_snmp check_hpjd \
14 check_swap check_fping check_ldap check_game check_dig \ 14 check_swap check_fping check_ldap check_game check_dig \
15 check_nagios check_by_ssh check_dns check_nt 15 check_nagios check_by_ssh check_dns check_nt
16 16
17check_tcp_programs = check_ftp check_imap check_nntp check_pop 17check_tcp_programs = check_ftp check_imap check_nntp check_pop check_udp2
18 18
19EXTRA_DIST = t utils.c netutils.c popen.c utils.h netutils.h popen.h common.h 19EXTRA_DIST = t utils.c netutils.c popen.c utils.h netutils.h popen.h common.h \
20 getaddrinfo.c getaddrinfo.h gethostbyname.c gethostbyname.h
20 21
21PLUGINHDRS = common.h config.h 22PLUGINHDRS = common.h config.h
22 23
23BASEOBJS = utils.o ../lib/libnagiosplug.a 24BASEOBJS = utils.o ../lib/libnagiosplug.a
24NETOBJS = netutils.o $(BASEOBJS) 25NETOBJS = netutils.o $(BASEOBJS) $(EXTRA_NETOBJS)
25NETLIBS = $(NETOBJS) $(SOCKETLIBS) 26NETLIBS = $(NETOBJS) $(SOCKETLIBS)
26 27
27TESTS_ENVIRONMENT = perl -I $(top_builddir) -I $(top_srcdir) 28TESTS_ENVIRONMENT = perl -I $(top_builddir) -I $(top_srcdir)
@@ -36,27 +37,27 @@ AM_INSTALL_PROGRAM_FLAGS = @INSTALL_OPTS@
36############################################################################## 37##############################################################################
37# the actual targets 38# the actual targets
38 39
39check_dig_LDADD = $(BASEOBJS) popen.o 40check_dig_LDADD = $(NETLIBS) popen.o
40check_disk_LDADD = $(BASEOBJS) popen.o 41check_disk_LDADD = $(BASEOBJS) popen.o
41check_dns_LDADD = $(BASEOBJS) popen.o 42check_dns_LDADD = $(NETLIBS) popen.o
42check_dummy_LDADD = $(BASEOBJS) 43check_dummy_LDADD = $(BASEOBJS)
43check_fping_LDADD = $(BASEOBJS) popen.o 44check_fping_LDADD = $(NETLIBS) popen.o
44check_game_LDADD = $(BASEOBJS) 45check_game_LDADD = $(BASEOBJS)
45check_http_LDADD = $(NETLIBS) $(SSLLIBS) 46check_http_LDADD = $(NETLIBS) $(SSLLIBS)
46check_hpjd_LDADD = $(BASEOBJS) popen.o 47check_hpjd_LDADD = $(NETLIBS) popen.o
47check_ldap_LDADD = $(NETLIBS) $(LDAPLIBS) 48check_ldap_LDADD = $(NETLIBS) $(LDAPLIBS)
48check_load_LDADD = $(BASEOBJS) popen.o 49check_load_LDADD = $(BASEOBJS) popen.o
49check_mrtg_LDADD = $(BASEOBJS) 50check_mrtg_LDADD = $(BASEOBJS)
50check_mrtgtraf_LDADD = $(BASEOBJS) 51check_mrtgtraf_LDADD = $(BASEOBJS)
51check_mysql_LDADD = $(BASEOBJS) $(MYSQLLIBS) 52check_mysql_LDADD = $(NETLIBS) $(MYSQLLIBS)
52check_nagios_LDADD = $(BASEOBJS) popen.o 53check_nagios_LDADD = $(BASEOBJS) popen.o
53check_nt_LDADD = $(NETLIBS) 54check_nt_LDADD = $(NETLIBS)
54check_nwstat_LDADD = $(NETLIBS) 55check_nwstat_LDADD = $(NETLIBS)
55check_overcr_LDADD = $(NETLIBS) 56check_overcr_LDADD = $(NETLIBS)
56check_pgsql_LDADD = $(BASEOBJS) $(PGLIBS) 57check_pgsql_LDADD = $(NETLIBS) $(PGLIBS)
57check_ping_LDADD = $(BASEOBJS) popen.o 58check_ping_LDADD = $(NETLIBS) popen.o
58check_procs_LDADD = $(BASEOBJS) popen.o 59check_procs_LDADD = $(BASEOBJS) popen.o
59check_radius_LDADD = $(BASEOBJS) $(RADIUSLIBS) 60check_radius_LDADD = $(NETLIBS) $(RADIUSLIBS)
60check_real_LDADD = $(NETLIBS) 61check_real_LDADD = $(NETLIBS)
61check_snmp_LDADD = $(BASEOBJS) popen.o 62check_snmp_LDADD = $(BASEOBJS) popen.o
62check_smtp_LDADD = $(NETLIBS) 63check_smtp_LDADD = $(NETLIBS)
@@ -68,31 +69,31 @@ check_udp_LDADD = $(NETLIBS)
68check_ups_LDADD = $(NETLIBS) 69check_ups_LDADD = $(NETLIBS)
69check_users_LDADD = $(BASEOBJS) popen.o 70check_users_LDADD = $(BASEOBJS) popen.o
70check_vsz_LDADD = $(BASEOBJS) popen.o 71check_vsz_LDADD = $(BASEOBJS) popen.o
71check_by_ssh_LDADD = $(BASEOBJS) popen.o 72check_by_ssh_LDADD = $(NETLIBS) popen.o
72negate_LDADD = $(BASEOBJS) popen.o 73negate_LDADD = $(BASEOBJS) popen.o
73urlize_LDADD = $(BASEOBJS) popen.o 74urlize_LDADD = $(BASEOBJS) popen.o
74 75
75check_dig_DEPENDENCIES = check_dig.c $(BASEOBJS) popen.o $(DEPLIBS) 76check_dig_DEPENDENCIES = check_dig.c $(NETOBJS) popen.o $(DEPLIBS)
76check_disk_DEPENDENCIES = check_disk.c $(BASEOBJS) popen.o $(DEPLIBS) 77check_disk_DEPENDENCIES = check_disk.c $(BASEOBJS) popen.o $(DEPLIBS)
77check_dns_DEPENDENCIES = check_dns.c $(BASEOBJS) popen.o $(DEPLIBS) 78check_dns_DEPENDENCIES = check_dns.c $(NETOBJS) popen.o $(DEPLIBS)
78check_dummy_DEPENDENCIES = check_dummy.c $(DEPLIBS) 79check_dummy_DEPENDENCIES = check_dummy.c $(DEPLIBS)
79check_fping_DEPENDENCIES = check_fping.c $(BASEOBJS) popen.o $(DEPLIBS) 80check_fping_DEPENDENCIES = check_fping.c $(NETOBJS) popen.o $(DEPLIBS)
80check_game_DEPENDENCIES = check_game.c $(DEPLIBS) 81check_game_DEPENDENCIES = check_game.c $(DEPLIBS)
81check_http_DEPENDENCIES = check_http.c $(NETOBJS) $(DEPLIBS) 82check_http_DEPENDENCIES = check_http.c $(NETOBJS) $(DEPLIBS)
82check_hpjd_DEPENDENCIES = check_hpjd.c $(BASEOBJS) popen.o $(DEPLIBS) 83check_hpjd_DEPENDENCIES = check_hpjd.c $(NETOBJS) popen.o $(DEPLIBS)
83check_ldap_DEPENDENCIES = check_ldap.c $(NETOBJS) $(DEPLIBS) 84check_ldap_DEPENDENCIES = check_ldap.c $(NETOBJS) $(DEPLIBS)
84check_load_DEPENDENCIES = check_load.c $(BASEOBJS) popen.o $(DEPLIBS) 85check_load_DEPENDENCIES = check_load.c $(BASEOBJS) popen.o $(DEPLIBS)
85check_mrtg_DEPENDENCIES = check_mrtg.c $(DEPLIBS) 86check_mrtg_DEPENDENCIES = check_mrtg.c $(DEPLIBS)
86check_mrtgtraf_DEPENDENCIES = check_mrtgtraf.c $(DEPLIBS) 87check_mrtgtraf_DEPENDENCIES = check_mrtgtraf.c $(DEPLIBS)
87check_mysql_DEPENDENCIES = check_mysql.c $(DEPLIBS) 88check_mysql_DEPENDENCIES = check_mysql.c $(NETOBJS) $(DEPLIBS)
88check_nagios_DEPENDENCIES = check_nagios.c $(BASEOBJS) popen.o $(DEPLIBS) 89check_nagios_DEPENDENCIES = check_nagios.c $(BASEOBJS) popen.o $(DEPLIBS)
89check_nt_DEPENDENCIES = check_nt.c $(NETOBJS) $(DEPLIBS) 90check_nt_DEPENDENCIES = check_nt.c $(NETOBJS) $(DEPLIBS)
90check_nwstat_DEPENDENCIES = check_nwstat.c $(NETOBJS) $(DEPLIBS) 91check_nwstat_DEPENDENCIES = check_nwstat.c $(NETOBJS) $(DEPLIBS)
91check_overcr_DEPENDENCIES = check_overcr.c $(NETOBJS) $(DEPLIBS) 92check_overcr_DEPENDENCIES = check_overcr.c $(NETOBJS) $(DEPLIBS)
92check_pgsql_DEPENDENCIES = check_pgsql.c $(DEPLIBS) 93check_pgsql_DEPENDENCIES = check_pgsql.c $(NETOBJS) $(DEPLIBS)
93check_ping_DEPENDENCIES = check_ping.c $(BASEOBJS) popen.o $(DEPLIBS) 94check_ping_DEPENDENCIES = check_ping.c $(NETOBJS) popen.o $(DEPLIBS)
94check_procs_DEPENDENCIES = check_procs.c $(BASEOBJS) popen.o $(DEPLIBS) 95check_procs_DEPENDENCIES = check_procs.c $(BASEOBJS) popen.o $(DEPLIBS)
95check_radius_DEPENDENCIES = check_radius.c $(DEPLIBS) 96check_radius_DEPENDENCIES = check_radius.c $(NETOBJS) $(DEPLIBS)
96check_real_DEPENDENCIES = check_real.c $(NETOBJS) $(DEPLIBS) 97check_real_DEPENDENCIES = check_real.c $(NETOBJS) $(DEPLIBS)
97check_snmp_DEPENDENCIES = check_snmp.c $(BASEOBJS) popen.o $(DEPLIBS) 98check_snmp_DEPENDENCIES = check_snmp.c $(BASEOBJS) popen.o $(DEPLIBS)
98check_smtp_DEPENDENCIES = check_smtp.c $(NETOBJS) $(DEPLIBS) 99check_smtp_DEPENDENCIES = check_smtp.c $(NETOBJS) $(DEPLIBS)
@@ -104,7 +105,7 @@ check_udp_DEPENDENCIES = check_udp.c $(NETOBJS) $(DEPLIBS)
104check_ups_DEPENDENCIES = check_ups.c $(NETOBJS) $(DEPLIBS) 105check_ups_DEPENDENCIES = check_ups.c $(NETOBJS) $(DEPLIBS)
105check_users_DEPENDENCIES = check_users.c $(BASEOBJS) popen.o $(DEPLIBS) 106check_users_DEPENDENCIES = check_users.c $(BASEOBJS) popen.o $(DEPLIBS)
106check_vsz_DEPENDENCIES = check_vsz.c $(BASEOBJS) popen.o $(DEPLIBS) 107check_vsz_DEPENDENCIES = check_vsz.c $(BASEOBJS) popen.o $(DEPLIBS)
107check_by_ssh_DEPENDENCIES = check_by_ssh.c $(BASEOBJS) popen.o $(DEPLIBS) 108check_by_ssh_DEPENDENCIES = check_by_ssh.c $(NETOBJS) popen.o $(DEPLIBS)
108negate_DEPENDENCIES = negate.c $(BASEOBJS) popen.o $(DEPLIBS) 109negate_DEPENDENCIES = negate.c $(BASEOBJS) popen.o $(DEPLIBS)
109urlize_DEPENDENCIES = urlize.c $(BASEOBJS) popen.o $(DEPLIBS) 110urlize_DEPENDENCIES = urlize.c $(BASEOBJS) popen.o $(DEPLIBS)
110 111
@@ -117,6 +118,10 @@ utils.o: utils.c utils.h $(PLUGINHDRS)
117 118
118netutils.o: netutils.c netutils.h $(PLUGINHDRS) 119netutils.o: netutils.c netutils.h $(PLUGINHDRS)
119 120
121getaddrinfo.o: getaddrinfo.h $(PLUGINHDRS)
122
123gethostbyname.o: gethostbyname.h $(PLUGINHDRS)
124
120all-local: $(check_tcp_programs) 125all-local: $(check_tcp_programs)
121 126
122$(check_tcp_programs): check_tcp 127$(check_tcp_programs): check_tcp
diff --git a/lib/getaddrinfo.c b/plugins/getaddrinfo.c
index c958da6..12ac67d 100644
--- a/lib/getaddrinfo.c
+++ b/plugins/getaddrinfo.c
@@ -2,6 +2,7 @@
2 * This file is part of libESMTP, a library for submission of RFC 2822 2 * This file is part of libESMTP, a library for submission of RFC 2822
3 * formatted electronic mail messages using the SMTP protocol described 3 * formatted electronic mail messages using the SMTP protocol described
4 * in RFC 2821. 4 * in RFC 2821.
5 * Modified by Jeremy T. Bouse for use in Nagios plugins
5 * 6 *
6 * Copyright (C) 2001,2002 Brian Stafford <brian@stafford.uklinux.net> 7 * Copyright (C) 2001,2002 Brian Stafford <brian@stafford.uklinux.net>
7 * 8 *
@@ -89,26 +90,17 @@ getaddrinfo (const char *nodename, const char *servname,
89 hints = &hint; 90 hints = &hint;
90 } 91 }
91 92
92 /* servname must not be NULL in this implementation */
93 if (servname == NULL)
94 return EAI_NONAME;
95
96 /* check for tcp or udp sockets only */
97 if (hints->ai_socktype == SOCK_STREAM)
98 socktype = "tcp";
99 else if (hints->ai_socktype == SOCK_DGRAM)
100 socktype = "udp";
101 else
102 return EAI_SERVICE;
103 result.ai_socktype = hints->ai_socktype; 93 result.ai_socktype = hints->ai_socktype;
104 94
105 /* Note: maintain port in host byte order to make debugging easier */ 95 /* Note: maintain port in host byte order to make debugging easier */
106 if (isdigit (*servname)) 96 if (servname != NULL) {
107 port = strtol (servname, NULL, 10); 97 if (isdigit (*servname))
108 else if ((servent = getservbyname (servname, socktype)) != NULL) 98 port = strtol (servname, NULL, 10);
109 port = ntohs (servent->s_port); 99 else if ((servent = getservbyname (servname, socktype)) != NULL)
110 else 100 port = ntohs (servent->s_port);
111 return EAI_NONAME; 101 else
102 return EAI_NONAME;
103 }
112 104
113 /* if nodename == NULL refer to the local host for a client or any 105 /* if nodename == NULL refer to the local host for a client or any
114 for a server */ 106 for a server */
@@ -309,4 +301,3 @@ gai_strerror (int ecode)
309 return "unknown error"; 301 return "unknown error";
310 return eai_descr[ecode]; 302 return eai_descr[ecode];
311} 303}
312
diff --git a/lib/getaddrinfo.h b/plugins/getaddrinfo.h
index c474d3b..5bcc884 100644
--- a/lib/getaddrinfo.h
+++ b/plugins/getaddrinfo.h
@@ -4,6 +4,7 @@
4 * This file is part of libESMTP, a library for submission of RFC 2822 4 * This file is part of libESMTP, a library for submission of RFC 2822
5 * formatted electronic mail messages using the SMTP protocol described 5 * formatted electronic mail messages using the SMTP protocol described
6 * in RFC 2821. 6 * in RFC 2821.
7 * Modified by Jeremy T. Bouse for use in Nagios plugins
7 * 8 *
8 * Copyright (C) 2001,2002 Brian Stafford <brian@stafford.uklinux.net> 9 * Copyright (C) 2001,2002 Brian Stafford <brian@stafford.uklinux.net>
9 * 10 *
diff --git a/lib/gethostbyname.c b/plugins/gethostbyname.c
index d151606..d151606 100644
--- a/lib/gethostbyname.c
+++ b/plugins/gethostbyname.c
diff --git a/lib/gethostbyname.h b/plugins/gethostbyname.h
index 2b96399..2b96399 100644
--- a/lib/gethostbyname.h
+++ b/plugins/gethostbyname.h
diff --git a/plugins/netutils.c b/plugins/netutils.c
index c0e82da..4234c43 100644
--- a/plugins/netutils.c
+++ b/plugins/netutils.c
@@ -29,22 +29,9 @@
29* 29*
30****************************************************************************/ 30****************************************************************************/
31 31
32#include "config.h" 32#include "netutils.h"
33#include "common.h"
34#include <netinet/in.h>
35#include <arpa/inet.h>
36 33
37extern int socket_timeout; 34int socket_timeout = DEFAULT_SOCKET_TIMEOUT;
38RETSIGTYPE socket_timeout_alarm_handler (int);
39
40int process_tcp_request2 (char *, int, char *, char *, int);
41int process_tcp_request (char *, int, char *, char *, int);
42int process_udp_request (char *, int, char *, char *, int);
43int process_request (char *, int, int, char *, char *, int);
44
45int my_tcp_connect (char *, int, int *);
46int my_udp_connect (char *, int, int *);
47int my_connect (char *, int, int *, int);
48 35
49/* handles socket timeouts */ 36/* handles socket timeouts */
50void 37void
@@ -304,3 +291,69 @@ my_connect (char *host_name, int port, int *sd, int proto)
304 return STATE_CRITICAL; 291 return STATE_CRITICAL;
305 } 292 }
306} 293}
294
295int
296is_host (char *address)
297{
298 if (is_addr (address) || is_hostname (address))
299 return (TRUE);
300
301 return (FALSE);
302}
303
304int
305is_addr (char *address)
306{
307#ifdef USE_IPV6
308 if (is_inet_addr (address) || is_inet6_addr (address))
309#else
310 if (is_inet_addr (address))
311#endif
312 return (TRUE);
313
314 return (FALSE);
315}
316
317int
318resolve_host_or_addr (char *address, int family)
319{
320 struct addrinfo hints;
321 struct addrinfo *res;
322 int retval;
323
324 memset (&hints, 0, sizeof (hints));
325 hints.ai_family = family;
326 retval = getaddrinfo (address, NULL, &hints, &res);
327
328 if (retval != 0)
329 return FALSE;
330 else {
331 freeaddrinfo (res);
332 return TRUE;
333 }
334}
335
336int
337is_inet_addr (char *address)
338{
339 return resolve_host_or_addr (address, AF_INET);
340}
341
342#ifdef USE_IPV6
343int
344is_inet6_addr (char *address)
345{
346 return resolve_host_or_addr (address, AF_INET6);
347}
348#endif
349
350int
351is_hostname (char *s1)
352{
353#ifdef USE_IPV6
354 return resolve_host_or_addr (s1, AF_UNSPEC);
355#else
356 return resolve_host_or_addr (s1, AF_INET);
357#endif
358}
359
diff --git a/plugins/netutils.h b/plugins/netutils.h
index 3ea5166..6c8eed3 100644
--- a/plugins/netutils.h
+++ b/plugins/netutils.h
@@ -43,11 +43,20 @@ int process_tcp_request (char *address, int port, char *sbuffer,
43 char *rbuffer, int rsize); 43 char *rbuffer, int rsize);
44int process_udp_request (char *address, int port, char *sbuffer, 44int process_udp_request (char *address, int port, char *sbuffer,
45 char *rbuffer, int rsize); 45 char *rbuffer, int rsize);
46int process_request (char *address, int port, char *proto, char *sbuffer, 46int process_request (char *address, int port, int proto, char *sbuffer,
47 char *rbuffer, int rsize); 47 char *rbuffer, int rsize);
48 48
49int my_tcp_connect (char *address, int port, int *sd); 49int my_tcp_connect (char *address, int port, int *sd);
50int my_udp_connect (char *address, int port, int *sd); 50int my_udp_connect (char *address, int port, int *sd);
51int my_connect (char *address, int port, int *sd, int proto); 51int my_connect (char *address, int port, int *sd, int proto);
52 52
53int socket_timeout = DEFAULT_SOCKET_TIMEOUT; 53int is_host (char *);
54int is_addr (char *);
55int resolve_host_or_addr (char *, int);
56int is_inet_addr (char *);
57#ifdef USE_IPV6
58int is_inet6_addr (char *);
59#endif
60int is_hostname (char *);
61
62extern int socket_timeout;
diff --git a/plugins/utils.c b/plugins/utils.c
index 7361323..e204e23 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -27,15 +27,6 @@ void print_revision (const char *, const char *);
27void terminate (int, const char *fmt, ...); 27void terminate (int, const char *fmt, ...);
28RETSIGTYPE timeout_alarm_handler (int); 28RETSIGTYPE timeout_alarm_handler (int);
29 29
30int is_host (char *);
31int is_addr (char *);
32int resolve_host_or_addr (char *, int);
33int is_inet_addr (char *);
34#ifdef USE_IPV6
35int is_inet6_addr (char *);
36#endif
37int is_hostname (char *);
38
39int is_integer (char *); 30int is_integer (char *);
40int is_intpos (char *); 31int is_intpos (char *);
41int is_intneg (char *); 32int is_intneg (char *);
@@ -171,78 +162,6 @@ timeout_alarm_handler (int signo)
171} 162}
172 163
173int 164int
174is_host (char *address)
175{
176 if (is_addr (address) || is_hostname (address))
177 return (TRUE);
178
179 return (FALSE);
180}
181
182int
183is_addr (char *address)
184{
185#ifdef USE_IPV6
186 if (is_inet_addr (address) || is_inet6_addr (address))
187#else
188 if (is_inet_addr (address))
189#endif
190 return (TRUE);
191
192 return (FALSE);
193}
194
195int
196resolve_host_or_addr (char *address, int family)
197{
198 struct addrinfo hints;
199 struct addrinfo *res;
200 int retval;
201
202 memset (&hints, 0, sizeof (hints));
203 hints.ai_family = family;
204 retval = getaddrinfo (address, NULL, &hints, &res);
205
206 if (retval != 0)
207 return FALSE;
208 else {
209 freeaddrinfo (res);
210 return TRUE;
211 }
212}
213
214int
215is_inet_addr (char *address)
216{
217 return resolve_host_or_addr (address, AF_INET);
218}
219
220#ifdef USE_IPV6
221int
222is_inet6_addr (char *address)
223{
224 return resolve_host_or_addr (address, AF_INET6);
225}
226#endif
227
228/* from RFC-1035
229 *
230 * The labels must follow the rules for ARPANET host names. They must
231 * start with a letter, end with a letter or digit, and have as interior
232 * characters only letters, digits, and hyphen. There are also some
233 * restrictions on the length. Labels must be 63 characters or less. */
234
235int
236is_hostname (char *s1)
237{
238#ifdef USE_IPV6
239 return resolve_host_or_addr (s1, AF_UNSPEC);
240#else
241 return resolve_host_or_addr (s1, AF_INET);
242#endif
243}
244
245int
246is_numeric (char *number) 165is_numeric (char *number)
247{ 166{
248 char tmp[1]; 167 char tmp[1];
diff --git a/plugins/utils.h b/plugins/utils.h
index 89ada6f..43b612c 100644
--- a/plugins/utils.h
+++ b/plugins/utils.h
@@ -27,14 +27,6 @@ int timeout_interval = DEFAULT_SOCKET_TIMEOUT;
27 27
28/* Test input types */ 28/* Test input types */
29 29
30int is_host (char *);
31int is_addr (char *);
32int is_inet_addr (char *);
33#ifdef USE_IPV6
34int is_inet6_addr (char *);
35#endif
36int is_hostname (char *);
37
38int is_integer (char *); 30int is_integer (char *);
39int is_intpos (char *); 31int is_intpos (char *);
40int is_intneg (char *); 32int is_intneg (char *);