OLD | NEW |
1 #ifndef»_NETDB_H | 1 #ifndef _NETDB_H |
2 #define»_NETDB_H | 2 #define _NETDB_H |
3 | 3 |
4 #ifdef __cplusplus | 4 #ifdef __cplusplus |
5 extern "C" { | 5 extern "C" { |
6 #endif | 6 #endif |
7 | 7 |
8 #include <features.h> | 8 #include <features.h> |
9 #include <netinet/in.h> | 9 #include <netinet/in.h> |
10 | 10 |
11 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) | 11 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) |
12 #define __NEED_size_t | 12 #define __NEED_size_t |
13 #include <bits/alltypes.h> | 13 #include <bits/alltypes.h> |
14 #endif | 14 #endif |
15 | 15 |
16 struct addrinfo | 16 struct addrinfo { |
17 { | 17 int ai_flags; |
18 » int ai_flags; | 18 int ai_family; |
19 » int ai_family; | 19 int ai_socktype; |
20 » int ai_socktype; | 20 int ai_protocol; |
21 » int ai_protocol; | 21 socklen_t ai_addrlen; |
22 » socklen_t ai_addrlen; | 22 struct sockaddr* ai_addr; |
23 » struct sockaddr *ai_addr; | 23 char* ai_canonname; |
24 » char *ai_canonname; | 24 struct addrinfo* ai_next; |
25 » struct addrinfo *ai_next; | |
26 }; | 25 }; |
27 | 26 |
28 #define IPPORT_RESERVED 1024 | 27 #define IPPORT_RESERVED 1024 |
29 | 28 |
30 #define AI_PASSIVE 0x01 | 29 #define AI_PASSIVE 0x01 |
31 #define AI_CANONNAME 0x02 | 30 #define AI_CANONNAME 0x02 |
32 #define AI_NUMERICHOST 0x04 | 31 #define AI_NUMERICHOST 0x04 |
33 #define AI_V4MAPPED 0x08 | 32 #define AI_V4MAPPED 0x08 |
34 #define AI_ALL 0x10 | 33 #define AI_ALL 0x10 |
35 #define AI_ADDRCONFIG 0x20 | 34 #define AI_ADDRCONFIG 0x20 |
36 #define AI_NUMERICSERV 0x400 | 35 #define AI_NUMERICSERV 0x400 |
37 | 36 |
38 | 37 #define NI_NUMERICHOST 0x01 |
39 #define NI_NUMERICHOST 0x01 | 38 #define NI_NUMERICSERV 0x02 |
40 #define NI_NUMERICSERV 0x02 | 39 #define NI_NOFQDN 0x04 |
41 #define NI_NOFQDN 0x04 | 40 #define NI_NAMEREQD 0x08 |
42 #define NI_NAMEREQD 0x08 | 41 #define NI_DGRAM 0x10 |
43 #define NI_DGRAM 0x10 | |
44 #define NI_NUMERICSCOPE 0x100 | 42 #define NI_NUMERICSCOPE 0x100 |
45 | 43 |
46 #define EAI_BADFLAGS -1 | 44 #define EAI_BADFLAGS -1 |
47 #define EAI_NONAME -2 | 45 #define EAI_NONAME -2 |
48 #define EAI_AGAIN -3 | 46 #define EAI_AGAIN -3 |
49 #define EAI_FAIL -4 | 47 #define EAI_FAIL -4 |
50 #define EAI_FAMILY -6 | 48 #define EAI_FAMILY -6 |
51 #define EAI_SOCKTYPE -7 | 49 #define EAI_SOCKTYPE -7 |
52 #define EAI_SERVICE -8 | 50 #define EAI_SERVICE -8 |
53 #define EAI_MEMORY -10 | 51 #define EAI_MEMORY -10 |
54 #define EAI_SYSTEM -11 | 52 #define EAI_SYSTEM -11 |
55 #define EAI_OVERFLOW -12 | 53 #define EAI_OVERFLOW -12 |
56 | 54 |
57 int getaddrinfo (const char *__restrict, const char *__restrict, const struct ad
drinfo *__restrict, struct addrinfo **__restrict); | 55 int getaddrinfo(const char* __restrict, |
58 void freeaddrinfo (struct addrinfo *); | 56 const char* __restrict, |
59 int getnameinfo (const struct sockaddr *__restrict, socklen_t, char *__restrict,
socklen_t, char *__restrict, socklen_t, int); | 57 const struct addrinfo* __restrict, |
60 const char *gai_strerror(int); | 58 struct addrinfo** __restrict); |
61 | 59 void freeaddrinfo(struct addrinfo*); |
| 60 int getnameinfo(const struct sockaddr* __restrict, |
| 61 socklen_t, |
| 62 char* __restrict, |
| 63 socklen_t, |
| 64 char* __restrict, |
| 65 socklen_t, |
| 66 int); |
| 67 const char* gai_strerror(int); |
62 | 68 |
63 /* Legacy functions follow (marked OBsolete in SUS) */ | 69 /* Legacy functions follow (marked OBsolete in SUS) */ |
64 | 70 |
65 struct netent | 71 struct netent { |
66 { | 72 char* n_name; |
67 » char *n_name; | 73 char** n_aliases; |
68 » char **n_aliases; | 74 int n_addrtype; |
69 » int n_addrtype; | 75 uint32_t n_net; |
70 » uint32_t n_net; | |
71 }; | 76 }; |
72 | 77 |
73 struct hostent | 78 struct hostent { |
74 { | 79 char* h_name; |
75 » char *h_name; | 80 char** h_aliases; |
76 » char **h_aliases; | 81 int h_addrtype; |
77 » int h_addrtype; | 82 int h_length; |
78 » int h_length; | 83 char** h_addr_list; |
79 » char **h_addr_list; | |
80 }; | 84 }; |
81 #define h_addr h_addr_list[0] | 85 #define h_addr h_addr_list[0] |
82 | 86 |
83 struct servent | 87 struct servent { |
84 { | 88 char* s_name; |
85 » char *s_name; | 89 char** s_aliases; |
86 » char **s_aliases; | 90 int s_port; |
87 » int s_port; | 91 char* s_proto; |
88 » char *s_proto; | |
89 }; | 92 }; |
90 | 93 |
91 struct protoent | 94 struct protoent { |
92 { | 95 char* p_name; |
93 » char *p_name; | 96 char** p_aliases; |
94 » char **p_aliases; | 97 int p_proto; |
95 » int p_proto; | |
96 }; | 98 }; |
97 | 99 |
98 void sethostent (int); | 100 void sethostent(int); |
99 void endhostent (void); | 101 void endhostent(void); |
100 struct hostent *gethostent (void); | 102 struct hostent* gethostent(void); |
101 | 103 |
102 void setnetent (int); | 104 void setnetent(int); |
103 void endnetent (void); | 105 void endnetent(void); |
104 struct netent *getnetent (void); | 106 struct netent* getnetent(void); |
105 struct netent *getnetbyaddr (uint32_t, int); | 107 struct netent* getnetbyaddr(uint32_t, int); |
106 struct netent *getnetbyname (const char *); | 108 struct netent* getnetbyname(const char*); |
107 | 109 |
108 void setservent (int); | 110 void setservent(int); |
109 void endservent (void); | 111 void endservent(void); |
110 struct servent *getservent (void); | 112 struct servent* getservent(void); |
111 struct servent *getservbyname (const char *, const char *); | 113 struct servent* getservbyname(const char*, const char*); |
112 struct servent *getservbyport (int, const char *); | 114 struct servent* getservbyport(int, const char*); |
113 | 115 |
114 void setprotoent (int); | 116 void setprotoent(int); |
115 void endprotoent (void); | 117 void endprotoent(void); |
116 struct protoent *getprotoent (void); | 118 struct protoent* getprotoent(void); |
117 struct protoent *getprotobyname (const char *); | 119 struct protoent* getprotobyname(const char*); |
118 struct protoent *getprotobynumber (int); | 120 struct protoent* getprotobynumber(int); |
119 | 121 |
120 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_POSIX_SOURCE) \ | 122 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_POSIX_SOURCE) || \ |
121 || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE+0 < 200809L) \ | 123 (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE + 0 < 200809L) || \ |
122 || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700) | 124 (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE + 0 < 700) |
123 struct hostent *gethostbyname (const char *); | 125 struct hostent* gethostbyname(const char*); |
124 struct hostent *gethostbyaddr (const void *, socklen_t, int); | 126 struct hostent* gethostbyaddr(const void*, socklen_t, int); |
125 int *__h_errno_location(void); | 127 int* __h_errno_location(void); |
126 #define h_errno (*__h_errno_location()) | 128 #define h_errno (*__h_errno_location()) |
127 #define HOST_NOT_FOUND 1 | 129 #define HOST_NOT_FOUND 1 |
128 #define TRY_AGAIN 2 | 130 #define TRY_AGAIN 2 |
129 #define NO_RECOVERY 3 | 131 #define NO_RECOVERY 3 |
130 #define NO_DATA 4 | 132 #define NO_DATA 4 |
131 #define NO_ADDRESS NO_DATA | 133 #define NO_ADDRESS NO_DATA |
132 #endif | 134 #endif |
133 | 135 |
134 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) | 136 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) |
135 void herror(const char *); | 137 void herror(const char*); |
136 const char *hstrerror(int); | 138 const char* hstrerror(int); |
137 int gethostbyname_r(const char *, struct hostent *, char *, size_t, struct hoste
nt **, int *); | 139 int gethostbyname_r(const char*, |
138 int gethostbyname2_r(const char *, int, struct hostent *, char *, size_t, struct
hostent **, int *); | 140 struct hostent*, |
139 struct hostent *gethostbyname2(const char *, int); | 141 char*, |
140 int gethostbyaddr_r(const void *, socklen_t, int, struct hostent *, char *, size
_t, struct hostent **, int *); | 142 size_t, |
141 int getservbyport_r(int, const char *, struct servent *, char *, size_t, struct
servent **); | 143 struct hostent**, |
142 int getservbyname_r(const char *, const char *, struct servent *, char *, size_t
, struct servent **); | 144 int*); |
143 #define EAI_NODATA -5 | 145 int gethostbyname2_r(const char*, |
| 146 int, |
| 147 struct hostent*, |
| 148 char*, |
| 149 size_t, |
| 150 struct hostent**, |
| 151 int*); |
| 152 struct hostent* gethostbyname2(const char*, int); |
| 153 int gethostbyaddr_r(const void*, |
| 154 socklen_t, |
| 155 int, |
| 156 struct hostent*, |
| 157 char*, |
| 158 size_t, |
| 159 struct hostent**, |
| 160 int*); |
| 161 int getservbyport_r(int, |
| 162 const char*, |
| 163 struct servent*, |
| 164 char*, |
| 165 size_t, |
| 166 struct servent**); |
| 167 int getservbyname_r(const char*, |
| 168 const char*, |
| 169 struct servent*, |
| 170 char*, |
| 171 size_t, |
| 172 struct servent**); |
| 173 #define EAI_NODATA -5 |
144 #define EAI_ADDRFAMILY -9 | 174 #define EAI_ADDRFAMILY -9 |
145 #define EAI_INPROGRESS -100 | 175 #define EAI_INPROGRESS -100 |
146 #define EAI_CANCELED -101 | 176 #define EAI_CANCELED -101 |
147 #define EAI_NOTCANCELED -102 | 177 #define EAI_NOTCANCELED -102 |
148 #define EAI_ALLDONE -103 | 178 #define EAI_ALLDONE -103 |
149 #define EAI_INTR -104 | 179 #define EAI_INTR -104 |
150 #define EAI_IDN_ENCODE -105 | 180 #define EAI_IDN_ENCODE -105 |
151 #define NI_MAXHOST 255 | 181 #define NI_MAXHOST 255 |
152 #define NI_MAXSERV 32 | 182 #define NI_MAXSERV 32 |
153 #endif | 183 #endif |
154 | 184 |
155 | |
156 #ifdef __cplusplus | 185 #ifdef __cplusplus |
157 } | 186 } |
158 #endif | 187 #endif |
159 | 188 |
160 #endif | 189 #endif |
OLD | NEW |