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 <sys/_types.h> 32 #include <stdio.h> /* XXX: for FILE */ 33 34 #ifndef _UINT32_T_DECLARED 35 typedef __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 45 struct 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 57 struct 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 67 struct protoent_data { 68 FILE *fp; 69 char *aliases[_MAXALIASES]; 70 int stayopen; 71 char line[_MAXLINELEN + 1]; 72 }; 73 74 struct 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 90 struct hostdata { 91 struct hostent host; 92 struct hostent_data data; 93 }; 94 95 struct netdata { 96 struct netent net; 97 struct netent_data data; 98 }; 99 100 struct protodata { 101 struct protoent proto; 102 struct protoent_data data; 103 }; 104 105 struct 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 132 struct hostdata *__hostdata_init(void); 133 struct netdata *__netdata_init(void); 134 struct protodata *__protodata_init(void); 135 struct servdata *__servdata_init(void); 136 void _endhostdnsent(void); 137 void _endhosthtent(struct hostent_data *); 138 void _endnetdnsent(void); 139 void _endnethtent(struct netent_data *); 140 struct hostent *_gethostbynisaddr(const char *, int, int); 141 struct hostent *_gethostbynisname(const char *, int); 142 void _map_v4v6_address(const char *, char *); 143 void _map_v4v6_hostent(struct hostent *, char **, char **); 144 void _sethostdnsent(int); 145 void _sethosthtent(int, struct hostent_data *); 146 void _setnetdnsent(int); 147 void _setnethtent(int, struct netent_data *); 148 void endhostent_r(struct hostent_data *); 149 void endnetent_r(struct netent_data *); 150 void endprotoent_r(struct protoent_data *); 151 void endservent_r(struct servent_data *); 152 int gethostbyaddr_r(const char *, int, int, struct hostent *, 153 struct hostent_data *); 154 int gethostbyname_r(const char *, struct hostent *, struct hostent_data *); 155 int gethostbyname2_r(const char *, int, struct hostent *, 156 struct hostent_data *); 157 int gethostent_r(struct hostent *, struct hostent_data *); 158 int getnetbyaddr_r(unsigned long addr, int af, struct netent *, 159 struct netent_data *); 160 int getnetbyname_r(const char *, struct netent *, struct netent_data *); 161 int getnetent_r(struct netent *, struct netent_data *); 162 int getprotobyname_r(const char *, struct protoent *, struct protoent_data *); 163 int getprotobynumber_r(int, struct protoent *, struct protoent_data *); 164 int getprotoent_r(struct protoent *, struct protoent_data *); 165 int getservbyname_r(const char *, const char *, struct servent *, 166 struct servent_data *); 167 int getservbyport_r(int, const char *, struct servent *, 168 struct servent_data *); 169 int getservent_r(struct servent *, struct servent_data *); 170 void sethostent_r(int, struct hostent_data *); 171 void setnetent_r(int, struct netent_data *); 172 void setprotoent_r(int, struct protoent_data *); 173 void setservent_r(int, struct servent_data *); 174 175 #endif /* _NETDB_PRIVATE_H_ */ 176