/msys/packages/coreutils/5.97/lib/getaddrinfo.h

https://github.com/dscho/msys · C Header · 110 lines · 63 code · 11 blank · 36 comment · 3 complexity · 4456b3cdf2538f1c21304edde382ea39 MD5 · raw file

  1. /* Get address information.
  2. Copyright (C) 1996-2002, 2003, 2004, 2005 Free Software Foundation, Inc.
  3. Contributed by Simon Josefsson <simon@josefsson.org>.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software Foundation,
  14. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
  15. #ifndef GETADDRINFO_H
  16. # define GETADDRINFO_H
  17. /* sys/socket.h in i386-unknown-freebsd4.10 and
  18. powerpc-apple-darwin5.5 require sys/types.h, so include it first.
  19. Then we'll also get 'socklen_t' and 'struct sockaddr' which are
  20. used below. */
  21. # include <sys/types.h>
  22. /* Get all getaddrinfo related declarations, if available. */
  23. # include <sys/socket.h>
  24. # include <netdb.h>
  25. # ifndef HAVE_STRUCT_ADDRINFO
  26. /* Structure to contain information about address of a service provider. */
  27. struct addrinfo
  28. {
  29. int ai_flags; /* Input flags. */
  30. int ai_family; /* Protocol family for socket. */
  31. int ai_socktype; /* Socket type. */
  32. int ai_protocol; /* Protocol for socket. */
  33. socklen_t ai_addrlen; /* Length of socket address. */
  34. struct sockaddr *ai_addr; /* Socket address for socket. */
  35. char *ai_canonname; /* Canonical name for service location. */
  36. struct addrinfo *ai_next; /* Pointer to next in list. */
  37. };
  38. # endif
  39. /* Possible values for `ai_flags' field in `addrinfo' structure. */
  40. # ifndef AI_PASSIVE
  41. # define AI_PASSIVE 0x0001 /* Socket address is intended for `bind'. */
  42. # define AI_CANONNAME 0x0002 /* Request for canonical name. */
  43. # define AI_NUMERICHOST 0x0004 /* Don't use name resolution. */
  44. # define AI_V4MAPPED 0x0008 /* IPv4 mapped addresses are acceptable. */
  45. # define AI_ALL 0x0010 /* Return IPv4 mapped and IPv6 addresses. */
  46. # define AI_ADDRCONFIG 0x0020 /* Use configuration of this host to choose
  47. returned address type.. */
  48. # endif
  49. /* Error values for `getaddrinfo' function. */
  50. # ifndef EAI_BADFLAGS
  51. # define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */
  52. # define EAI_NONAME -2 /* NAME or SERVICE is unknown. */
  53. # define EAI_AGAIN -3 /* Temporary failure in name resolution. */
  54. # define EAI_FAIL -4 /* Non-recoverable failure in name res. */
  55. # define EAI_NODATA -5 /* No address associated with NAME. */
  56. # define EAI_FAMILY -6 /* `ai_family' not supported. */
  57. # define EAI_SOCKTYPE -7 /* `ai_socktype' not supported. */
  58. # define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */
  59. # define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */
  60. # define EAI_MEMORY -10 /* Memory allocation failure. */
  61. # define EAI_SYSTEM -11 /* System error returned in `errno'. */
  62. # define EAI_OVERFLOW -12 /* Argument buffer overflow. */
  63. # endif
  64. # ifdef __USE_GNU
  65. # ifndef EAI_INPROGRESS
  66. # define EAI_INPROGRESS -100 /* Processing request in progress. */
  67. # define EAI_CANCELED -101 /* Request canceled. */
  68. # define EAI_NOTCANCELED -102 /* Request not canceled. */
  69. # define EAI_ALLDONE -103 /* All requests done. */
  70. # define EAI_INTR -104 /* Interrupted by a signal. */
  71. # define EAI_IDN_ENCODE -105 /* IDN encoding failed. */
  72. # endif
  73. # endif
  74. # if !HAVE_DECL_GETADDRINFO
  75. /* Translate name of a service location and/or a service name to set of
  76. socket addresses.
  77. For more details, see the POSIX:2001 specification
  78. <http://www.opengroup.org/susv3xsh/getaddrinfo.html>. */
  79. extern int getaddrinfo (const char *restrict nodename,
  80. const char *restrict servname,
  81. const struct addrinfo *restrict hints,
  82. struct addrinfo **restrict res);
  83. # endif
  84. # if !HAVE_DECL_FREEADDRINFO
  85. /* Free `addrinfo' structure AI including associated storage.
  86. For more details, see the POSIX:2001 specification
  87. <http://www.opengroup.org/susv3xsh/getaddrinfo.html>. */
  88. extern void freeaddrinfo (struct addrinfo *ai);
  89. # endif
  90. # if !HAVE_DECL_GAI_STRERROR
  91. /* Convert error return from getaddrinfo() to a string.
  92. For more details, see the POSIX:2001 specification
  93. <http://www.opengroup.org/susv3xsh/gai_strerror.html>. */
  94. extern const char *gai_strerror (int ecode);
  95. # endif
  96. #endif /* GETADDRINFO_H */