diff options
author | Jeremy T. Bouse <undrgrid@users.sourceforge.net> | 2003-03-15 01:25:35 (GMT) |
---|---|---|
committer | Jeremy T. Bouse <undrgrid@users.sourceforge.net> | 2003-03-15 01:25:35 (GMT) |
commit | 11b35b92e3195d230bef359f6a0679ae4414716b (patch) | |
tree | f4911e5804c1f3037dcf63bbbf0b823c5ac19e5f /plugins/utils.c | |
parent | 6cf5fc3c74c0bdfef6c4cc1b627578378ad3a407 (diff) | |
download | monitoring-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.c | 81 |
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 *); | |||
27 | void terminate (int, const char *fmt, ...); | 27 | void terminate (int, const char *fmt, ...); |
28 | RETSIGTYPE timeout_alarm_handler (int); | 28 | RETSIGTYPE timeout_alarm_handler (int); |
29 | 29 | ||
30 | int is_host (char *); | ||
31 | int is_addr (char *); | ||
32 | int resolve_host_or_addr (char *, int); | ||
33 | int is_inet_addr (char *); | ||
34 | #ifdef USE_IPV6 | ||
35 | int is_inet6_addr (char *); | ||
36 | #endif | ||
37 | int is_hostname (char *); | ||
38 | |||
39 | int is_integer (char *); | 30 | int is_integer (char *); |
40 | int is_intpos (char *); | 31 | int is_intpos (char *); |
41 | int is_intneg (char *); | 32 | int is_intneg (char *); |
@@ -171,78 +162,6 @@ timeout_alarm_handler (int signo) | |||
171 | } | 162 | } |
172 | 163 | ||
173 | int | 164 | int |
174 | is_host (char *address) | ||
175 | { | ||
176 | if (is_addr (address) || is_hostname (address)) | ||
177 | return (TRUE); | ||
178 | |||
179 | return (FALSE); | ||
180 | } | ||
181 | |||
182 | int | ||
183 | is_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 | |||
195 | int | ||
196 | resolve_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 | |||
214 | int | ||
215 | is_inet_addr (char *address) | ||
216 | { | ||
217 | return resolve_host_or_addr (address, AF_INET); | ||
218 | } | ||
219 | |||
220 | #ifdef USE_IPV6 | ||
221 | int | ||
222 | is_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 | |||
235 | int | ||
236 | is_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 | |||
245 | int | ||
246 | is_numeric (char *number) | 165 | is_numeric (char *number) |
247 | { | 166 | { |
248 | char tmp[1]; | 167 | char tmp[1]; |