source: web/old/remctl-2.14/portable/getaddrinfo.h @ f6f3e91

web
Last change on this file since f6f3e91 was f6f3e91, checked in by Jessica B. Hamrick <jhamrick@…>, 15 years ago

Preserve directory hierarchy (not sure what happened to it)

  • Property mode set to 100644
File size: 2.7 KB
Line 
1/*
2 * Replacement implementation of getaddrinfo.
3 *
4 * This is an implementation of the getaddrinfo family of functions for
5 * systems that lack it, so that code can use getaddrinfo always.  It provides
6 * IPv4 support only; for IPv6 support, a native getaddrinfo implemenation is
7 * required.
8 *
9 * This file should generally be included by way of portable/socket.h rather
10 * than directly.
11 *
12 * Written by Russ Allbery <rra@stanford.edu>
13 * This work is hereby placed in the public domain by its author.
14 */
15
16#ifndef PORTABLE_GETADDRINFO_H
17#define PORTABLE_GETADDRINFO_H 1
18
19#include <config.h>
20#include <portable/macros.h>
21
22/* Skip this entire file if a system getaddrinfo was detected. */
23#ifndef HAVE_GETADDRINFO
24
25#include <sys/socket.h>
26
27/* The struct returned by getaddrinfo, from RFC 3493. */
28struct addrinfo {
29    int ai_flags;               /* AI_PASSIVE, AI_CANONNAME, .. */
30    int ai_family;              /* AF_xxx */
31    int ai_socktype;            /* SOCK_xxx */
32    int ai_protocol;            /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
33    socklen_t ai_addrlen;       /* Length of ai_addr */
34    char *ai_canonname;         /* Canonical name for nodename */
35    struct sockaddr *ai_addr;   /* Binary address */
36    struct addrinfo *ai_next;   /* Next structure in linked list */
37};
38
39/* Constants for ai_flags from RFC 3493, combined with binary or. */
40#define AI_PASSIVE      0x0001
41#define AI_CANONNAME    0x0002
42#define AI_NUMERICHOST  0x0004
43#define AI_NUMERICSERV  0x0008
44#define AI_V4MAPPED     0x0010
45#define AI_ALL          0x0020
46#define AI_ADDRCONFIG   0x0040
47
48/* Error return codes from RFC 3493. */
49#define EAI_AGAIN       1       /* Temporary name resolution failure */
50#define EAI_BADFLAGS    2       /* Invalid value in ai_flags parameter */
51#define EAI_FAIL        3       /* Permanent name resolution failure */
52#define EAI_FAMILY      4       /* Address family not recognized */
53#define EAI_MEMORY      5       /* Memory allocation failure */
54#define EAI_NONAME      6       /* nodename or servname unknown */
55#define EAI_SERVICE     7       /* Service not recognized for socket type */
56#define EAI_SOCKTYPE    8       /* Socket type not recognized */
57#define EAI_SYSTEM      9       /* System error occurred, see errno */
58#define EAI_OVERFLOW    10      /* An argument buffer overflowed */
59
60BEGIN_DECLS
61
62/* Function prototypes. */
63int getaddrinfo(const char *nodename, const char *servname,
64                const struct addrinfo *hints, struct addrinfo **res)
65    __attribute__((__visibility__("hidden")));
66void freeaddrinfo(struct addrinfo *ai)
67    __attribute__((__visibility__("hidden")));
68const char *gai_strerror(int ecode)
69    __attribute__((__visibility__("hidden")));
70
71END_DECLS
72
73#endif /* !HAVE_GETADDRINFO */
74#endif /* !PORTABLE_GETADDRINFO_H */
Note: See TracBrowser for help on using the repository browser.