diff options
author | Arch Librarian <arch@canonical.com> | 2004-09-20 16:53:50 +0000 |
---|---|---|
committer | Arch Librarian <arch@canonical.com> | 2004-09-20 16:53:50 +0000 |
commit | 934b6582b4518630a050c8b84853b8e78ed87905 (patch) | |
tree | a94e4b6fb6188311080355b6184bd20939143b99 /methods/rfc2553emu.h | |
parent | ab559b358d7c390ac63bfcf8d526ca44761aafc5 (diff) |
Changed to using rfc2553 name resolution for http
Author: jgg
Date: 1999-05-25 05:56:24 GMT
Changed to using rfc2553 name resolution for http
Diffstat (limited to 'methods/rfc2553emu.h')
-rw-r--r-- | methods/rfc2553emu.h | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/methods/rfc2553emu.h b/methods/rfc2553emu.h new file mode 100644 index 000000000..e24e7a3c1 --- /dev/null +++ b/methods/rfc2553emu.h @@ -0,0 +1,85 @@ +// -*- mode: cpp; mode: fold -*- +// Description /*{{{*/ +// $Id: rfc2553emu.h,v 1.1 1999/05/25 05:56:24 jgg Exp $ +/* ###################################################################### + + RFC 2553 Emulation - Provides emulation for RFC 2553 getaddrinfo, + freeaddrinfo and getnameinfo + + These functions are necessary to write portable protocol independent + networking. They transparently support IPv4, IPv6 and probably many + other protocols too. This implementation is needed when the host does + not support these standards. It implements a simple wrapper that + basically supports only IPv4. + + Perfect emulation is not provided, but it is passable.. + + Originally written by Jason Gunthorpe <jgg@debian.org> and placed into + the Public Domain, do with it what you will. + + ##################################################################### */ + /*}}}*/ +#ifndef RFC2553EMU_H +#define RFC2553EMU_H + +#include <netdb.h> +#include <sys/types.h> +#include <sys/socket.h> + +// Autosense getaddrinfo +#if defined(AI_PASSIVE) && defined(EAI_NONAME) +#define HAVE_GETADDRINFO +#endif + +// getaddrinfo support? +#ifndef HAVE_GETADDRINFO + #error Boink + + // Renamed to advoid type clashing.. (for debugging) + struct addrinfo_emu + { + int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */ + int ai_family; /* PF_xxx */ + int ai_socktype; /* SOCK_xxx */ + int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ + size_t ai_addrlen; /* length of ai_addr */ + char *ai_canonname; /* canonical name for nodename */ + struct sockaddr *ai_addr; /* binary address */ + struct addrinfo *ai_next; /* next structure in linked list */ + }; + #define addinfo addrinfo_emu + + int getaddrinfo(const char *nodename, const char *servname, + const struct addrinfo *hints, + struct addrinfo **res); + void freeaddrinfo(struct addrinfo *ai); + + #ifndef AI_PASSIVE + #define AI_PASSIVE (1<<1) + #endif + + #ifndef EAI_NONAME + #define EAI_NONAME -1 + #define EAI_AGAIN -2 + #define EAI_FAIL -3 + #define EAI_NODATA -4 + #define EAI_FAMILY -5 + #define EAI_SOCKTYPE -6 + #define EAI_SERVICE -7 + #define EAI_ADDRFAMILY -8 + #define EAI_ADDRFAMILY -8 + #define EAI_SYSTEM -10 + #endif + +#endif + +// getnameinfo support (glibc2.0 has getaddrinfo only) +#ifndef HAVE_GETNAMEINFO + + int getnameinfo(const struct sockaddr *sa, socklen_t salen, + char *host, size_t hostlen, + char *serv, size_t servlen, + int flags); +#endif + +#endif |