netdb_private.h revision 145635
1/*- 2 * Copyright (C) 2005 The FreeBSD Project. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 * SUCH DAMAGE. 24 * 25 * $FreeBSD: head/lib/libc/net/netdb_private.h 145635 2005-04-28 18:52:40Z ume $ 26 */ 27 28#ifndef _NETDB_PRIVATE_H_ 29#define _NETDB_PRIVATE_H_ 30 31#include <sys/_types.h> 32#include <stdio.h> /* XXX: for FILE */ 33 34#ifndef _UINT32_T_DECLARED 35typedef __uint32_t uint32_t; 36#define _UINT32_T_DECLARED 37#endif 38 39#define _MAXALIASES 35 40#define _MAXLINELEN 1024 41#define _MAXADDRS 35 42#define _HOSTBUFSIZE (8 * 1024) 43#define _NETBUFSIZE 1025 44 45struct hostent_data { 46 uint32_t host_addr[4]; /* IPv4 or IPv6 */ 47 char *h_addr_ptrs[_MAXADDRS + 1]; 48 char *host_aliases[_MAXALIASES]; 49 char hostbuf[_HOSTBUFSIZE]; 50 FILE *hostf; 51 int stayopen; 52#ifdef YP 53 char *yp_domain; 54#endif 55}; 56 57struct netent_data { 58 char *net_aliases[_MAXALIASES]; 59 char netbuf[_NETBUFSIZE]; 60 FILE *netf; 61 int stayopen; 62#ifdef YP 63 char *yp_domain; 64#endif 65}; 66 67struct protoent_data { 68 FILE *fp; 69 char *aliases[_MAXALIASES]; 70 int stayopen; 71 char line[_MAXLINELEN + 1]; 72}; 73 74struct servent_data { 75 FILE *fp; 76 char *aliases[_MAXALIASES]; 77 int stayopen; 78 char line[_MAXLINELEN + 1]; 79#ifdef YP 80 int yp_stepping; 81 char *yp_name; 82 char *yp_proto; 83 int yp_port; 84 char *yp_domain; 85 char *yp_key; 86 int yp_keylen; 87#endif 88}; 89 90struct hostdata { 91 struct hostent host; 92 struct hostent_data data; 93}; 94 95struct netdata { 96 struct netent net; 97 struct netent_data data; 98}; 99 100struct protodata { 101 struct protoent proto; 102 struct protoent_data data; 103}; 104 105struct servdata { 106 struct servent serv; 107 struct servent_data data; 108}; 109 110#define endhostent_r __endhostent_r 111#define endnetent_r __endnetent_r 112#define endprotoent_r __endprotoent_r 113#define endservent_r __endservent_r 114#define gethostbyaddr_r __gethostbyaddr_r 115#define gethostbyname_r __gethostbyname_r 116#define gethostbyname2_r __gethostbyname2_r 117#define gethostent_r __gethostent_r 118#define getnetbyaddr_r __getnetbyaddr_r 119#define getnetbyname_r __getnetbyname_r 120#define getnetent_r __getnetent_r 121#define getprotobyname_r __getprotobyname_r 122#define getprotobynumber_r __getprotobynumber_r 123#define getprotoent_r __getprotoent_r 124#define getservbyname_r __getservbyname_r 125#define getservbyport_r __getservbyport_r 126#define getservent_r __getservent_r 127#define sethostent_r __sethostent_r 128#define setnetent_r __setnetent_r 129#define setprotoent_r __setprotoent_r 130#define setservent_r __setservent_r 131 132struct hostdata *__hostdata_init(void); 133struct netdata *__netdata_init(void); 134struct protodata *__protodata_init(void); 135struct servdata *__servdata_init(void); 136void _endhostdnsent(void); 137void _endhosthtent(struct hostent_data *); 138void _endnetdnsent(void); 139void _endnethtent(struct netent_data *); 140struct hostent *_gethostbynisaddr(const char *, int, int); 141struct hostent *_gethostbynisname(const char *, int); 142void _map_v4v6_address(const char *, char *); 143void _map_v4v6_hostent(struct hostent *, char **, char *); 144void _sethostdnsent(int); 145void _sethosthtent(int, struct hostent_data *); 146void _setnetdnsent(int); 147void _setnethtent(int, struct netent_data *); 148void endhostent_r(struct hostent_data *); 149void endnetent_r(struct netent_data *); 150void endprotoent_r(struct protoent_data *); 151void endservent_r(struct servent_data *); 152int gethostbyaddr_r(const char *, int, int, struct hostent *, 153 struct hostent_data *); 154int gethostbyname_r(const char *, struct hostent *, struct hostent_data *); 155int gethostbyname2_r(const char *, int, struct hostent *, 156 struct hostent_data *); 157int gethostent_r(struct hostent *, struct hostent_data *); 158int getnetbyaddr_r(unsigned long addr, int af, struct netent *, 159 struct netent_data *); 160int getnetbyname_r(const char *, struct netent *, struct netent_data *); 161int getnetent_r(struct netent *, struct netent_data *); 162int getprotobyname_r(const char *, struct protoent *, struct protoent_data *); 163int getprotobynumber_r(int, struct protoent *, struct protoent_data *); 164int getprotoent_r(struct protoent *, struct protoent_data *); 165int getservbyname_r(const char *, const char *, struct servent *, 166 struct servent_data *); 167int getservbyport_r(int, const char *, struct servent *, 168 struct servent_data *); 169int getservent_r(struct servent *, struct servent_data *); 170void sethostent_r(int, struct hostent_data *); 171void setnetent_r(int, struct netent_data *); 172void setprotoent_r(int, struct protoent_data *); 173void setservent_r(int, struct servent_data *); 174 175#endif /* _NETDB_PRIVATE_H_ */ 176