9 #include <netinet/in.h>
11 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
13 #include <bits/alltypes.h>
23 struct sockaddr *ai_addr;
25 struct addrinfo *ai_next;
28 #define IPPORT_RESERVED 1024
30 #define AI_PASSIVE 0x01
31 #define AI_CANONNAME 0x02
32 #define AI_NUMERICHOST 0x04
33 #define AI_V4MAPPED 0x08
35 #define AI_ADDRCONFIG 0x20
36 #define AI_NUMERICSERV 0x400
39 #define NI_NUMERICHOST 0x01
40 #define NI_NUMERICSERV 0x02
41 #define NI_NOFQDN 0x04
42 #define NI_NAMEREQD 0x08
44 /*#define NI_NUMERICSCOPE */
46 #define EAI_BADFLAGS -1
51 #define EAI_SOCKTYPE -7
52 #define EAI_SERVICE -8
53 #define EAI_MEMORY -10
54 #define EAI_SYSTEM -11
55 #define EAI_OVERFLOW -12
57 int getaddrinfo (const char *__restrict, const char *__restrict, const struct addrinfo *__restrict, struct addrinfo **__restrict);
58 void freeaddrinfo (struct addrinfo *);
59 int getnameinfo (const struct sockaddr *__restrict, socklen_t, char *__restrict, socklen_t, char *__restrict, socklen_t, int);
60 const char *gai_strerror(int);
63 /* Legacy functions follow (marked OBsolete in SUS) */
81 #define h_addr h_addr_list[0]
98 void sethostent (int);
99 void endhostent (void);
100 struct hostent *gethostent (void);
102 void setnetent (int);
103 void endnetent (void);
104 struct netent *getnetent (void);
105 struct netent *getnetbyaddr (uint32_t, int);
106 struct netent *getnetbyname (const char *);
108 void setservent (int);
109 void endservent (void);
110 struct servent *getservent (void);
111 struct servent *getservbyname (const char *, const char *);
112 struct servent *getservbyport (int, const char *);
114 void setprotoent (int);
115 void endprotoent (void);
116 struct protoent *getprotoent (void);
117 struct protoent *getprotobyname (const char *);
118 struct protoent *getprotobynumber (int);
120 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_POSIX_SOURCE) \
121 || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE+0 < 200809L) \
122 || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700)
123 struct hostent *gethostbyname (const char *);
124 struct hostent *gethostbyaddr (const void *, socklen_t, int);
126 __attribute__((const))
128 int *__h_errno_location(void);
129 #define h_errno (*__h_errno_location())
130 #define HOST_NOT_FOUND 1
132 #define NO_RECOVERY 3
134 #define NO_ADDRESS NO_DATA
137 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
138 void herror(const char *);
139 const char *hstrerror(int);
140 int gethostbyname_r(const char *, struct hostent *, char *, size_t, struct hostent **, int *);
141 int gethostbyname2_r(const char *, int, struct hostent *, char *, size_t, struct hostent **, int *);
142 struct hostent *gethostbyname2(const char *, int);
143 int gethostbyaddr_r(const void *, socklen_t, int, struct hostent *, char *, size_t, struct hostent **, int *);
144 int getservbyport_r(int, const char *, struct servent *, char *, size_t, struct servent **);
145 int getservbyname_r(const char *, const char *, struct servent *, char *, size_t, struct servent **);
146 #define EAI_NODATA -5
147 #define EAI_ADDRFAMILY -9
148 #define EAI_INPROGRESS -100
149 #define EAI_CANCELED -101
150 #define EAI_NOTCANCELED -102
151 #define EAI_ALLDONE -103
152 #define EAI_INTR -104
153 #define EAI_IDN_ENCODE -105
154 #define NI_MAXHOST 255
155 #define NI_MAXSERV 32