9 #include <netinet/in.h>
11 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
13 #include <bits/alltypes.h>
22 struct sockaddr *ai_addr;
24 struct addrinfo *ai_next;
27 #define IPPORT_RESERVED 1024
29 #define AI_PASSIVE 0x01
30 #define AI_CANONNAME 0x02
31 #define AI_NUMERICHOST 0x04
32 #define AI_V4MAPPED 0x08
34 #define AI_ADDRCONFIG 0x20
35 #define AI_NUMERICSERV 0x400
38 #define NI_NUMERICHOST 0x01
39 #define NI_NUMERICSERV 0x02
40 #define NI_NOFQDN 0x04
41 #define NI_NAMEREQD 0x08
43 #define NI_NUMERICSCOPE 0x100
45 #define EAI_BADFLAGS -1
50 #define EAI_SOCKTYPE -7
51 #define EAI_SERVICE -8
52 #define EAI_MEMORY -10
53 #define EAI_SYSTEM -11
54 #define EAI_OVERFLOW -12
56 int getaddrinfo (const char *__restrict, const char *__restrict, const struct addrinfo *__restrict, struct addrinfo **__restrict);
57 void freeaddrinfo (struct addrinfo *);
58 int getnameinfo (const struct sockaddr *__restrict, socklen_t, char *__restrict, socklen_t, char *__restrict, socklen_t, int);
59 const char *gai_strerror(int);
62 /* Legacy functions follow (marked OBsolete in SUS) */
78 #define h_addr h_addr_list[0]
93 void sethostent (int);
94 void endhostent (void);
95 struct hostent *gethostent (void);
98 void endnetent (void);
99 struct netent *getnetent (void);
100 struct netent *getnetbyaddr (uint32_t, int);
101 struct netent *getnetbyname (const char *);
103 void setservent (int);
104 void endservent (void);
105 struct servent *getservent (void);
106 struct servent *getservbyname (const char *, const char *);
107 struct servent *getservbyport (int, const char *);
109 void setprotoent (int);
110 void endprotoent (void);
111 struct protoent *getprotoent (void);
112 struct protoent *getprotobyname (const char *);
113 struct protoent *getprotobynumber (int);
115 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_POSIX_SOURCE) \
116 || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE+0 < 200809L) \
117 || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700)
118 struct hostent *gethostbyname (const char *);
119 struct hostent *gethostbyaddr (const void *, socklen_t, int);
120 int *__h_errno_location(void);
121 #define h_errno (*__h_errno_location())
122 #define HOST_NOT_FOUND 1
124 #define NO_RECOVERY 3
126 #define NO_ADDRESS NO_DATA
129 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
130 void herror(const char *);
131 const char *hstrerror(int);
132 int gethostbyname_r(const char *, struct hostent *, char *, size_t, struct hostent **, int *);
133 int gethostbyname2_r(const char *, int, struct hostent *, char *, size_t, struct hostent **, int *);
134 struct hostent *gethostbyname2(const char *, int);
135 int gethostbyaddr_r(const void *, socklen_t, int, struct hostent *, char *, size_t, struct hostent **, int *);
136 int getservbyport_r(int, const char *, struct servent *, char *, size_t, struct servent **);
137 int getservbyname_r(const char *, const char *, struct servent *, char *, size_t, struct servent **);
138 #define EAI_NODATA -5
139 #define EAI_ADDRFAMILY -9
140 #define EAI_INPROGRESS -100
141 #define EAI_CANCELED -101
142 #define EAI_NOTCANCELED -102
143 #define EAI_ALLDONE -103
144 #define EAI_INTR -104
145 #define EAI_IDN_ENCODE -105
146 #define NI_MAXHOST 255
147 #define NI_MAXSERV 32