blob: 6e181b6e173b858354ad49af82b79ef5ed93495e [file] [log] [blame]
Rich Felker0b44a032011-02-12 00:22:29 -05001#ifndef _NETDB_H
2#define _NETDB_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#ifdef _GNU_SOURCE
9#define __NEED_size_t
10#endif
11
12#define __NEED_socklen_t
13#define __NEED_uint32_t
14
15#include <bits/alltypes.h>
16
17struct addrinfo
18{
19 int ai_flags;
20 int ai_family;
21 int ai_socktype;
22 int ai_protocol;
23 socklen_t ai_addrlen;
24 struct sockaddr *ai_addr;
25 char *ai_canonname;
26 struct addrinfo *ai_next;
27};
28
29#define IPPORT_RESERVED 1024
30
31#define AI_PASSIVE 0x01
32#define AI_CANONNAME 0x02
33#define AI_NUMERICHOST 0x04
34#define AI_V4MAPPED 0x08
35#define AI_ALL 0x10
36#define AI_ADDRCONFIG 0x20
37#define AI_NUMERICSERV 0x400
38
39
40#define NI_NUMERICHOST 0x01
41#define NI_NUMERICSERV 0x02
42#define NI_NOFQDN 0x04
43#define NI_NAMEREQD 0x08
44#define NI_DGRAM 0x10
45/*#define NI_NUMERICSCOPE */
46
47#define NI_MAXHOST 255
48#define NI_MAXSERV 32
49
50#define EAI_BADFLAGS -1
51#define EAI_NONAME -2
52#define EAI_AGAIN -3
53#define EAI_FAIL -4
54#define EAI_FAMILY -6
55#define EAI_SOCKTYPE -7
56#define EAI_SERVICE -8
57#define EAI_MEMORY -10
58#define EAI_SYSTEM -11
59#define EAI_OVERFLOW -12
60
61int getaddrinfo (const char *, const char *, const struct addrinfo *, struct addrinfo **);
62void freeaddrinfo (struct addrinfo *);
63int getnameinfo (const struct sockaddr *, socklen_t, char *, socklen_t, char *, socklen_t, int);
64const char *gai_strerror(int);
65
66
67/* Legacy functions follow (marked OBsolete in SUS) */
68
69struct netent
70{
71 char *n_name;
72 char **n_aliases;
73 int n_addrtype;
74 uint32_t n_net;
75};
76
77struct hostent
78{
79 char *h_name;
80 char **h_aliases;
81 int h_addrtype;
82 int h_length;
83 char **h_addr_list;
84};
85#define h_addr h_addr_list[0]
86
87struct servent
88{
89 char *s_name;
90 char **s_aliases;
91 int s_port;
92 char *s_proto;
93};
94
95struct protoent
96{
97 char *p_name;
98 char **p_aliases;
99 int p_proto;
100};
101
102extern int h_errno;
103
104#define HOST_NOT_FOUND 1
105#define TRY_AGAIN 2
106#define NO_RECOVERY 3
107#define NO_DATA 4
108
109void sethostent (int);
110void endhostent (void);
111struct hostent *gethostent (void);
112struct hostent *gethostbyaddr (const void *, socklen_t, int);
113struct hostent *gethostbyname (const char *);
114
115void setnetent (int);
116void endnetent (void);
117struct netent *getnetent (void);
118struct netent *getnetbyaddr (uint32_t, int);
119struct netent *getnetbyname (const char *);
120
121void setservent (int);
122void endservent (void);
123struct servent *getservent (void);
124struct servent *getservbyname (const char *, const char *);
125struct servent *getservbyport (int, const char *);
126
127void setprotoent (int);
128void endprotoent (void);
129struct protoent *getprotoent (void);
130struct protoent *getprotobyname (const char *);
131struct protoent *getprotobynumber (int);
132
133#ifdef _GNU_SOURCE
134const char *hstrerror(int);
135int gethostbyname_r(const char *, struct hostent *, char *, size_t, struct hostent **, int *);
136int gethostbyname2_r(const char *, int, struct hostent *, char *, size_t, struct hostent **, int *);
137struct hostent *gethostbyname2(const char *, int);
138int gethostbyaddr_r(const void *, socklen_t, int, struct hostent *, char *, size_t, struct hostent **, int *);
139int getservbyport_r(int, const char *, struct servent *, char *, size_t, struct servent **);
140int getservbyname_r(const char *, const char *, struct servent *, char *, size_t, struct servent **);
Rich Felker7db6a872012-05-12 23:31:52 -0400141#define EAI_NODATA -5
142#define EAI_ADDRFAMILY -9
143#define EAI_INPROGRESS -100
144#define EAI_CANCELED -101
145#define EAI_NOTCANCELED -102
146#define EAI_ALLDONE -103
147#define EAI_INTR -104
148#define EAI_IDN_ENCODE -105
Rich Felker0b44a032011-02-12 00:22:29 -0500149#endif
150
151
152#ifdef __cplusplus
153}
154#endif
155
156#endif