diff options
author | Simon Josefsson <simon@josefsson.org> | 2004-11-10 14:53:00 +0000 |
---|---|---|
committer | Simon Josefsson <simon@josefsson.org> | 2004-11-10 14:53:00 +0000 |
commit | f34b5ec45f70109f4d3d321ea17f996ff4b1c14d (patch) | |
tree | f50d16fab057af1c8f47c870aee7b4352719b5ea /lib/getaddrinfo.h | |
parent | c075153d3311410bd63b2212bfbe2f2f43f7e41a (diff) | |
download | gnulib-f34b5ec45f70109f4d3d321ea17f996ff4b1c14d.tar.gz |
Add getaddrinfo.
Diffstat (limited to 'lib/getaddrinfo.h')
-rw-r--r-- | lib/getaddrinfo.h | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/lib/getaddrinfo.h b/lib/getaddrinfo.h new file mode 100644 index 0000000000..59553234e9 --- /dev/null +++ b/lib/getaddrinfo.h @@ -0,0 +1,90 @@ +/* Get address information. + Copyright (C) 1996-2002, 2003, 2004 Free Software Foundation, Inc. + Contributed by Simon Josefsson <simon@josefsson.org>. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifndef GETADDRINFO_H +# define GETADDRINFO_H + +/* Get getaddrinfo declarations, if available. */ +# include <sys/socket.h> +# include <netdb.h> + +# if defined HAVE_GETADDRINFO && !HAVE_GETADDRINFO + +/* Get socklen_t, struct sockaddr. */ +# include <sys/types.h> + +/* Structure to contain information about address of a service provider. */ +struct addrinfo +{ + int ai_flags; /* Input flags. */ + int ai_family; /* Protocol family for socket. */ + int ai_socktype; /* Socket type. */ + int ai_protocol; /* Protocol for socket. */ + socklen_t ai_addrlen; /* Length of socket address. */ + struct sockaddr *ai_addr; /* Socket address for socket. */ + char *ai_canonname; /* Canonical name for service location. */ + struct addrinfo *ai_next; /* Pointer to next in list. */ +}; + +/* Possible values for `ai_flags' field in `addrinfo' structure. */ +# define AI_PASSIVE 0x0001 /* Socket address is intended for `bind'. */ +# define AI_CANONNAME 0x0002 /* Request for canonical name. */ +# define AI_NUMERICHOST 0x0004 /* Don't use name resolution. */ +# define AI_V4MAPPED 0x0008 /* IPv4 mapped addresses are acceptable. */ +# define AI_ALL 0x0010 /* Return IPv4 mapped and IPv6 addresses. */ +# define AI_ADDRCONFIG 0x0020 /* Use configuration of this host to choose + returned address type.. */ + +/* Error values for `getaddrinfo' function. */ +# define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */ +# define EAI_NONAME -2 /* NAME or SERVICE is unknown. */ +# define EAI_AGAIN -3 /* Temporary failure in name resolution. */ +# define EAI_FAIL -4 /* Non-recoverable failure in name res. */ +# define EAI_NODATA -5 /* No address associated with NAME. */ +# define EAI_FAMILY -6 /* `ai_family' not supported. */ +# define EAI_SOCKTYPE -7 /* `ai_socktype' not supported. */ +# define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */ +# define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */ +# define EAI_MEMORY -10 /* Memory allocation failure. */ +# define EAI_SYSTEM -11 /* System error returned in `errno'. */ +# define EAI_OVERFLOW -12 /* Argument buffer overflow. */ +# ifdef __USE_GNU +# define EAI_INPROGRESS -100 /* Processing request in progress. */ +# define EAI_CANCELED -101 /* Request canceled. */ +# define EAI_NOTCANCELED -102 /* Request not canceled. */ +# define EAI_ALLDONE -103 /* All requests done. */ +# define EAI_INTR -104 /* Interrupted by a signal. */ +# define EAI_IDN_ENCODE -105 /* IDN encoding failed. */ +# endif + +/* Translate name of a service location and/or a service name to set of + socket addresses. */ +extern int getaddrinfo (const char *restrict nodename, + const char *restrict servname, + const struct addrinfo *restrict hints, + struct addrinfo **restrict res); + +/* Free `addrinfo' structure AI including associated storage. */ +extern void freeaddrinfo (struct addrinfo *ai); + +/* Convert error return from getaddrinfo() to a string. */ +extern const char *gai_strerror (int ecode); + +# endif + +#endif /* GETADDRINFO_H */ |