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