1 /* 2 getinfos.h - definition of getaddrinfo(), getnameinfo() and related 3 functions for systems that lack it 4 note that these functions are implemented only for use 5 in cvsd and are probably incomplete for other purposes 6 7 Copyright (C) 2002 Arthur de Jong 8 9 This program is free software; you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation; either version 2, or (at your option) 12 any later version. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program; if not, write to the Free Software 21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 */ 23 24 25 #ifndef _GETINFOS_H 26 #define _GETINFOS_H 1 27 28 29 #include <unistd.h> 30 #include <sys/types.h> 31 #include <sys/socket.h> 32 33 34 /* errors for both getaddrinfo() and getnameinfo() */ 35 #define EAI_OK 0 36 #define EAI_SYSTEM -11 37 #define EAI_WRONGNODE 2 38 #define EAI_WRONSERVC 3 39 #define EAI_WRONGSOCK 4 40 #define EAI_HERR 5 41 42 /* macros for the ai_flags field */ 43 #define AI_PASSIVE 0x0001 44 45 /* macros for the getnameinf() flags parameter */ 46 #define NI_NUMERICHOST 0x0001 47 #define NI_NUMERICSERV 0x0002 48 49 /* macros for systems that don't have them */ 50 #ifndef AF_INET6 51 #define AF_INET6 -1 52 #endif /* not AF_INET6 */ 53 54 /* the structure used by getaddrinfo() for passing address information */ 55 struct addrinfo 56 { 57 int ai_flags; 58 int ai_family; 59 int ai_socktype; 60 int ai_protocol; 61 size_t ai_addrlen; 62 struct sockaddr *ai_addr; 63 char *ai_canonname; /* used nowhere */ 64 struct addrinfo *ai_next; 65 }; 66 67 68 /* very poor implementation, see getaddrinfo.c for details */ 69 int getaddrinfo(const char *node,const char *service, 70 const struct addrinfo *hints, 71 struct addrinfo **res); 72 73 74 /* poor implementation of getnameinfo() doing no name lookups */ 75 int getnameinfo(const struct sockaddr *sa,socklen_t salen, 76 char *host,size_t hostlen, 77 char *serv,size_t servlen,int flags); 78 79 80 /* free address information allocated by getaddrinfo */ 81 void freeaddrinfo(struct addrinfo *res); 82 83 84 /* translate an error codes returned by getaddrinfo() and 85 getnameinfo() to printable error strings */ 86 const char *gai_strerror(int errcode); 87 88 89 #endif /* not _GETINFOS_H */ 90