xref: /openbsd/include/rpcsvc/yp_prot.h (revision f2dfb0a4)
1 /*	$OpenBSD: yp_prot.h,v 1.2 1997/09/21 10:46:19 niklas Exp $	*/
2 /*	$NetBSD: yp_prot.h,v 1.6 1995/07/14 21:10:58 christos Exp $	*/
3 
4 /*
5  * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. All advertising materials mentioning features or use of this software
17  *    must display the following acknowledgement:
18  *	This product includes software developed by Theo de Raadt.
19  * 4. The name of the author may not be used to endorse or promote products
20  *    derived from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
23  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
26  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  */
34 
35 #ifndef _RPCSVC_YP_PROT_H_
36 #define _RPCSVC_YP_PROT_H_
37 
38 /*
39  * YPSERV PROTOCOL:
40  *
41  * ypserv supports the following procedures:
42  *
43  * YPPROC_NULL		takes (void), returns (void).
44  * 			called to check if server is alive.
45  * YPPROC_DOMAIN	takes (char *), returns (bool_t).
46  * 			true if ypserv serves the named domain.
47  * YPPROC_DOMAIN_NOACK	takes (char *), returns (bool_t).
48  * 			true if ypserv serves the named domain.
49  *			used for broadcasts, does not ack if ypserv
50  *			doesn't handle named domain.
51  * YPPROC_MATCH		takes (struct ypreq_key), returns (struct ypresp_val)
52  * 			does a lookup.
53  * YPPROC_FIRST		takes (struct ypreq_nokey) returns (ypresp_key_val).
54  * 			gets the first key/datum from the map.
55  * YPPROC_NEXT		takes (struct ypreq_key) returns (ypresp_key_val).
56  * 			gets the next key/datum from the map.
57  * YPPROC_XFR		takes (struct ypreq_xfr), returns (void).
58  * 			tells ypserv to check if there is a new version of
59  *			the map.
60  * YPPROC_CLEAR		takes (void), returns (void).
61  * 			tells ypserv to flush it's file cache, so that
62  *			newly transferred files will get read.
63  * YPPROC_ALL		takes (struct ypreq_nokey), returns (bool_t and
64  *			struct ypresp_key_val).
65  * 			returns an array of data, with the bool_t being
66  * 			false on the last datum. read the source, it's
67  *			convoluted.
68  * YPPROC_MASTER	takes (struct ypreq_nokey), returns (ypresp_master).
69  * YPPROC_ORDER		takes (struct ypreq_nokey), returns (ypresp_order).
70  * YPPROC_MAPLIST	takes (char *), returns (struct ypmaplist *).
71  */
72 
73 #ifndef BOOL_DEFINED
74 typedef u_int bool;
75 #define BOOL_DEFINED
76 #endif
77 
78 
79 /* Program and version symbols, magic numbers */
80 #define YPPROG		((u_long)100004)
81 #define YPVERS		((u_long)2)
82 #define YPVERS_ORIG	((u_long)1)
83 #define YPMAXRECORD	((u_long)1024)
84 #define YPMAXDOMAIN	((u_long)64)
85 #define YPMAXMAP	((u_long)64)
86 #define YPMAXPEER	((u_long)256)
87 
88 /*
89  * I don't know if anything of sun's depends on this, or if they
90  * simply defined it so that their own code wouldn't try to send
91  * packets over the ethernet MTU. This YP code doesn't use it.
92  */
93 #define YPMSGSZ		1600
94 
95 #ifndef DATUM
96 typedef struct {
97 	const char	*dptr;
98 	int		 dsize;
99 } datum;
100 #define DATUM
101 #endif
102 
103 struct ypmap_parms {
104 	const char *domain;
105 	const char *map;
106 	u_long ordernum;
107 	char *owner;
108 };
109 
110 struct ypreq_key {
111 	const char *domain;
112 	const char *map;
113 	datum keydat;
114 };
115 
116 struct ypreq_nokey {
117 	const char *domain;
118 	const char *map;
119 };
120 
121 struct ypreq_xfr {
122 	struct ypmap_parms map_parms;
123 	u_long transid;
124 	u_long proto;
125 	u_short port;
126 };
127 #define ypxfr_domain	map_parms.domain
128 #define ypxfr_map	map_parms.map
129 #define ypxfr_ordernum	map_parms.ordernum
130 #define ypxfr_owner	map_parms.owner
131 
132 struct ypresp_val {
133 	u_long status;
134 	datum valdat;
135 };
136 
137 struct ypresp_key_val {
138 	u_long status;
139 	datum keydat;
140 	datum valdat;
141 };
142 
143 struct ypresp_master {
144 	u_long status;
145 	char *master;
146 };
147 
148 struct ypresp_order {
149 	u_long status;
150 	u_long ordernum;
151 };
152 
153 struct ypresp_all {
154 	bool_t more;
155 	union {
156 		struct ypresp_key_val val;
157 	} ypresp_all_u;
158 };
159 
160 struct ypmaplist {
161 	char ypml_name[YPMAXMAP + 1];
162 	struct ypmaplist *ypml_next;
163 };
164 
165 struct ypresp_maplist {
166 	u_long status;
167 	struct ypmaplist *list;
168 };
169 
170 /* ypserv procedure numbers */
171 #define YPPROC_NULL		((u_long)0)
172 #define YPPROC_DOMAIN		((u_long)1)
173 #define YPPROC_DOMAIN_NONACK	((u_long)2)
174 #define YPPROC_MATCH		((u_long)3)
175 #define YPPROC_FIRST		((u_long)4)
176 #define YPPROC_NEXT		((u_long)5)
177 #define YPPROC_XFR		((u_long)6)
178 #define YPPROC_CLEAR		((u_long)7)
179 #define YPPROC_ALL		((u_long)8)
180 #define YPPROC_MASTER		((u_long)9)
181 #define YPPROC_ORDER		((u_long)10)
182 #define YPPROC_MAPLIST		((u_long)11)
183 
184 /* ypserv procedure return status values */
185 #define YP_TRUE	 	((long)1)	/* general purpose success code */
186 #define YP_NOMORE 	((long)2)	/* no more entries in map */
187 #define YP_FALSE 	((long)0)	/* general purpose failure code */
188 #define YP_NOMAP 	((long)-1)	/* no such map in domain */
189 #define YP_NODOM 	((long)-2)	/* domain not supported */
190 #define YP_NOKEY 	((long)-3)	/* no such key in map */
191 #define YP_BADOP 	((long)-4)	/* invalid operation */
192 #define YP_BADDB 	((long)-5)	/* server data base is bad */
193 #define YP_YPERR 	((long)-6)	/* YP server error */
194 #define YP_BADARGS 	((long)-7)	/* request arguments bad */
195 #define YP_VERS		((long)-8)	/* YP server version mismatch */
196 
197 /*
198  * Sun's header file says:
199  * "Domain binding data structure, used by ypclnt package and ypserv modules.
200  * Users of the ypclnt package (or of this protocol) don't HAVE to know about
201  * it, but it must be available to users because _yp_dobind is a public
202  * interface."
203  *
204  * This is totally bogus! Nowhere else does Sun state that _yp_dobind() is
205  * a public interface, and I don't know any reason anyone would want to call
206  * it. But, just in case anyone does actually expect it to be available..
207  * we provide this.. exactly as Sun wants it.
208  */
209 struct dom_binding {
210 	struct dom_binding *dom_pnext;
211 	char dom_domain[YPMAXDOMAIN + 1];
212 	struct sockaddr_in dom_server_addr;
213 	u_short dom_server_port;
214 	int dom_socket;
215 	CLIENT *dom_client;
216 	u_short dom_local_port;
217 	long dom_vers;
218 };
219 
220 /*
221  * YPBIND PROTOCOL:
222  *
223  * ypbind supports the following procedures:
224  *
225  * YPBINDPROC_NULL	takes (void), returns (void).
226  *			to check if ypbind is running.
227  * YPBINDPROC_DOMAIN	takes (char *), returns (struct ypbind_resp).
228  *			requests that ypbind start to serve the
229  *			named domain (if it doesn't already)
230  * YPBINDPROC_SETDOM	takes (struct ypbind_setdom), returns (void).
231  *			used by ypset.
232  */
233 
234 #define YPBINDPROG		((u_long)100007)
235 #define YPBINDVERS		((u_long)2)
236 #define YPBINDVERS_ORIG		((u_long)1)
237 
238 /* ypbind procedure numbers */
239 #define YPBINDPROC_NULL		((u_long)0)
240 #define YPBINDPROC_DOMAIN	((u_long)1)
241 #define YPBINDPROC_SETDOM	((u_long)2)
242 
243 /* error code in ypbind_resp.ypbind_status */
244 enum ypbind_resptype {
245 	YPBIND_SUCC_VAL = 1,
246 	YPBIND_FAIL_VAL = 2
247 };
248 
249 /* network order, of course */
250 struct ypbind_binding {
251 	struct in_addr	ypbind_binding_addr;
252 	u_short		ypbind_binding_port;
253 };
254 
255 struct ypbind_resp {
256 	enum ypbind_resptype	ypbind_status;
257 	union {
258 		u_long			ypbind_error;
259 		struct ypbind_binding	ypbind_bindinfo;
260 	} ypbind_respbody;
261 };
262 
263 /* error code in ypbind_resp.ypbind_respbody.ypbind_error */
264 #define YPBIND_ERR_ERR		1	/* internal error */
265 #define YPBIND_ERR_NOSERV	2	/* no bound server for passed domain */
266 #define YPBIND_ERR_RESC		3	/* system resource allocation failure */
267 
268 /*
269  * Request data structure for ypbind "Set domain" procedure.
270  */
271 struct ypbind_setdom {
272 	char ypsetdom_domain[YPMAXDOMAIN + 1];
273 	struct ypbind_binding ypsetdom_binding;
274 	u_short ypsetdom_vers;
275 };
276 #define ypsetdom_addr ypsetdom_binding.ypbind_binding_addr
277 #define ypsetdom_port ypsetdom_binding.ypbind_binding_port
278 
279 /*
280  * YPPUSH PROTOCOL:
281  *
282  * Sun says:
283  * "Protocol between clients (ypxfr, only) and yppush
284  *  yppush speaks a protocol in the transient range, which
285  *  is supplied to ypxfr as a command-line parameter when it
286  *  is activated by ypserv."
287  *
288  * This protocol is not implimented, naturally, because this YP
289  * implimentation only does the client side.
290  */
291 #define YPPUSHVERS		((u_long)1)
292 #define YPPUSHVERS_ORIG		((u_long)1)
293 
294 /* yppush procedure numbers */
295 #define YPPUSHPROC_NULL		((u_long)0)
296 #define YPPUSHPROC_XFRRESP	((u_long)1)
297 
298 struct yppushresp_xfr {
299 	u_long	transid;
300 	u_long	status;
301 };
302 
303 /* yppush status value in yppushresp_xfr.status */
304 #define YPPUSH_SUCC	((long)1)	/* Success */
305 #define YPPUSH_AGE	((long)2)	/* Master's version not newer */
306 #define YPPUSH_NOMAP 	((long)-1)	/* Can't find server for map */
307 #define YPPUSH_NODOM 	((long)-2)	/* Domain not supported */
308 #define YPPUSH_RSRC 	((long)-3)	/* Local resouce alloc failure */
309 #define YPPUSH_RPC 	((long)-4)	/* RPC failure talking to server */
310 #define YPPUSH_MADDR	((long)-5)	/* Can't get master address */
311 #define YPPUSH_YPERR 	((long)-6)	/* YP server/map db error */
312 #define YPPUSH_BADARGS 	((long)-7)	/* Request arguments bad */
313 #define YPPUSH_DBM	((long)-8)	/* Local dbm operation failed */
314 #define YPPUSH_FILE	((long)-9)	/* Local file I/O operation failed */
315 #define YPPUSH_SKEW	((long)-10)	/* Map version skew during transfer */
316 #define YPPUSH_CLEAR	((long)-11)	/* Can't send "Clear" req to local ypserv */
317 #define YPPUSH_FORCE	((long)-12)	/* No local order number in map - use -f */
318 #define YPPUSH_XFRERR	((long)-13)	/* ypxfr error */
319 #define YPPUSH_REFUSED	((long)-14)	/* Transfer request refused by ypserv */
320 
321 __BEGIN_DECLS
322 bool_t xdr_domainname __P((XDR *, char *));
323 bool_t xdr_peername __P((XDR *, char *));
324 bool_t xdr_datum __P((XDR *, datum *));
325 bool_t xdr_mapname __P((XDR *, char *));
326 bool_t xdr_ypreq_key __P((XDR *, struct ypreq_key *));
327 bool_t xdr_ypreq_nokey __P((XDR *, struct ypreq_nokey *));
328 bool_t xdr_yp_inaddr __P((XDR *, struct in_addr *));
329 bool_t xdr_ypbind_binding __P((XDR *, struct ypbind_binding *));
330 bool_t xdr_ypbind_resptype __P((XDR *, enum ypbind_resptype *));
331 bool_t xdr_ypstat __P((XDR *, enum ypbind_resptype *));
332 bool_t xdr_ypbind_resp __P((XDR *, struct ypbind_resp *));
333 bool_t xdr_ypresp_val __P((XDR *, struct ypresp_val *));
334 bool_t xdr_ypbind_setdom __P((XDR *, struct ypbind_setdom *));
335 bool_t xdr_ypresp_key_val __P((XDR *, struct ypresp_key_val *));
336 bool_t xdr_ypresp_all __P((XDR *, struct ypresp_all *));
337 bool_t xdr_ypresp_all_seq __P((XDR *, u_long *));
338 bool_t xdr_ypresp_master __P((XDR *, struct ypresp_master *));
339 bool_t xdr_ypmaplist_str __P((XDR *, char *));
340 bool_t xdr_ypmaplist __P((XDR *, struct ypmaplist *));
341 bool_t xdr_ypresp_maplist __P((XDR *, struct ypresp_maplist *));
342 bool_t xdr_ypresp_order __P((XDR *, struct ypresp_order *));
343 __END_DECLS
344 
345 #endif /* _RPCSVC_YP_PROT_H_ */
346