xref: /freebsd/lib/libc/net/netdb_private.h (revision a2a775011ce266113bd38d22d618fa6258d4d8cb)
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	_NETBUFSIZE	1025
37 
38 struct netent_data {
39 	char *net_aliases[_MAXALIASES];
40 	char netbuf[_NETBUFSIZE];
41 	FILE *netf;
42 	int stayopen;
43 #ifdef YP
44 	char *yp_domain;
45 #endif
46 };
47 
48 struct protoent_data {
49 	FILE *fp;
50 	char *aliases[_MAXALIASES];
51 	int stayopen;
52 	char line[_MAXLINELEN + 1];
53 };
54 
55 struct servent_data {
56 	FILE *fp;
57 	char *aliases[_MAXALIASES];
58 	int stayopen;
59 	char line[_MAXLINELEN + 1];
60 #ifdef YP
61 	int yp_stepping;
62 	char *yp_name;
63 	char *yp_proto;
64 	int yp_port;
65 	char *yp_domain;
66 	char *yp_key;
67 	int yp_keylen;
68 #endif
69 };
70 
71 struct netdata {
72 	struct netent net;
73 	struct netent_data data;
74 };
75 
76 struct protodata {
77 	struct protoent proto;
78 	struct protoent_data data;
79 };
80 
81 struct servdata {
82 	struct servent serv;
83 	struct servent_data data;
84 };
85 
86 #define	endnetent_r		__endnetent_r
87 #define	endprotoent_r		__endprotoent_r
88 #define	endservent_r		__endservent_r
89 #define	getnetbyaddr_r		__getnetbyaddr_r
90 #define	getnetbyname_r		__getnetbyname_r
91 #define	getnetent_r		__getnetent_r
92 #define	getprotobyname_r	__getprotobyname_r
93 #define	getprotobynumber_r	__getprotobynumber_r
94 #define	getprotoent_r		__getprotoent_r
95 #define	getservbyname_r		__getservbyname_r
96 #define	getservbyport_r		__getservbyport_r
97 #define	getservent_r		__getservent_r
98 #define	setnetent_r		__setnetent_r
99 #define	setprotoent_r		__setprotoent_r
100 #define	setservent_r		__setservent_r
101 
102 struct netdata *__netdata_init(void);
103 struct protodata *__protodata_init(void);
104 struct servdata *__servdata_init(void);
105 void _endhostdnsent(void);
106 void _endhosthtent(void);
107 void _endnetdnsent(void);
108 void _endnethtent(struct netent_data *);
109 struct hostent *_gethostbynisaddr(const char *, int, int);
110 struct hostent *_gethostbynisname(const char *, int);
111 void _map_v4v6_address(const char *, char *);
112 void _map_v4v6_hostent(struct hostent *, char **, char **);
113 void _sethostdnsent(int);
114 void _sethosthtent(int);
115 void _setnetdnsent(int);
116 void _setnethtent(int, struct netent_data *);
117 void endnetent_r(struct netent_data *);
118 void endprotoent_r(struct protoent_data *);
119 void endservent_r(struct servent_data *);
120 int getnetbyaddr_r(unsigned long addr, int af, struct netent *,
121 	struct netent_data *);
122 int getnetbyname_r(const char *, struct netent *, struct netent_data *);
123 int getnetent_r(struct netent *, struct netent_data *);
124 int getprotobyname_r(const char *, struct protoent *, struct protoent_data *);
125 int getprotobynumber_r(int, struct protoent *, struct protoent_data *);
126 int getprotoent_r(struct protoent *, struct protoent_data *);
127 int getservbyname_r(const char *, const char *, struct servent *,
128 	struct servent_data *);
129 int getservbyport_r(int, const char *, struct servent *,
130 	struct servent_data *);
131 int getservent_r(struct servent *, struct servent_data *);
132 void setnetent_r(int, struct netent_data *);
133 void setprotoent_r(int, struct protoent_data *);
134 void setservent_r(int, struct servent_data *);
135 
136 #endif /* _NETDB_PRIVATE_H_ */
137