8 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
12 #define __NEED_socklen_t
13 #define __NEED_uint32_t
15 #include <bits/alltypes.h>
24 struct sockaddr *ai_addr;
26 struct addrinfo *ai_next;
29 #define IPPORT_RESERVED 1024
31 #define AI_PASSIVE 0x01
32 #define AI_CANONNAME 0x02
33 #define AI_NUMERICHOST 0x04
34 #define AI_V4MAPPED 0x08
36 #define AI_ADDRCONFIG 0x20
37 #define AI_NUMERICSERV 0x400
40 #define NI_NUMERICHOST 0x01
41 #define NI_NUMERICSERV 0x02
42 #define NI_NOFQDN 0x04
43 #define NI_NAMEREQD 0x08
45 /*#define NI_NUMERICSCOPE */
47 #define EAI_BADFLAGS -1
52 #define EAI_SOCKTYPE -7
53 #define EAI_SERVICE -8
54 #define EAI_MEMORY -10
55 #define EAI_SYSTEM -11
56 #define EAI_OVERFLOW -12
58 int getaddrinfo (const char *, const char *, const struct addrinfo *, struct addrinfo **);
59 void freeaddrinfo (struct addrinfo *);
60 int getnameinfo (const struct sockaddr *, socklen_t, char *, socklen_t, char *, socklen_t, int);
61 const char *gai_strerror(int);
64 /* Legacy functions follow (marked OBsolete in SUS) */
82 #define h_addr h_addr_list[0]
99 void sethostent (int);
100 void endhostent (void);
101 struct hostent *gethostent (void);
103 void setnetent (int);
104 void endnetent (void);
105 struct netent *getnetent (void);
106 struct netent *getnetbyaddr (uint32_t, int);
107 struct netent *getnetbyname (const char *);
109 void setservent (int);
110 void endservent (void);
111 struct servent *getservent (void);
112 struct servent *getservbyname (const char *, const char *);
113 struct servent *getservbyport (int, const char *);
115 void setprotoent (int);
116 void endprotoent (void);
117 struct protoent *getprotoent (void);
118 struct protoent *getprotobyname (const char *);
119 struct protoent *getprotobynumber (int);
121 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_POSIX_SOURCE) \
122 || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE < 200809L) \
123 || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE < 700)
124 struct hostent *gethostbyname (const char *);
125 struct hostent *gethostbyaddr (const void *, socklen_t, int);
127 __attribute__((const))
129 int *__h_errno_location(void);
130 #define h_errno (*__h_errno_location())
131 #define HOST_NOT_FOUND 1
133 #define NO_RECOVERY 3
137 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
138 const char *hstrerror(int);
139 int gethostbyname_r(const char *, struct hostent *, char *, size_t, struct hostent **, int *);
140 int gethostbyname2_r(const char *, int, struct hostent *, char *, size_t, struct hostent **, int *);
141 struct hostent *gethostbyname2(const char *, int);
142 int gethostbyaddr_r(const void *, socklen_t, int, struct hostent *, char *, size_t, struct hostent **, int *);
143 int getservbyport_r(int, const char *, struct servent *, char *, size_t, struct servent **);
144 int getservbyname_r(const char *, const char *, struct servent *, char *, size_t, struct servent **);
145 #define EAI_NODATA -5
146 #define EAI_ADDRFAMILY -9
147 #define EAI_INPROGRESS -100
148 #define EAI_CANCELED -101
149 #define EAI_NOTCANCELED -102
150 #define EAI_ALLDONE -103
151 #define EAI_INTR -104
152 #define EAI_IDN_ENCODE -105
153 #define NI_MAXHOST 255
154 #define NI_MAXSERV 32