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$ 26 */ 27 28 #ifndef _NETDB_PRIVATE_H_ 29 #define _NETDB_PRIVATE_H_ 30 31 #include <stdio.h> /* XXX: for FILE */ 32 33 #define _MAXALIASES 35 34 #define _MAXLINELEN 1024 35 #define _MAXADDRS 35 36 #define _HOSTBUFSIZE (8 * 1024) 37 #define _NETBUFSIZE 1025 38 39 struct hostent_data { 40 uint32_t host_addr[4]; /* IPv4 or IPv6 */ 41 char *h_addr_ptrs[_MAXADDRS + 1]; 42 char *host_aliases[_MAXALIASES]; 43 char hostbuf[_HOSTBUFSIZE]; 44 FILE *hostf; 45 int stayopen; 46 #ifdef YP 47 char *yp_domain; 48 #endif 49 }; 50 51 struct netent_data { 52 char *net_aliases[_MAXALIASES]; 53 char netbuf[_NETBUFSIZE]; 54 FILE *netf; 55 int stayopen; 56 #ifdef YP 57 char *yp_domain; 58 #endif 59 }; 60 61 struct protoent_data { 62 FILE *fp; 63 char *aliases[_MAXALIASES]; 64 int stayopen; 65 char line[_MAXLINELEN + 1]; 66 }; 67 68 struct servent_data { 69 FILE *fp; 70 char *aliases[_MAXALIASES]; 71 int stayopen; 72 char line[_MAXLINELEN + 1]; 73 #ifdef YP 74 int yp_stepping; 75 char *yp_name; 76 char *yp_proto; 77 int yp_port; 78 char *yp_domain; 79 char *yp_key; 80 int yp_keylen; 81 #endif 82 }; 83 84 struct hostdata { 85 struct hostent host; 86 struct hostent_data data; 87 }; 88 89 struct netdata { 90 struct netent net; 91 struct netent_data data; 92 }; 93 94 struct protodata { 95 struct protoent proto; 96 struct protoent_data data; 97 }; 98 99 struct servdata { 100 struct servent serv; 101 struct servent_data data; 102 }; 103 104 #define endhostent_r __endhostent_r 105 #define endnetent_r __endnetent_r 106 #define endprotoent_r __endprotoent_r 107 #define endservent_r __endservent_r 108 #define gethostbyaddr_r __gethostbyaddr_r 109 #define gethostbyname_r __gethostbyname_r 110 #define gethostbyname2_r __gethostbyname2_r 111 #define gethostent_r __gethostent_r 112 #define getnetbyaddr_r __getnetbyaddr_r 113 #define getnetbyname_r __getnetbyname_r 114 #define getnetent_r __getnetent_r 115 #define getprotobyname_r __getprotobyname_r 116 #define getprotobynumber_r __getprotobynumber_r 117 #define getprotoent_r __getprotoent_r 118 #define getservbyname_r __getservbyname_r 119 #define getservbyport_r __getservbyport_r 120 #define getservent_r __getservent_r 121 #define sethostent_r __sethostent_r 122 #define setnetent_r __setnetent_r 123 #define setprotoent_r __setprotoent_r 124 #define setservent_r __setservent_r 125 126 struct hostdata *__hostdata_init(void); 127 struct netdata *__netdata_init(void); 128 struct protodata *__protodata_init(void); 129 struct servdata *__servdata_init(void); 130 void _endhostdnsent(void); 131 void _endhosthtent(struct hostent_data *); 132 void _endnetdnsent(void); 133 void _endnethtent(struct netent_data *); 134 struct hostent *_gethostbynisaddr(const char *, int, int); 135 struct hostent *_gethostbynisname(const char *, int); 136 void _map_v4v6_address(const char *, char *); 137 void _map_v4v6_hostent(struct hostent *, char **, char *); 138 void _sethostdnsent(int); 139 void _sethosthtent(int, struct hostent_data *); 140 void _setnetdnsent(int); 141 void _setnethtent(int, struct netent_data *); 142 void endhostent_r(struct hostent_data *); 143 void endnetent_r(struct netent_data *); 144 void endprotoent_r(struct protoent_data *); 145 void endservent_r(struct servent_data *); 146 int gethostbyaddr_r(const char *, int, int, struct hostent *, 147 struct hostent_data *); 148 int gethostbyname_r(const char *, struct hostent *, struct hostent_data *); 149 int gethostbyname2_r(const char *, int, struct hostent *, 150 struct hostent_data *); 151 int gethostent_r(struct hostent *, struct hostent_data *); 152 int getnetbyaddr_r(uint32_t addr, int af, struct netent *, 153 struct netent_data *); 154 int getnetbyname_r(const char *, struct netent *, struct netent_data *); 155 int getnetent_r(struct netent *, struct netent_data *); 156 int getprotobyname_r(const char *, struct protoent *, struct protoent_data *); 157 int getprotobynumber_r(int, struct protoent *, struct protoent_data *); 158 int getprotoent_r(struct protoent *, struct protoent_data *); 159 int getservbyname_r(const char *, const char *, struct servent *, 160 struct servent_data *); 161 int getservbyport_r(int, const char *, struct servent *, 162 struct servent_data *); 163 int getservent_r(struct servent *, struct servent_data *); 164 void sethostent_r(int, struct hostent_data *); 165 void setnetent_r(int, struct netent_data *); 166 void setprotoent_r(int, struct protoent_data *); 167 void setservent_r(int, struct servent_data *); 168 169 #endif /* _NETDB_PRIVATE_H_ */ 170