summaryrefslogtreecommitdiffstats
path: root/plugins/utils.c
diff options
context:
space:
mode:
authorJeremy T. Bouse <undrgrid@users.sourceforge.net>2003-03-15 01:25:35 (GMT)
committerJeremy T. Bouse <undrgrid@users.sourceforge.net>2003-03-15 01:25:35 (GMT)
commit11b35b92e3195d230bef359f6a0679ae4414716b (patch)
treef4911e5804c1f3037dcf63bbbf0b823c5ac19e5f /plugins/utils.c
parent6cf5fc3c74c0bdfef6c4cc1b627578378ad3a407 (diff)
downloadmonitoring-plugins-11b35b92e3195d230bef359f6a0679ae4414716b.tar.gz
Spent the day working on backwards compatability using getaddrinfo()
Moved getaddrinfo.? and gethostbyname.? from lib/ to plugins/ due to problems with compiling into the libnagiosplug.a as it required linking against socket libraries which are unneeded except for network based plugins. This code should hopefully happily work for all systems and has been tested prior to commit on Debian GNU/Linux, SPARC Solaris 7 and SPARC Solaris 9. git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@424 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/utils.c')
-rw-r--r--plugins/utils.c81
1 files changed, 0 insertions, 81 deletions
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];