Subversion Repositories SvarDOS

Rev

Rev 616 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
207 mateuszvis 1
/*!\file netdb.h
2
 * BSD netdb functions.
3
 */
4
 
5
/*-
6
 * Copyright (c) 1980, 1983, 1988, 1993
7
 *      The Regents of the University of California.  All rights reserved.
8
 *
9
 * Redistribution and use in source and binary forms, with or without
10
 * modification, are permitted provided that the following conditions
11
 * are met:
12
 * 1. Redistributions of source code must retain the above copyright
13
 *    notice, this list of conditions and the following disclaimer.
14
 * 2. Redistributions in binary form must reproduce the above copyright
15
 *    notice, this list of conditions and the following disclaimer in the
16
 *    documentation and/or other materials provided with the distribution.
17
 * 3. All advertising materials mentioning features or use of this software
18
 *    must display the following acknowledgement:
19
 *      This product includes software developed by the University of
20
 *      California, Berkeley and its contributors.
21
 * 4. Neither the name of the University nor the names of its contributors
22
 *    may be used to endorse or promote products derived from this software
23
 *    without specific prior written permission.
24
 *
25
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35
 * SUCH DAMAGE.
36
 *
37
 *      @(#)netdb.h     8.1 (Berkeley) 6/2/93
38
 *      $Id: netdb.h,v 1.5 1996/08/29 20:00:56 peter Exp $
39
 * -
40
 * Portions Copyright (c) 1993 by Digital Equipment Corporation.
41
 *
42
 * Permission to use, copy, modify, and distribute this software for any
43
 * purpose with or without fee is hereby granted, provided that the above
44
 * copyright notice and this permission notice appear in all copies, and that
45
 * the name of Digital Equipment Corporation not be used in advertising or
46
 * publicity pertaining to distribution of the document or software without
47
 * specific, written prior permission.
48
 *
49
 * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
50
 * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
51
 * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
52
 * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
53
 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
54
 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
55
 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
56
 * SOFTWARE.
57
 * -
58
 * --Copyright--
59
 */
60
 
61
#ifndef __NETDB_H
62
#define __NETDB_H
63
 
64
#ifndef _PATH_HEQUIV
65
#define _PATH_HEQUIV    "/etc/hosts.equiv"
66
#endif
67
 
68
#ifndef _PATH_HOSTS
69
#define _PATH_HOSTS     "/etc/hosts"
70
#endif
71
 
72
#ifndef _PATH_NETWORKS
73
#define _PATH_NETWORKS  "/etc/networks"
74
#endif
75
 
76
#ifndef _PATH_PROTOCOLS
77
#define _PATH_PROTOCOLS "/etc/protocols"
78
#endif
79
 
80
#ifndef _PATH_SERVICES
81
#define _PATH_SERVICES  "/etc/services"
82
#endif
83
 
84
#ifndef __SYS_W32API_H
85
#include <sys/w32api.h>
86
#endif
87
 
88
#ifndef __SYS_SOCKET_H
89
#include <sys/socket.h> /* struct sockaddr */
90
#endif
91
 
92
#ifndef __SYS_CDEFS_H
93
#include <sys/cdefs.h>
94
#endif
95
 
96
 
97
/*
98
 * Structures returned by network data base library.  All addresses are
99
 * supplied in host order, and returned in network order (suitable for
100
 * use in system calls).
101
 */
102
struct hostent {
103
        char    *h_name;        /* official name of host */
104
        char    **h_aliases;    /* alias list */
105
        int     h_addrtype;     /* host address type */
106
        int     h_length;       /* length of address */
107
        char    **h_addr_list;  /* list of addresses from name server */
108
#define h_addr  h_addr_list[0]  /* address, for backward compatiblity */
109
};
110
 
111
/*
112
 * Assumption here is that a network number
113
 * fits in 32 bits -- probably a poor one.
114
 */
115
struct netent {
116
       char            *n_name;        /* official name of net */
117
       char            **n_aliases;    /* alias list */
118
       int             n_addrtype;     /* net address type */
119
       unsigned long   n_net;          /* network # */
120
     };
121
 
122
struct servent {
123
       char    *s_name;        /* official service name */
124
       char    **s_aliases;    /* alias list */
125
       int     s_port;         /* port # */
126
       char    *s_proto;       /* protocol to use */
127
     };
128
 
129
struct protoent {
130
       char    *p_name;        /* official protocol name */
131
       char    **p_aliases;    /* alias list */
132
       int     p_proto;        /* protocol # */
133
     };
134
 
135
struct addrinfo {
136
       int     ai_flags;       /* AI_PASSIVE, AI_CANONNAME */
137
       int     ai_family;      /* PF_xxx */
138
       int     ai_socktype;    /* SOCK_xxx */
139
       int     ai_protocol;    /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
140
       int     ai_addrlen;     /* length of ai_addr */
141
       char   *ai_canonname;   /* canonical name for hostname */
142
       struct sockaddr  *ai_addr; /* binary address */
143
       struct addrinfo  *ai_next; /* next structure in linked list */
144
     };
145
 
146
/*
147
 * Error return codes from gethostbyname() and gethostbyaddr()
148
 * (left in extern int h_errno).
149
 */
150
W32_DATA int h_errno;
151
 
152
#define NETDB_INTERNAL  -1      /* see errno */
153
#define NETDB_SUCCESS   0       /* no problem */
154
#define HOST_NOT_FOUND  1       /* Authoritative Answer Host not found */
155
#define TRY_AGAIN       2       /* Non-Authoritive Host not found, or SERVERFAIL */
156
#define NO_RECOVERY     3       /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
157
#define NO_DATA         4       /* Valid name, no data record of requested type */
158
#define NO_ADDRESS      NO_DATA /* no address, look for MX record */
159
 
160
 
161
/*
162
 * Error return codes from getaddrinfo()
163
 */
164
#define EAI_ADDRFAMILY   1  /* address family for hostname not supported */
165
#define EAI_AGAIN        2  /* temporary failure in name resolution */
166
#define EAI_BADFLAGS     3  /* invalid value for ai_flags */
167
#define EAI_FAIL         4  /* non-recoverable failure in name resolution */
168
#define EAI_FAMILY       5  /* ai_family not supported */
169
#define EAI_MEMORY       6  /* memory allocation failure */
170
#define EAI_NODATA       7  /* no address associated with hostname */
171
#define EAI_NONAME       8  /* hostname nor servname provided, or not known */
172
#define EAI_SERVICE      9  /* servname not supported for ai_socktype */
173
#define EAI_SOCKTYPE    10  /* ai_socktype not supported */
174
#define EAI_SYSTEM      11  /* system error returned in errno */
175
#define EAI_BADHINTS    12
176
#define EAI_PROTOCOL    13
177
#define EAI_MAX         14
178
 
179
/*
180
 * Flag values for getaddrinfo()
181
 */
182
#define AI_PASSIVE      0x00000001 /* get address to use bind() */
183
#define AI_CANONNAME    0x00000002 /* fill ai_canonname */
184
#define AI_NUMERICHOST  0x00000004 /* prevent name resolution */
185
 
186
/* valid flags for addrinfo
187
 */
188
#define AI_MASK         (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
189
 
190
#define AI_ALL          0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
191
#define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */
192
#define AI_ADDRCONFIG   0x00000400 /* only if any address is assigned */
193
#define AI_V4MAPPED     0x00000800 /* accept IPv4-mapped IPv6 address */
194
 
195
/* special recommended flags for getipnodebyname
196
 */
197
#define AI_DEFAULT      (AI_V4MAPPED_CFG | AI_ADDRCONFIG)
198
 
199
/*
200
 * Constants for getnameinfo()
201
 */
202
#define NI_MAXHOST      1025
203
#define NI_MAXSERV      32
204
 
205
/*
206
 * Flag values for getnameinfo()
207
 */
208
#define NI_NOFQDN       0x00000001
209
#define NI_NUMERICHOST  0x00000002
210
#define NI_NAMEREQD     0x00000004
211
#define NI_NUMERICSERV  0x00000008
212
#define NI_DGRAM        0x00000010
213
#define NI_WITHSCOPEID  0x00000020
214
 
215
/*
216
 * Scope delimit character
217
 */
218
#define SCOPE_DELIMITER '%'
219
 
220
__BEGIN_DECLS
221
 
222
W32_FUNC void              W32_CALL endhostent     (void);
223
W32_FUNC void              W32_CALL endnetent      (void);
224
W32_FUNC void              W32_CALL endprotoent    (void);
225
W32_FUNC void              W32_CALL endservent     (void);
226
 
227
W32_FUNC struct hostent  * W32_CALL gethostbyaddr  (const char *, int, int);
228
W32_FUNC struct hostent  * W32_CALL gethostbyname  (const char *);
229
W32_FUNC struct hostent  * W32_CALL gethostbyname2 (const char *, int af);
230
W32_FUNC struct hostent  * W32_CALL gethostent     (void);
231
W32_FUNC struct hostent  * W32_CALL getipnodebyaddr(const void *, size_t, int, int *);
232
W32_FUNC struct hostent  * W32_CALL getipnodebyname(const char *, int, int, int *);
233
W32_FUNC struct netent   * W32_CALL getnetbyaddr   (long, int);
234
W32_FUNC struct netent   * W32_CALL getnetbyname   (const char *);
235
W32_FUNC struct netent   * W32_CALL getnetent      (void);
236
W32_FUNC struct protoent * W32_CALL getprotobyname (const char *);
237
W32_FUNC struct protoent * W32_CALL getprotobynumber (int);
238
W32_FUNC struct protoent * W32_CALL getprotoent    (void);
239
W32_FUNC struct servent  * W32_CALL getservbyname  (const char *, const char *);
240
W32_FUNC struct servent  * W32_CALL getservbyport  (int, const char *);
241
W32_FUNC struct servent  * W32_CALL getservent     (void);
242
W32_FUNC void              W32_CALL herror         (const char *);
243
W32_FUNC const char      * W32_CALL hstrerror      (int);
244
W32_FUNC void              W32_CALL sethostent     (int);
245
W32_FUNC void              W32_CALL setnetent      (int);
246
W32_FUNC void              W32_CALL setprotoent    (int);
247
W32_FUNC void              W32_CALL setservent     (int);
248
 
249
W32_FUNC int W32_CALL getnameinfo (const struct sockaddr *sa, int salen,
250
                                   char *host, int hostlen,
251
                                   char *serv, int servlen, int flags);
252
 
253
W32_FUNC int W32_CALL getaddrinfo (const char *hostname, const char *servname,
254
                                   const struct addrinfo *hints, struct addrinfo **res);
255
 
256
W32_FUNC void   W32_CALL freeaddrinfo (struct addrinfo *ai);
257
W32_FUNC void   W32_CALL freehostent  (struct hostent *);
258
W32_FUNC char * W32_CALL gai_strerror (int ecode);
259
 
260
W32_FUNC int    W32_CALL if_nametoindex (const char *);
261
W32_FUNC char * W32_CALL if_indextoname (int, char *);
262
 
263
W32_FUNC int  * W32_CALL __h_errno_location (void);
264
 
265
#if defined(_REENTRANT)
266
W32_FUNC struct hostent * W32_CALL gethostbyaddr_r (
267
  const char *addr, int len, int type, struct hostent *result,
268
  char *buffer, int buflen, int *h_errnop);
269
 
270
W32_FUNC struct hostent * W32_CALL gethostbyname_r (
271
  const char *name, struct hostent *result,
272
  char *buffer, int buflen, int *h_errnop);
273
 
274
W32_FUNC struct hostent * W32_CALL gethostent_r (
275
  struct hostent *result, char *buffer, int buflen, int *h_errnop);
276
 
277
W32_FUNC struct netent * W32_CALL getnetbyaddr_r (
278
  long net, int type, struct netent *result, char *buffer, int buflen);
279
 
280
W32_FUNC struct netent * W32_CALL getnetbyname_r (
281
  const char *name, struct netent *result, char *buffer, int buflen);
282
 
283
W32_FUNC struct netent * W32_CALL getnetent_r (
284
  struct netent *result, char *buffer, int buflen);
285
 
286
W32_FUNC struct protoent * W32_CALL getprotobyname_r (
287
  const char *name, struct protoent *result, char *buffer, int buflen);
288
 
289
W32_FUNC struct protoent * W32_CALL getprotobynumber_r (
290
  int proto, struct protoent *result, char *buffer, int buflen);
291
 
292
W32_FUNC struct protoent * W32_CALL getprotoent_r (
293
  struct protoent *result, char *buffer, int buflen);
294
 
295
W32_FUNC struct servent * W32_CALL getservbyname_r (
296
  const char *name, const char *proto, struct servent *result,
297
  char *buffer, int buflen);
298
 
299
W32_FUNC struct servent * W32_CALL getservbyport_r (
300
  int port, const char *proto, struct servent *result,
301
  char *buffer, int buflen);
302
 
303
W32_FUNC struct servent * W32_CALL getservent_r (
304
  struct servent *result, char *buffer, int buflen);
305
 
306
#endif /* _REENTRANT */
307
 
308
__END_DECLS
309
 
310
#endif