getaddrinfo.c (e8baaa70629833b245540b4915c58ee4ae2ec446) getaddrinfo.c (b29ec00b7057a9871e9adf2ebc1ce52b6128b09c)
1/* $KAME: getaddrinfo.c,v 1.15 2000/07/09 04:37:24 itojun Exp $ */
2
3/*
4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 225 unchanged lines hidden (view full) ---

234static int _yp_getaddrinfo(void *, void *, va_list);
235#endif
236
237static int res_queryN(const char *, struct res_target *);
238static int res_searchN(const char *, struct res_target *);
239static int res_querydomainN(const char *, const char *,
240 struct res_target *);
241
1/* $KAME: getaddrinfo.c,v 1.15 2000/07/09 04:37:24 itojun Exp $ */
2
3/*
4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 225 unchanged lines hidden (view full) ---

234static int _yp_getaddrinfo(void *, void *, va_list);
235#endif
236
237static int res_queryN(const char *, struct res_target *);
238static int res_searchN(const char *, struct res_target *);
239static int res_querydomainN(const char *, const char *,
240 struct res_target *);
241
242static char *ai_errlist[] = {
243 "Success",
244 "Address family for hostname not supported", /* EAI_ADDRFAMILY */
245 "Temporary failure in name resolution", /* EAI_AGAIN */
246 "Invalid value for ai_flags", /* EAI_BADFLAGS */
247 "Non-recoverable failure in name resolution", /* EAI_FAIL */
248 "ai_family not supported", /* EAI_FAMILY */
249 "Memory allocation failure", /* EAI_MEMORY */
250 "No address associated with hostname", /* EAI_NODATA */
251 "hostname nor servname provided, or not known", /* EAI_NONAME */
252 "servname not supported for ai_socktype", /* EAI_SERVICE */
253 "ai_socktype not supported", /* EAI_SOCKTYPE */
254 "System error returned in errno", /* EAI_SYSTEM */
255 "Invalid value for hints", /* EAI_BADHINTS */
256 "Resolved protocol is unknown", /* EAI_PROTOCOL */
257 "Unknown error", /* EAI_MAX */
242static struct ai_errlist {
243 const char *str;
244 int code;
245} ai_errlist[] = {
246 { "Success", 0, },
247#ifdef EAI_ADDRFAMILY
248 { "Address family for hostname not supported", EAI_ADDRFAMILY, },
249#endif
250 { "Temporary failure in name resolution", EAI_AGAIN, },
251 { "Invalid value for ai_flags", EAI_BADFLAGS, },
252 { "Non-recoverable failure in name resolution", EAI_FAIL, },
253 { "ai_family not supported", EAI_FAMILY, },
254 { "Memory allocation failure", EAI_MEMORY, },
255#ifdef EAI_NODATA
256 { "No address associated with hostname", EAI_NODATA, },
257#endif
258 { "hostname nor servname provided, or not known", EAI_NONAME, },
259 { "servname not supported for ai_socktype", EAI_SERVICE, },
260 { "ai_socktype not supported", EAI_SOCKTYPE, },
261 { "System error returned in errno", EAI_SYSTEM, },
262 { "Invalid value for hints", EAI_BADHINTS, },
263 { "Resolved protocol is unknown", EAI_PROTOCOL, },
264 /* backward compatibility with userland code prior to 2553bis-02 */
265 { "Address family for hostname not supported", 1, },
266 { "No address associated with hostname", 7, },
267 { NULL, -1, },
258};
259
260/*
261 * XXX: Our res_*() is not thread-safe. So, we share lock between
262 * getaddrinfo() and getipnodeby*(). Still, we cannot use
263 * getaddrinfo() and getipnodeby*() in conjunction with other
264 * functions which call res_*().
265 */

--- 43 unchanged lines hidden (view full) ---

309 ((x) == (y) || (/*CONSTCOND*/(w) && ((x) == PF_UNSPEC || (y) == PF_UNSPEC)))
310#define MATCH(x, y, w) \
311 ((x) == (y) || (/*CONSTCOND*/(w) && ((x) == ANY || (y) == ANY)))
312
313char *
314gai_strerror(ecode)
315 int ecode;
316{
268};
269
270/*
271 * XXX: Our res_*() is not thread-safe. So, we share lock between
272 * getaddrinfo() and getipnodeby*(). Still, we cannot use
273 * getaddrinfo() and getipnodeby*() in conjunction with other
274 * functions which call res_*().
275 */

--- 43 unchanged lines hidden (view full) ---

319 ((x) == (y) || (/*CONSTCOND*/(w) && ((x) == PF_UNSPEC || (y) == PF_UNSPEC)))
320#define MATCH(x, y, w) \
321 ((x) == (y) || (/*CONSTCOND*/(w) && ((x) == ANY || (y) == ANY)))
322
323char *
324gai_strerror(ecode)
325 int ecode;
326{
317 if (ecode < 0 || ecode > EAI_MAX)
318 ecode = EAI_MAX;
319 return ai_errlist[ecode];
327 struct ai_errlist *p;
328
329 for (p = ai_errlist; p->str; p++) {
330 if (p->code == ecode)
331 return (char *)p->str;
332 }
320}
321
322void
323freeaddrinfo(ai)
324 struct addrinfo *ai;
325{
326 struct addrinfo *next;
327

--- 1773 unchanged lines hidden ---
333}
334
335void
336freeaddrinfo(ai)
337 struct addrinfo *ai;
338{
339 struct addrinfo *next;
340

--- 1773 unchanged lines hidden ---