source: svn/newcon3bcm2_21bu/toolchain/mips-linux-uclibc/include/netdb.h @ 43

Last change on this file since 43 was 43, checked in by megakiss, 11 years ago

광주방송 OTC 주파수 369Mhz로 변경

  • Property svn:executable set to *
File size: 16.9 KB
Line 
1/* Copyright (C) 1996,1997,1998,1999,2000,2001 Free Software Foundation, Inc.
2   This file is part of the GNU C Library.
3
4   The GNU C Library is free software; you can redistribute it and/or
5   modify it under the terms of the GNU Lesser General Public
6   License as published by the Free Software Foundation; either
7   version 2.1 of the License, or (at your option) any later version.
8
9   The GNU C Library is distributed in the hope that it will be useful,
10   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12   Lesser General Public License for more details.
13
14   You should have received a copy of the GNU Lesser General Public
15   License along with the GNU C Library; if not, write to the Free
16   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17   02111-1307 USA.  */
18
19/* All data returned by the network data base library are supplied in
20   host order and returned in network order (suitable for use in
21   system calls).  */
22
23#ifndef _NETDB_H
24#define _NETDB_H        1
25
26#include <features.h>
27
28#include <netinet/in.h>
29#include <stdint.h>
30#ifdef __USE_MISC
31/* This is necessary to make this include file properly replace the
32   Sun version.  */
33# include <rpc/netdb.h>
34#endif
35
36#ifdef __USE_GNU
37# define __need_sigevent_t
38# include <bits/siginfo.h>
39# define __need_timespec
40# include <time.h>
41#endif
42
43#include <bits/netdb.h>
44
45/* Absolute file name for network data base files.  */
46#define _PATH_HEQUIV            "/etc/hosts.equiv"
47#define _PATH_HOSTS             "/etc/hosts"
48#define _PATH_NETWORKS          "/etc/networks"
49#define _PATH_NSSWITCH_CONF     "/etc/nsswitch.conf"
50#define _PATH_PROTOCOLS         "/etc/protocols"
51#define _PATH_SERVICES          "/etc/services"
52
53
54__BEGIN_DECLS
55
56/* Error status for non-reentrant lookup functions.  */
57extern int h_errno;
58
59/* Function to get address of global `h_errno' variable.  */
60extern int *__h_errno_location (void) __THROW __attribute__ ((__const__));
61
62#ifdef _LIBC
63# define __set_h_errno(x) (h_errno = (x))
64#endif
65
66#if defined __UCLIBC_HAS_THREADS__
67/* Use a macro to access always the thread specific `h_errno' variable.  */
68# define h_errno (*__h_errno_location ())
69#endif
70
71
72/* Possible values left in `h_errno'.  */
73#define NETDB_INTERNAL  -1      /* See errno.  */
74#define NETDB_SUCCESS   0       /* No problem.  */
75#define HOST_NOT_FOUND  1       /* Authoritative Answer Host not found.  */
76#define TRY_AGAIN       2       /* Non-Authoritative Host not found,
77                                   or SERVERFAIL.  */
78#define NO_RECOVERY     3       /* Non recoverable errors, FORMERR, REFUSED,
79                                   NOTIMP.  */
80#define NO_DATA         4       /* Valid name, no data record of requested
81                                   type.  */
82#define NO_ADDRESS      NO_DATA /* No address, look for MX record.  */
83
84#ifdef __USE_XOPEN2K
85/* Highest reserved Internet port number.  */
86# define IPPORT_RESERVED        1024
87#endif
88
89#ifdef __USE_GNU
90/* Scope delimiter for getaddrinfo(), getnameinfo().  */
91# define SCOPE_DELIMITER        '%'
92#endif
93
94/* Print error indicated by `h_errno' variable on standard error.  STR
95   if non-null is printed before the error string.  */
96extern void herror (__const char *__str) __THROW;
97
98/* Return string associated with error ERR_NUM.  */
99extern __const char *hstrerror (int __err_num) __THROW;
100
101
102
103/* Description of data base entry for a single host.  */
104struct hostent
105{
106  char *h_name;                 /* Official name of host.  */
107  char **h_aliases;             /* Alias list.  */
108  int h_addrtype;               /* Host address type.  */
109  int h_length;                 /* Length of address.  */
110  char **h_addr_list;           /* List of addresses from name server.  */
111#define h_addr  h_addr_list[0]  /* Address, for backward compatibility.  */
112};
113
114/* Open host data base files and mark them as staying open even after
115   a later search if STAY_OPEN is non-zero.  */
116extern void sethostent (int __stay_open) __THROW;
117
118/* Close host data base files and clear `stay open' flag.  */
119extern void endhostent (void) __THROW;
120
121/* Get next entry from host data base file.  Open data base if
122   necessary.  */
123extern struct hostent *gethostent (void) __THROW;
124
125/* Return entry from host data base which address match ADDR with
126   length LEN and type TYPE.  */
127extern struct hostent *gethostbyaddr (__const void *__addr, __socklen_t __len,
128                                      int __type) __THROW;
129
130/* Return entry from host data base for host with NAME.  */
131extern struct hostent *gethostbyname (__const char *__name) __THROW;
132
133#ifdef __USE_MISC
134/* Return entry from host data base for host with NAME.  AF must be
135   set to the address type which is `AF_INET' for IPv4 or `AF_INET6'
136   for IPv6.  */
137extern struct hostent *gethostbyname2 (__const char *__name, int __af) __THROW;
138
139/* Reentrant versions of the functions above.  The additional
140   arguments specify a buffer of BUFLEN starting at BUF.  The last
141   argument is a pointer to a variable which gets the value which
142   would be stored in the global variable `herrno' by the
143   non-reentrant functions.  */
144extern int gethostent_r (struct hostent *__restrict __result_buf,
145                         char *__restrict __buf, size_t __buflen,
146                         struct hostent **__restrict __result,
147                         int *__restrict __h_errnop) __THROW;
148
149extern int gethostbyaddr_r (__const void *__restrict __addr, __socklen_t __len,
150                            int __type,
151                            struct hostent *__restrict __result_buf,
152                            char *__restrict __buf, size_t __buflen,
153                            struct hostent **__restrict __result,
154                            int *__restrict __h_errnop) __THROW;
155
156extern int gethostbyname_r (__const char *__restrict __name,
157                            struct hostent *__restrict __result_buf,
158                            char *__restrict __buf, size_t __buflen,
159                            struct hostent **__restrict __result,
160                            int *__restrict __h_errnop) __THROW;
161
162extern int gethostbyname2_r (__const char *__restrict __name, int __af,
163                             struct hostent *__restrict __result_buf,
164                             char *__restrict __buf, size_t __buflen,
165                             struct hostent **__restrict __result,
166                             int *__restrict __h_errnop) __THROW;
167#endif  /* misc */
168
169
170/* Open network data base files and mark them as staying open even
171   after a later search if STAY_OPEN is non-zero.  */
172extern void setnetent (int __stay_open) __THROW;
173
174/* Close network data base files and clear `stay open' flag.  */
175extern void endnetent (void) __THROW;
176
177/* Get next entry from network data base file.  Open data base if
178   necessary.  */
179extern struct netent *getnetent (void) __THROW;
180
181/* Return entry from network data base which address match NET and
182   type TYPE.  */
183extern struct netent *getnetbyaddr (uint32_t __net, int __type)
184     __THROW;
185
186/* Return entry from network data base for network with NAME.  */
187extern struct netent *getnetbyname (__const char *__name) __THROW;
188
189#if 0
190/* FIXME */
191#ifdef  __USE_MISC
192/* Reentrant versions of the functions above.  The additional
193   arguments specify a buffer of BUFLEN starting at BUF.  The last
194   argument is a pointer to a variable which gets the value which
195   would be stored in the global variable `herrno' by the
196   non-reentrant functions.  */
197extern int getnetent_r (struct netent *__restrict __result_buf,
198                        char *__restrict __buf, size_t __buflen,
199                        struct netent **__restrict __result,
200                        int *__restrict __h_errnop) __THROW;
201
202extern int getnetbyaddr_r (uint32_t __net, int __type,
203                           struct netent *__restrict __result_buf,
204                           char *__restrict __buf, size_t __buflen,
205                           struct netent **__restrict __result,
206                           int *__restrict __h_errnop) __THROW;
207
208extern int getnetbyname_r (__const char *__restrict __name,
209                           struct netent *__restrict __result_buf,
210                           char *__restrict __buf, size_t __buflen,
211                           struct netent **__restrict __result,
212                           int *__restrict __h_errnop) __THROW;
213#endif  /* misc */
214#endif
215
216
217/* Description of data base entry for a single service.  */
218struct servent
219{
220  char *s_name;                 /* Official service name.  */
221  char **s_aliases;             /* Alias list.  */
222  int s_port;                   /* Port number.  */
223  char *s_proto;                /* Protocol to use.  */
224};
225
226/* Open service data base files and mark them as staying open even
227   after a later search if STAY_OPEN is non-zero.  */
228extern void setservent (int __stay_open) __THROW;
229
230/* Close service data base files and clear `stay open' flag.  */
231extern void endservent (void) __THROW;
232
233/* Get next entry from service data base file.  Open data base if
234   necessary.  */
235extern struct servent *getservent (void) __THROW;
236
237/* Return entry from network data base for network with NAME and
238   protocol PROTO.  */
239extern struct servent *getservbyname (__const char *__name,
240                                      __const char *__proto) __THROW;
241
242/* Return entry from service data base which matches port PORT and
243   protocol PROTO.  */
244extern struct servent *getservbyport (int __port, __const char *__proto)
245     __THROW;
246
247
248#ifdef  __USE_MISC
249/* Reentrant versions of the functions above.  The additional
250   arguments specify a buffer of BUFLEN starting at BUF.  */
251extern int getservent_r (struct servent *__restrict __result_buf,
252                         char *__restrict __buf, size_t __buflen,
253                         struct servent **__restrict __result) __THROW;
254
255extern int getservbyname_r (__const char *__restrict __name,
256                            __const char *__restrict __proto,
257                            struct servent *__restrict __result_buf,
258                            char *__restrict __buf, size_t __buflen,
259                            struct servent **__restrict __result) __THROW;
260
261extern int getservbyport_r (int __port, __const char *__restrict __proto,
262                            struct servent *__restrict __result_buf,
263                            char *__restrict __buf, size_t __buflen,
264                            struct servent **__restrict __result) __THROW;
265#endif  /* misc */
266
267
268/* Description of data base entry for a single service.  */
269struct protoent
270{
271  char *p_name;                 /* Official protocol name.  */
272  char **p_aliases;             /* Alias list.  */
273  int p_proto;                  /* Protocol number.  */
274};
275
276/* Open protocol data base files and mark them as staying open even
277   after a later search if STAY_OPEN is non-zero.  */
278extern void setprotoent (int __stay_open) __THROW;
279
280/* Close protocol data base files and clear `stay open' flag.  */
281extern void endprotoent (void) __THROW;
282
283/* Get next entry from protocol data base file.  Open data base if
284   necessary.  */
285extern struct protoent *getprotoent (void) __THROW;
286
287/* Return entry from protocol data base for network with NAME.  */
288extern struct protoent *getprotobyname (__const char *__name) __THROW;
289
290/* Return entry from protocol data base which number is PROTO.  */
291extern struct protoent *getprotobynumber (int __proto) __THROW;
292
293
294#ifdef  __USE_MISC
295/* Reentrant versions of the functions above.  The additional
296   arguments specify a buffer of BUFLEN starting at BUF.  */
297extern int getprotoent_r (struct protoent *__restrict __result_buf,
298                          char *__restrict __buf, size_t __buflen,
299                          struct protoent **__restrict __result) __THROW;
300
301extern int getprotobyname_r (__const char *__restrict __name,
302                             struct protoent *__restrict __result_buf,
303                             char *__restrict __buf, size_t __buflen,
304                             struct protoent **__restrict __result) __THROW;
305
306extern int getprotobynumber_r (int __proto,
307                               struct protoent *__restrict __result_buf,
308                               char *__restrict __buf, size_t __buflen,
309                               struct protoent **__restrict __result) __THROW;
310#endif  /* misc */
311
312
313#ifdef __USE_BSD
314/* Call `rshd' at port RPORT on remote machine *AHOST to execute CMD.
315   The local user is LOCUSER, on the remote machine the command is
316   executed as REMUSER.  In *FD2P the descriptor to the socket for the
317   connection is returned.  The caller must have the right to use a
318   reserved port.  When the function returns *AHOST contains the
319   official host name.  */
320extern int rcmd (char **__restrict __ahost, unsigned short int __rport,
321                 __const char *__restrict __locuser,
322                 __const char *__restrict __remuser,
323                 __const char *__restrict __cmd, int *__restrict __fd2p)
324     __THROW;
325
326#if 0
327/* FIXME */
328/* This is the equivalent function where the protocol can be selected
329   and which therefore can be used for IPv6.  */
330extern int rcmd_af (char **__restrict __ahost, unsigned short int __rport,
331                    __const char *__restrict __locuser,
332                    __const char *__restrict __remuser,
333                    __const char *__restrict __cmd, int *__restrict __fd2p,
334                    sa_family_t __af) __THROW;
335#endif
336
337/* Call `rexecd' at port RPORT on remote machine *AHOST to execute
338   CMD.  The process runs at the remote machine using the ID of user
339   NAME whose cleartext password is PASSWD.  In *FD2P the descriptor
340   to the socket for the connection is returned.  When the function
341   returns *AHOST contains the official host name.  */
342extern int rexec (char **__restrict __ahost, int __rport,
343                  __const char *__restrict __name,
344                  __const char *__restrict __pass,
345                  __const char *__restrict __cmd, int *__restrict __fd2p)
346     __THROW;
347
348/* This is the equivalent function where the protocol can be selected
349   and which therefore can be used for IPv6.  */
350extern int rexec_af (char **__restrict __ahost, int __rport,
351                     __const char *__restrict __name,
352                     __const char *__restrict __pass,
353                     __const char *__restrict __cmd, int *__restrict __fd2p,
354                     sa_family_t __af) __THROW;
355
356/* Check whether user REMUSER on system RHOST is allowed to login as LOCUSER.
357   If SUSER is not zero the user tries to become superuser.  Return 0 if
358   it is possible.  */
359extern int ruserok (__const char *__rhost, int __suser,
360                    __const char *__remuser, __const char *__locuser) __THROW;
361
362#if 0
363/* FIXME */
364/* This is the equivalent function where the protocol can be selected
365   and which therefore can be used for IPv6.  */
366extern int ruserok_af (__const char *__rhost, int __suser,
367                       __const char *__remuser, __const char *__locuser,
368                       sa_family_t __af) __THROW;
369#endif
370
371/* Try to allocate reserved port, returning a descriptor for a socket opened
372   at this port or -1 if unsuccessful.  The search for an available port
373   will start at ALPORT and continues with lower numbers.  */
374extern int rresvport (int *__alport) __THROW;
375
376#if 0
377/* FIXME */
378/* This is the equivalent function where the protocol can be selected
379   and which therefore can be used for IPv6.  */
380extern int rresvport_af (int *__alport, sa_family_t __af) __THROW;
381#endif
382#endif
383
384
385/* Extension from POSIX.1g.  */
386#ifdef  __USE_POSIX
387/* Structure to contain information about address of a service provider.  */
388struct addrinfo
389{
390  int ai_flags;                 /* Input flags.  */
391  int ai_family;                /* Protocol family for socket.  */
392  int ai_socktype;              /* Socket type.  */
393  int ai_protocol;              /* Protocol for socket.  */
394  socklen_t ai_addrlen;         /* Length of socket address.  */
395  struct sockaddr *ai_addr;     /* Socket address for socket.  */
396  char *ai_canonname;           /* Canonical name for service location.  */
397  struct addrinfo *ai_next;     /* Pointer to next in list.  */
398};
399
400/* Possible values for `ai_flags' field in `addrinfo' structure.  */
401# define AI_PASSIVE     0x0001  /* Socket address is intended for `bind'.  */
402# define AI_CANONNAME   0x0002  /* Request for canonical name.  */
403# define AI_NUMERICHOST 0x0004  /* Don't use name resolution.  */
404
405/* Error values for `getaddrinfo' function.  */
406# define EAI_BADFLAGS     -1    /* Invalid value for `ai_flags' field.  */
407# define EAI_NONAME       -2    /* NAME or SERVICE is unknown.  */
408# define EAI_AGAIN        -3    /* Temporary failure in name resolution.  */
409# define EAI_FAIL         -4    /* Non-recoverable failure in name res.  */
410# define EAI_NODATA       -5    /* No address associated with NAME.  */
411# define EAI_FAMILY       -6    /* `ai_family' not supported.  */
412# define EAI_SOCKTYPE     -7    /* `ai_socktype' not supported.  */
413# define EAI_SERVICE      -8    /* SERVICE not supported for `ai_socktype'.  */
414# define EAI_ADDRFAMILY   -9    /* Address family for NAME not supported.  */
415# define EAI_MEMORY       -10   /* Memory allocation failure.  */
416# define EAI_SYSTEM       -11   /* System error returned in `errno'.  */
417# ifdef __USE_GNU
418#  define EAI_INPROGRESS  -100  /* Processing request in progress.  */
419#  define EAI_CANCELED    -101  /* Request canceled.  */
420#  define EAI_NOTCANCELED -102  /* Request not canceled.  */
421#  define EAI_ALLDONE     -103  /* All requests done.  */
422#  define EAI_INTR        -104  /* Interrupted by a signal.  */
423# endif
424
425# define NI_MAXHOST      1025
426# define NI_MAXSERV      32
427
428# define NI_NUMERICHOST 1       /* Don't try to look up hostname.  */
429# define NI_NUMERICSERV 2       /* Don't convert port number to name.  */
430# define NI_NOFQDN      4       /* Only return nodename portion.  */
431# define NI_NAMEREQD    8       /* Don't return numeric addresses.  */
432# define NI_DGRAM       16      /* Look up UDP service rather than TCP.  */
433
434/* Translate name of a service location and/or a service name to set of
435   socket addresses.  */
436extern int getaddrinfo (__const char *__restrict __name,
437                        __const char *__restrict __service,
438                        __const struct addrinfo *__restrict __req,
439                        struct addrinfo **__restrict __pai) __THROW;
440
441/* Free `addrinfo' structure AI including associated storage.  */
442extern void freeaddrinfo (struct addrinfo *__ai) __THROW;
443
444/* Convert error return from getaddrinfo() to a string.  */
445extern __const char *gai_strerror (int __ecode) __THROW;
446
447/* Translate a socket address to a location and service name.  */
448extern int getnameinfo (__const struct sockaddr *__restrict __sa,
449                        socklen_t __salen, char *__restrict __host,
450                        socklen_t __hostlen, char *__restrict __serv,
451                        socklen_t __servlen, unsigned int __flags) __THROW;
452
453#endif  /* POSIX */
454
455__END_DECLS
456
457#endif  /* netdb.h */
Note: See TracBrowser for help on using the repository browser.