Back to index

nagios-plugins  1.4.16
netdb.in.h
Go to the documentation of this file.
00001 /* Provide a netdb.h header file for systems lacking it (read: MinGW).
00002    Copyright (C) 2008-2010 Free Software Foundation, Inc.
00003    Written by Simon Josefsson.
00004 
00005    This program is free software; you can redistribute it and/or modify
00006    it under the terms of the GNU General Public License as published by
00007    the Free Software Foundation; either version 3, or (at your option)
00008    any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013    GNU General Public License for more details.
00014 
00015    You should have received a copy of the GNU General Public License
00016    along with this program; if not, write to the Free Software Foundation,
00017    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
00018 
00019 /* This file is supposed to be used on platforms that lack <netdb.h>.
00020    It is intended to provide definitions and prototypes needed by an
00021    application.  */
00022 
00023 #ifndef _GL_NETDB_H
00024 
00025 #if __GNUC__ >= 3
00026 @PRAGMA_SYSTEM_HEADER@
00027 #endif
00028 
00029 #if @HAVE_NETDB_H@
00030 
00031 /* The include_next requires a split double-inclusion guard.  */
00032 # @INCLUDE_NEXT@ @NEXT_NETDB_H@
00033 
00034 #endif
00035 
00036 #ifndef _GL_NETDB_H
00037 #define _GL_NETDB_H
00038 
00039 /* Get netdb.h definitions such as struct hostent for MinGW.  */
00040 #include <sys/socket.h>
00041 
00042 /* The definition of _GL_ARG_NONNULL is copied here.  */
00043 
00044 /* The definition of _GL_WARN_ON_USE is copied here.  */
00045 
00046 /* Declarations for a platform that lacks <netdb.h>, or where it is
00047    incomplete.  */
00048 
00049 #if @GNULIB_GETADDRINFO@
00050 
00051 # if !@HAVE_STRUCT_ADDRINFO@
00052 
00053 /* Structure to contain information about address of a service provider.  */
00054 struct addrinfo
00055 {
00056   int ai_flags;                 /* Input flags.  */
00057   int ai_family;                /* Protocol family for socket.  */
00058   int ai_socktype;              /* Socket type.  */
00059   int ai_protocol;              /* Protocol for socket.  */
00060   socklen_t ai_addrlen;         /* Length of socket address.  */
00061   struct sockaddr *ai_addr;     /* Socket address for socket.  */
00062   char *ai_canonname;           /* Canonical name for service location.  */
00063   struct addrinfo *ai_next;     /* Pointer to next in list.  */
00064 };
00065 # endif
00066 
00067 /* Possible values for `ai_flags' field in `addrinfo' structure.  */
00068 # ifndef AI_PASSIVE
00069 #  define AI_PASSIVE    0x0001  /* Socket address is intended for `bind'.  */
00070 # endif
00071 # ifndef AI_CANONNAME
00072 #  define AI_CANONNAME  0x0002  /* Request for canonical name.  */
00073 # endif
00074 # ifndef AI_NUMERICSERV
00075 #  define AI_NUMERICSERV        0x0400  /* Don't use name resolution.  */
00076 # endif
00077 
00078 # if 0
00079 #  define AI_NUMERICHOST        0x0004  /* Don't use name resolution.  */
00080 # endif
00081 
00082 /* These symbolic constants are required to be present by POSIX, but
00083    our getaddrinfo replacement doesn't use them (yet).  Setting them
00084    to 0 on systems that doesn't have them avoids causing problems for
00085    system getaddrinfo implementations that would be confused by
00086    unknown values.  */
00087 # ifndef AI_V4MAPPED
00088 #  define AI_V4MAPPED    0 /* 0x0008: IPv4 mapped addresses are acceptable.  */
00089 # endif
00090 # ifndef AI_ALL
00091 #  define AI_ALL         0 /* 0x0010: Return IPv4 mapped and IPv6 addresses. */
00092 # endif
00093 # ifndef AI_ADDRCONFIG
00094 #  define AI_ADDRCONFIG  0 /* 0x0020: Use configuration of this host to choose
00095                                       returned address type.  */
00096 # endif
00097 
00098 /* Error values for `getaddrinfo' function.  */
00099 # ifndef EAI_BADFLAGS
00100 #  define EAI_BADFLAGS    -1    /* Invalid value for `ai_flags' field.  */
00101 #  define EAI_NONAME      -2    /* NAME or SERVICE is unknown.  */
00102 #  define EAI_AGAIN       -3    /* Temporary failure in name resolution.  */
00103 #  define EAI_FAIL        -4    /* Non-recoverable failure in name res.  */
00104 #  define EAI_NODATA      -5    /* No address associated with NAME.  */
00105 #  define EAI_FAMILY      -6    /* `ai_family' not supported.  */
00106 #  define EAI_SOCKTYPE    -7    /* `ai_socktype' not supported.  */
00107 #  define EAI_SERVICE     -8    /* SERVICE not supported for `ai_socktype'.  */
00108 #  define EAI_MEMORY      -10   /* Memory allocation failure.  */
00109 # endif
00110 
00111 /* Since EAI_NODATA is deprecated by RFC3493, some systems (at least
00112    FreeBSD, which does define EAI_BADFLAGS) have removed the definition
00113    in favor of EAI_NONAME.  */
00114 # if !defined EAI_NODATA && defined EAI_NONAME
00115 #  define EAI_NODATA EAI_NONAME
00116 # endif
00117 
00118 # ifndef EAI_OVERFLOW
00119 /* Not defined on mingw32 and Haiku. */
00120 #  define EAI_OVERFLOW    -12   /* Argument buffer overflow.  */
00121 # endif
00122 # ifndef EAI_ADDRFAMILY
00123 /* Not defined on mingw32. */
00124 #  define EAI_ADDRFAMILY  -9    /* Address family for NAME not supported.  */
00125 # endif
00126 # ifndef EAI_SYSTEM
00127 /* Not defined on mingw32. */
00128 #  define EAI_SYSTEM      -11   /* System error returned in `errno'.  */
00129 # endif
00130 
00131 # if 0
00132 /* The commented out definitions below are not yet implemented in the
00133    GNULIB getaddrinfo() replacement, so are not yet needed.
00134 
00135    If they are restored, be sure to protect the definitions with #ifndef.  */
00136 #  ifndef EAI_INPROGRESS
00137 #   define EAI_INPROGRESS       -100    /* Processing request in progress.  */
00138 #   define EAI_CANCELED         -101    /* Request canceled.  */
00139 #   define EAI_NOTCANCELED      -102    /* Request not canceled.  */
00140 #   define EAI_ALLDONE          -103    /* All requests done.  */
00141 #   define EAI_INTR             -104    /* Interrupted by a signal.  */
00142 #   define EAI_IDN_ENCODE       -105    /* IDN encoding failed.  */
00143 #  endif
00144 # endif
00145 
00146 # if !@HAVE_DECL_GETADDRINFO@
00147 /* Translate name of a service location and/or a service name to set of
00148    socket addresses.
00149    For more details, see the POSIX:2001 specification
00150    <http://www.opengroup.org/susv3xsh/getaddrinfo.html>.  */
00151 extern int getaddrinfo (const char *restrict nodename,
00152                         const char *restrict servname,
00153                         const struct addrinfo *restrict hints,
00154                         struct addrinfo **restrict res)
00155      _GL_ARG_NONNULL ((4));
00156 # endif
00157 
00158 # if !@HAVE_DECL_FREEADDRINFO@
00159 /* Free `addrinfo' structure AI including associated storage.
00160    For more details, see the POSIX:2001 specification
00161    <http://www.opengroup.org/susv3xsh/getaddrinfo.html>.  */
00162 extern void freeaddrinfo (struct addrinfo *ai) _GL_ARG_NONNULL ((1));
00163 # endif
00164 
00165 # if !@HAVE_DECL_GAI_STRERROR@
00166 /* Convert error return from getaddrinfo() to a string.
00167    For more details, see the POSIX:2001 specification
00168    <http://www.opengroup.org/susv3xsh/gai_strerror.html>.  */
00169 extern const char *gai_strerror (int ecode);
00170 # endif
00171 
00172 # if !@HAVE_DECL_GETNAMEINFO@
00173 /* Convert socket address to printable node and service names.
00174    For more details, see the POSIX:2001 specification
00175    <http://www.opengroup.org/susv3xsh/getnameinfo.html>.  */
00176 extern int getnameinfo (const struct sockaddr *restrict sa, socklen_t salen,
00177                         char *restrict node, socklen_t nodelen,
00178                         char *restrict service, socklen_t servicelen,
00179                         int flags)
00180      _GL_ARG_NONNULL ((1));
00181 # endif
00182 
00183 /* Possible flags for getnameinfo.  */
00184 # ifndef NI_NUMERICHOST
00185 #  define NI_NUMERICHOST 1
00186 # endif
00187 # ifndef NI_NUMERICSERV
00188 #  define NI_NUMERICSERV 2
00189 # endif
00190 
00191 #elif defined GNULIB_POSIXCHECK
00192 
00193 # undef getaddrinfo
00194 # if HAVE_RAW_DECL_GETADDRINFO
00195 _GL_WARN_ON_USE (getaddrinfo, "getaddrinfo is unportable - "
00196                  "use gnulib module getaddrinfo for portability");
00197 # endif
00198 
00199 # undef freeaddrinfo
00200 # if HAVE_RAW_DECL_FREEADDRINFO
00201 _GL_WARN_ON_USE (freeaddrinfo, "freeaddrinfo is unportable - "
00202                  "use gnulib module getaddrinfo for portability");
00203 # endif
00204 
00205 # undef gai_strerror
00206 # if HAVE_RAW_DECL_GAI_STRERROR
00207 _GL_WARN_ON_USE (gai_strerror, "gai_strerror is unportable - "
00208                  "use gnulib module getaddrinfo for portability");
00209 # endif
00210 
00211 # undef getnameinfo
00212 # if HAVE_RAW_DECL_GETNAMEINFO
00213 _GL_WARN_ON_USE (getnameinfo, "getnameinfo is unportable - "
00214                  "use gnulib module getaddrinfo for portability");
00215 # endif
00216 
00217 #endif
00218 
00219 #endif /* _GL_NETDB_H */
00220 #endif /* _GL_NETDB_H */