PageRenderTime 65ms CodeModel.GetById 42ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/gnutls/gnutls-2.2.0/gl/getaddrinfo.h

https://bitbucket.org/thelearninglabs/uclinux-distro-tll-public
C Header | 155 lines | 90 code | 15 blank | 50 comment | 0 complexity | 81627ba4e21246b3c54b6a2cb6fa91cc MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause, MPL-2.0-no-copyleft-exception, LGPL-3.0, Unlicense, GPL-2.0, GPL-3.0, CC-BY-SA-3.0, AGPL-1.0, ISC, MIT, 0BSD, LGPL-2.0
  1. /* Get address information.
  2. Copyright (C) 1996-2002, 2003, 2004, 2005, 2006
  3. Free Software Foundation, Inc.
  4. Contributed by Simon Josefsson <simon@josefsson.org>.
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3, or (at your option)
  8. any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software Foundation,
  15. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
  16. #ifndef GETADDRINFO_H
  17. #define GETADDRINFO_H
  18. /* sys/socket.h in i386-unknown-freebsd4.10 and
  19. powerpc-apple-darwin5.5 require sys/types.h, so include it first.
  20. Then we'll also get 'socklen_t' and 'struct sockaddr' which are
  21. used below. */
  22. #include <sys/types.h>
  23. /* Get all getaddrinfo related declarations, if available. */
  24. #include <sys/socket.h>
  25. #ifdef HAVE_NETDB_H
  26. # include <netdb.h>
  27. #endif
  28. #ifndef HAVE_STRUCT_ADDRINFO
  29. /* Structure to contain information about address of a service provider. */
  30. struct addrinfo
  31. {
  32. int ai_flags; /* Input flags. */
  33. int ai_family; /* Protocol family for socket. */
  34. int ai_socktype; /* Socket type. */
  35. int ai_protocol; /* Protocol for socket. */
  36. socklen_t ai_addrlen; /* Length of socket address. */
  37. struct sockaddr *ai_addr; /* Socket address for socket. */
  38. char *ai_canonname; /* Canonical name for service location. */
  39. struct addrinfo *ai_next; /* Pointer to next in list. */
  40. };
  41. #endif
  42. /* Possible values for `ai_flags' field in `addrinfo' structure. */
  43. #ifndef AI_PASSIVE
  44. # define AI_PASSIVE 0x0001 /* Socket address is intended for `bind'. */
  45. #endif
  46. #ifndef AI_CANONNAME
  47. # define AI_CANONNAME 0x0002 /* Request for canonical name. */
  48. #endif
  49. #ifndef AI_NUMERICSERV
  50. # define AI_NUMERICSERV 0x0400 /* Don't use name resolution. */
  51. #endif
  52. #if 0
  53. /* The commented out definitions below are not yet implemented in the
  54. GNULIB getaddrinfo() replacement, so are not yet needed and may, in fact,
  55. cause conflicts on systems with a getaddrinfo() function which does not
  56. define them.
  57. If they are restored, be sure to protect the definitions with #ifndef. */
  58. #define AI_NUMERICHOST 0x0004 /* Don't use name resolution. */
  59. #define AI_V4MAPPED 0x0008 /* IPv4 mapped addresses are acceptable. */
  60. #define AI_ALL 0x0010 /* Return IPv4 mapped and IPv6 addresses. */
  61. #define AI_ADDRCONFIG 0x0020 /* Use configuration of this host to choose
  62. returned address type.. */
  63. #endif /* 0 */
  64. /* Error values for `getaddrinfo' function. */
  65. #ifndef EAI_BADFLAGS
  66. # define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */
  67. # define EAI_NONAME -2 /* NAME or SERVICE is unknown. */
  68. # define EAI_AGAIN -3 /* Temporary failure in name resolution. */
  69. # define EAI_FAIL -4 /* Non-recoverable failure in name res. */
  70. # define EAI_NODATA -5 /* No address associated with NAME. */
  71. # define EAI_FAMILY -6 /* `ai_family' not supported. */
  72. # define EAI_SOCKTYPE -7 /* `ai_socktype' not supported. */
  73. # define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */
  74. # define EAI_MEMORY -10 /* Memory allocation failure. */
  75. #endif
  76. #ifndef EAI_OVERFLOW
  77. /* Not defined on mingw32. */
  78. # define EAI_OVERFLOW -12 /* Argument buffer overflow. */
  79. #endif
  80. #ifndef EAI_ADDRFAMILY
  81. /* Not defined on mingw32. */
  82. # define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */
  83. #endif
  84. #ifndef EAI_SYSTEM
  85. /* Not defined on mingw32. */
  86. # define EAI_SYSTEM -11 /* System error returned in `errno'. */
  87. #endif
  88. #ifdef __USE_GNU
  89. # ifndef EAI_INPROGRESS
  90. # define EAI_INPROGRESS -100 /* Processing request in progress. */
  91. # define EAI_CANCELED -101 /* Request canceled. */
  92. # define EAI_NOTCANCELED -102 /* Request not canceled. */
  93. # define EAI_ALLDONE -103 /* All requests done. */
  94. # define EAI_INTR -104 /* Interrupted by a signal. */
  95. # define EAI_IDN_ENCODE -105 /* IDN encoding failed. */
  96. # endif
  97. #endif
  98. #if !HAVE_DECL_GETADDRINFO
  99. /* Translate name of a service location and/or a service name to set of
  100. socket addresses.
  101. For more details, see the POSIX:2001 specification
  102. <http://www.opengroup.org/susv3xsh/getaddrinfo.html>. */
  103. extern int getaddrinfo (const char *restrict nodename,
  104. const char *restrict servname,
  105. const struct addrinfo *restrict hints,
  106. struct addrinfo **restrict res);
  107. #endif
  108. #if !HAVE_DECL_FREEADDRINFO
  109. /* Free `addrinfo' structure AI including associated storage.
  110. For more details, see the POSIX:2001 specification
  111. <http://www.opengroup.org/susv3xsh/getaddrinfo.html>. */
  112. extern void freeaddrinfo (struct addrinfo *ai);
  113. #endif
  114. #if !HAVE_DECL_GAI_STRERROR
  115. /* Convert error return from getaddrinfo() to a string.
  116. For more details, see the POSIX:2001 specification
  117. <http://www.opengroup.org/susv3xsh/gai_strerror.html>. */
  118. extern const char *gai_strerror (int ecode);
  119. #endif
  120. #if !HAVE_DECL_GETNAMEINFO
  121. /* Convert socket address to printable node and service names.
  122. For more details, see the POSIX:2001 specification
  123. <http://www.opengroup.org/susv3xsh/getnameinfo.html>. */
  124. extern int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen,
  125. char *restrict node, socklen_t nodelen,
  126. char *restrict service, socklen_t servicelen,
  127. int flags);
  128. #endif
  129. /* Possible flags for getnameinfo. */
  130. #ifndef NI_NUMERICHOST
  131. # define NI_NUMERICHOST 1
  132. #endif
  133. #ifndef NI_NUMERICSERV
  134. # define NI_NUMERICSERV 2
  135. #endif
  136. #endif /* GETADDRINFO_H */