xref: /freebsd/include/rpcsvc/yp.x (revision edf8578117e8844e02c0121147f45e4609b30680)
1 /* @(#)yp.x	2.1 88/08/01 4.0 RPCSRC */
2 
3 /*-
4  * Copyright (c) 2010, Oracle America, Inc.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  *     * Redistributions of source code must retain the above copyright
11  *       notice, this list of conditions and the following disclaimer.
12  *     * Redistributions in binary form must reproduce the above
13  *       copyright notice, this list of conditions and the following
14  *       disclaimer in the documentation and/or other materials
15  *       provided with the distribution.
16  *     * Neither the name of the "Oracle America, Inc." nor the names of its
17  *       contributors may be used to endorse or promote products derived
18  *       from this software without specific prior written permission.
19  *
20  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23  *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24  *   COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
25  *   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
27  *   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29  *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30  *   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 /*
35  * Protocol description file for the Yellow Pages Service
36  */
37 
38 #ifndef RPC_HDR
39 %#include <sys/cdefs.h>
40 #endif
41 
42 const YPMAXRECORD = 16777216;
43 const YPMAXDOMAIN = 64;
44 const YPMAXMAP = 64;
45 const YPMAXPEER = 64;
46 
47 
48 enum ypstat {
49 	YP_TRUE		=  1,
50 	YP_NOMORE	=  2,
51 	YP_FALSE	=  0,
52 	YP_NOMAP	= -1,
53 	YP_NODOM	= -2,
54 	YP_NOKEY	= -3,
55 	YP_BADOP	= -4,
56 	YP_BADDB	= -5,
57 	YP_YPERR	= -6,
58 	YP_BADARGS	= -7,
59 	YP_VERS		= -8
60 };
61 
62 
63 enum ypxfrstat {
64 	YPXFR_SUCC	=  1,
65 	YPXFR_AGE	=  2,
66 	YPXFR_NOMAP	= -1,
67 	YPXFR_NODOM	= -2,
68 	YPXFR_RSRC	= -3,
69 	YPXFR_RPC	= -4,
70 	YPXFR_MADDR	= -5,
71 	YPXFR_YPERR	= -6,
72 	YPXFR_BADARGS	= -7,
73 	YPXFR_DBM	= -8,
74 	YPXFR_FILE	= -9,
75 	YPXFR_SKEW	= -10,
76 	YPXFR_CLEAR	= -11,
77 	YPXFR_FORCE	= -12,
78 	YPXFR_XFRERR	= -13,
79 	YPXFR_REFUSED	= -14
80 };
81 
82 
83 typedef string domainname<YPMAXDOMAIN>;
84 typedef string mapname<YPMAXMAP>;
85 typedef string peername<YPMAXPEER>;
86 typedef opaque keydat<YPMAXRECORD>;
87 typedef opaque valdat<YPMAXRECORD>;
88 
89 
90 struct ypmap_parms {
91 	domainname domain;
92 	mapname map;
93 	unsigned int ordernum;
94 	peername peer;
95 };
96 
97 struct ypreq_key {
98 	domainname domain;
99 	mapname map;
100 	keydat key;
101 };
102 
103 struct ypreq_nokey {
104 	domainname domain;
105 	mapname map;
106 };
107 
108 struct ypreq_xfr {
109 	ypmap_parms map_parms;
110 	unsigned int transid;
111 	unsigned int prog;
112 	unsigned int port;
113 };
114 
115 
116 struct ypresp_val {
117 	ypstat stat;
118 	valdat val;
119 };
120 
121 struct ypresp_key_val {
122 	ypstat stat;
123 #ifdef STUPID_SUN_BUG /* These are backwards */
124 	keydat key;
125 	valdat val;
126 #else
127 	valdat val;
128 	keydat key;
129 #endif
130 };
131 
132 
133 struct ypresp_master {
134 	ypstat stat;
135 	peername peer;
136 };
137 
138 struct ypresp_order {
139 	ypstat stat;
140 	unsigned int ordernum;
141 };
142 
143 union ypresp_all switch (bool more) {
144 case TRUE:
145 	ypresp_key_val val;
146 case FALSE:
147 	void;
148 };
149 
150 struct ypresp_xfr {
151 	unsigned int transid;
152 	ypxfrstat xfrstat;
153 };
154 
155 struct ypmaplist {
156 	mapname map;
157 	ypmaplist *next;
158 };
159 
160 struct ypresp_maplist {
161 	ypstat stat;
162 	ypmaplist *maps;
163 };
164 
165 enum yppush_status {
166 	YPPUSH_SUCC	=  1,	/* Success */
167 	YPPUSH_AGE 	=  2,	/* Master's version not newer */
168 	YPPUSH_NOMAP	= -1,	/* Can't find server for map */
169 	YPPUSH_NODOM	= -2,	/* Domain not supported */
170 	YPPUSH_RSRC	= -3,	/* Local resource alloc failure */
171 	YPPUSH_RPC	= -4,	/* RPC failure talking to server */
172 	YPPUSH_MADDR 	= -5,	/* Can't get master address */
173 	YPPUSH_YPERR	= -6,	/* YP server/map db error */
174 	YPPUSH_BADARGS	= -7,	/* Request arguments bad */
175 	YPPUSH_DBM	= -8,	/* Local dbm operation failed */
176 	YPPUSH_FILE	= -9,	/* Local file I/O operation failed */
177 	YPPUSH_SKEW	= -10,	/* Map version skew during transfer */
178 	YPPUSH_CLEAR	= -11,	/* Can't send "Clear" req to local ypserv */
179 	YPPUSH_FORCE	= -12,	/* No local order number in map  use -f flag. */
180 	YPPUSH_XFRERR 	= -13,	/* ypxfr error */
181 	YPPUSH_REFUSED	= -14 	/* Transfer request refused by ypserv */
182 };
183 
184 struct yppushresp_xfr {
185 	unsigned transid;
186 	yppush_status status;
187 };
188 
189 /*
190  * Response structure and overall result status codes.  Success and failure
191  * represent two separate response message types.
192  */
193 
194 enum ypbind_resptype {
195 	YPBIND_SUCC_VAL = 1,
196 	YPBIND_FAIL_VAL = 2
197 };
198 
199 struct ypbind_binding {
200     opaque ypbind_binding_addr[4]; /* In network order */
201     opaque ypbind_binding_port[2]; /* In network order */
202 };
203 
204 union ypbind_resp switch (ypbind_resptype ypbind_status) {
205 case YPBIND_FAIL_VAL:
206         unsigned ypbind_error;
207 case YPBIND_SUCC_VAL:
208         ypbind_binding ypbind_bindinfo;
209 };
210 
211 /* Detailed failure reason codes for response field ypbind_error*/
212 
213 const YPBIND_ERR_ERR    = 1;	/* Internal error */
214 const YPBIND_ERR_NOSERV = 2;	/* No bound server for passed domain */
215 const YPBIND_ERR_RESC   = 3;	/* System resource allocation failure */
216 
217 
218 /*
219  * Request data structure for ypbind "Set domain" procedure.
220  */
221 struct ypbind_setdom {
222 	domainname ypsetdom_domain;
223 	ypbind_binding ypsetdom_binding;
224 	unsigned ypsetdom_vers;
225 };
226 
227 
228 /*
229  * NIS v1 support for backwards compatibility
230  */
231 enum ypreqtype {
232 	YPREQ_KEY = 1,
233 	YPREQ_NOKEY = 2,
234 	YPREQ_MAP_PARMS = 3
235 };
236 
237 enum ypresptype {
238 	YPRESP_VAL = 1,
239 	YPRESP_KEY_VAL = 2,
240 	YPRESP_MAP_PARMS = 3
241 };
242 
243 union yprequest switch (ypreqtype yp_reqtype) {
244 case YPREQ_KEY:
245 	ypreq_key yp_req_keytype;
246 case YPREQ_NOKEY:
247 	ypreq_nokey yp_req_nokeytype;
248 case YPREQ_MAP_PARMS:
249 	ypmap_parms yp_req_map_parmstype;
250 };
251 
252 union ypresponse switch (ypresptype yp_resptype) {
253 case YPRESP_VAL:
254 	ypresp_val yp_resp_valtype;
255 case YPRESP_KEY_VAL:
256 	ypresp_key_val yp_resp_key_valtype;
257 case YPRESP_MAP_PARMS:
258 	ypmap_parms yp_resp_map_parmstype;
259 };
260 
261 #if !defined(YPBIND_ONLY) && !defined(YPPUSH_ONLY)
262 /*
263  * YP access protocol
264  */
265 program YPPROG {
266 /*
267  * NIS v1 support for backwards compatibility
268  */
269 	version YPOLDVERS {
270 		void
271 		YPOLDPROC_NULL(void) = 0;
272 
273 		bool
274 		YPOLDPROC_DOMAIN(domainname) = 1;
275 
276 		bool
277 		YPOLDPROC_DOMAIN_NONACK(domainname) = 2;
278 
279 		ypresponse
280 		YPOLDPROC_MATCH(yprequest) = 3;
281 
282 		ypresponse
283 		YPOLDPROC_FIRST(yprequest) = 4;
284 
285 		ypresponse
286 		YPOLDPROC_NEXT(yprequest) = 5;
287 
288 		ypresponse
289 		YPOLDPROC_POLL(yprequest) = 6;
290 
291 		ypresponse
292 		YPOLDPROC_PUSH(yprequest) = 7;
293 
294 		ypresponse
295 		YPOLDPROC_PULL(yprequest) = 8;
296 
297 		ypresponse
298 		YPOLDPROC_GET(yprequest) = 9;
299 	} = 1;
300 
301 	version YPVERS {
302 		void
303 		YPPROC_NULL(void) = 0;
304 
305 		bool
306 		YPPROC_DOMAIN(domainname) = 1;
307 
308 		bool
309 		YPPROC_DOMAIN_NONACK(domainname) = 2;
310 
311 		ypresp_val
312 		YPPROC_MATCH(ypreq_key) = 3;
313 
314 		ypresp_key_val
315 #ifdef STUPID_SUN_BUG /* should be ypreq_nokey */
316 		YPPROC_FIRST(ypreq_key) = 4;
317 #else
318 		YPPROC_FIRST(ypreq_nokey) = 4;
319 #endif
320 		ypresp_key_val
321 		YPPROC_NEXT(ypreq_key) = 5;
322 
323 		ypresp_xfr
324 		YPPROC_XFR(ypreq_xfr) = 6;
325 
326 		void
327 		YPPROC_CLEAR(void) = 7;
328 
329 		ypresp_all
330 		YPPROC_ALL(ypreq_nokey) = 8;
331 
332 		ypresp_master
333 		YPPROC_MASTER(ypreq_nokey) = 9;
334 
335 		ypresp_order
336 		YPPROC_ORDER(ypreq_nokey) = 10;
337 
338 		ypresp_maplist
339 		YPPROC_MAPLIST(domainname) = 11;
340 	} = 2;
341 } = 100004;
342 #endif
343 #if !defined(YPSERV_ONLY) && !defined(YPBIND_ONLY)
344 /*
345  * YPPUSHPROC_XFRRESP is the callback routine for result of YPPROC_XFR
346  */
347 program YPPUSH_XFRRESPPROG {
348 	version YPPUSH_XFRRESPVERS {
349 		void
350 		YPPUSHPROC_NULL(void) = 0;
351 #ifdef STUPID_SUN_BUG /* argument and return value are backwards */
352 		yppushresp_xfr
353 		YPPUSHPROC_XFRRESP(void) = 1;
354 #else
355 		void
356 		YPPUSHPROC_XFRRESP(yppushresp_xfr) = 1;
357 #endif
358 	} = 1;
359 } = 0x40000000;	/* transient: could be anything up to 0x5fffffff */
360 #endif
361 #if !defined(YPSERV_ONLY) && !defined(YPPUSH_ONLY)
362 /*
363  * YP binding protocol
364  */
365 program YPBINDPROG {
366 	version YPBINDVERS {
367 		void
368 		YPBINDPROC_NULL(void) = 0;
369 
370 		ypbind_resp
371 		YPBINDPROC_DOMAIN(domainname) = 1;
372 
373 		void
374 		YPBINDPROC_SETDOM(ypbind_setdom) = 2;
375 	} = 2;
376 } = 100007;
377 
378 #endif
379