8 #if __STDC_VERSION__ >= 199901L
9 #define __restrict restrict
10 #elif !defined(__GNUC__)
14 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
18 #define __NEED_socklen_t
19 #define __NEED_uint32_t
21 #include <bits/alltypes.h>
30 struct sockaddr *ai_addr;
32 struct addrinfo *ai_next;
35 #define IPPORT_RESERVED 1024
37 #define AI_PASSIVE 0x01
38 #define AI_CANONNAME 0x02
39 #define AI_NUMERICHOST 0x04
40 #define AI_V4MAPPED 0x08
42 #define AI_ADDRCONFIG 0x20
43 #define AI_NUMERICSERV 0x400
46 #define NI_NUMERICHOST 0x01
47 #define NI_NUMERICSERV 0x02
48 #define NI_NOFQDN 0x04
49 #define NI_NAMEREQD 0x08
51 /*#define NI_NUMERICSCOPE */
53 #define EAI_BADFLAGS -1
58 #define EAI_SOCKTYPE -7
59 #define EAI_SERVICE -8
60 #define EAI_MEMORY -10
61 #define EAI_SYSTEM -11
62 #define EAI_OVERFLOW -12
64 int getaddrinfo (const char *__restrict, const char *__restrict, const struct addrinfo *__restrict, struct addrinfo **__restrict);
65 void freeaddrinfo (struct addrinfo *);
66 int getnameinfo (const struct sockaddr *__restrict, socklen_t, char *__restrict, socklen_t, char *__restrict, socklen_t, int);
67 const char *gai_strerror(int);
70 /* Legacy functions follow (marked OBsolete in SUS) */
88 #define h_addr h_addr_list[0]
105 void sethostent (int);
106 void endhostent (void);
107 struct hostent *gethostent (void);
109 void setnetent (int);
110 void endnetent (void);
111 struct netent *getnetent (void);
112 struct netent *getnetbyaddr (uint32_t, int);
113 struct netent *getnetbyname (const char *);
115 void setservent (int);
116 void endservent (void);
117 struct servent *getservent (void);
118 struct servent *getservbyname (const char *, const char *);
119 struct servent *getservbyport (int, const char *);
121 void setprotoent (int);
122 void endprotoent (void);
123 struct protoent *getprotoent (void);
124 struct protoent *getprotobyname (const char *);
125 struct protoent *getprotobynumber (int);
127 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_POSIX_SOURCE) \
128 || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE < 200809L) \
129 || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE < 700)
130 struct hostent *gethostbyname (const char *);
131 struct hostent *gethostbyaddr (const void *, socklen_t, int);
133 __attribute__((const))
135 int *__h_errno_location(void);
136 #define h_errno (*__h_errno_location())
137 #define HOST_NOT_FOUND 1
139 #define NO_RECOVERY 3
143 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
144 const char *hstrerror(int);
145 int gethostbyname_r(const char *, struct hostent *, char *, size_t, struct hostent **, int *);
146 int gethostbyname2_r(const char *, int, struct hostent *, char *, size_t, struct hostent **, int *);
147 struct hostent *gethostbyname2(const char *, int);
148 int gethostbyaddr_r(const void *, socklen_t, int, struct hostent *, char *, size_t, struct hostent **, int *);
149 int getservbyport_r(int, const char *, struct servent *, char *, size_t, struct servent **);
150 int getservbyname_r(const char *, const char *, struct servent *, char *, size_t, struct servent **);
151 #define EAI_NODATA -5
152 #define EAI_ADDRFAMILY -9
153 #define EAI_INPROGRESS -100
154 #define EAI_CANCELED -101
155 #define EAI_NOTCANCELED -102
156 #define EAI_ALLDONE -103
157 #define EAI_INTR -104
158 #define EAI_IDN_ENCODE -105
159 #define NI_MAXHOST 255
160 #define NI_MAXSERV 32