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
36const YPMAXRECORD = 16777216;
37const YPMAXDOMAIN = 64;
38const YPMAXMAP = 64;
39const YPMAXPEER = 64;
40
41
42enum ypstat {
43 YP_TRUE = 1,
44 YP_NOMORE = 2,
45 YP_FALSE = 0,
46 YP_NOMAP = -1,
47 YP_NODOM = -2,
48 YP_NOKEY = -3,
49 YP_BADOP = -4,
50 YP_BADDB = -5,
51 YP_YPERR = -6,
52 YP_BADARGS = -7,
53 YP_VERS = -8
54};
55
56
57enum ypxfrstat {
58 YPXFR_SUCC = 1,
59 YPXFR_AGE = 2,
60 YPXFR_NOMAP = -1,
61 YPXFR_NODOM = -2,
62 YPXFR_RSRC = -3,
63 YPXFR_RPC = -4,
64 YPXFR_MADDR = -5,
65 YPXFR_YPERR = -6,
66 YPXFR_BADARGS = -7,
67 YPXFR_DBM = -8,
68 YPXFR_FILE = -9,
69 YPXFR_SKEW = -10,
70 YPXFR_CLEAR = -11,
71 YPXFR_FORCE = -12,
72 YPXFR_XFRERR = -13,
73 YPXFR_REFUSED = -14
74};
75
76
77typedef string domainname<YPMAXDOMAIN>;
78typedef string mapname<YPMAXMAP>;
79typedef string peername<YPMAXPEER>;
80typedef opaque keydat<YPMAXRECORD>;
81typedef opaque valdat<YPMAXRECORD>;
82
83
84struct ypmap_parms {
85 domainname domain;
86 mapname map;
87 unsigned int ordernum;
88 peername peer;
89};
90
91struct ypreq_key {
92 domainname domain;
93 mapname map;
94 keydat key;
95};
96
97struct ypreq_nokey {
98 domainname domain;
99 mapname map;
100};
101
102struct ypreq_xfr {
103 ypmap_parms map_parms;
104 unsigned int transid;
105 unsigned int prog;
106 unsigned int port;
107};
108
109
110struct ypresp_val {
111 ypstat stat;
112 valdat val;
113};
114
115struct ypresp_key_val {
116 ypstat stat;
117#ifdef STUPID_SUN_BUG /* These are backwards */
118 keydat key;
119 valdat val;
120#else
121 valdat val;
122 keydat key;
123#endif
124};
125
126
127struct ypresp_master {
128 ypstat stat;
129 peername peer;
130};
131
132struct ypresp_order {
133 ypstat stat;
134 unsigned int ordernum;
135};
136
137union ypresp_all switch (bool more) {
138case TRUE:
139 ypresp_key_val val;
140case FALSE:
141 void;
142};
143
144struct ypresp_xfr {
145 unsigned int transid;
146 ypxfrstat xfrstat;
147};
148
149struct ypmaplist {
150 mapname map;
151 ypmaplist *next;
152};
153
154struct ypresp_maplist {
155 ypstat stat;
156 ypmaplist *maps;
157};
158
159enum yppush_status {
160 YPPUSH_SUCC = 1, /* Success */
161 YPPUSH_AGE = 2, /* Master's version not newer */
162 YPPUSH_NOMAP = -1, /* Can't find server for map */
163 YPPUSH_NODOM = -2, /* Domain not supported */
164 YPPUSH_RSRC = -3, /* Local resource alloc failure */
165 YPPUSH_RPC = -4, /* RPC failure talking to server */
166 YPPUSH_MADDR = -5, /* Can't get master address */
167 YPPUSH_YPERR = -6, /* YP server/map db error */
168 YPPUSH_BADARGS = -7, /* Request arguments bad */
169 YPPUSH_DBM = -8, /* Local dbm operation failed */
170 YPPUSH_FILE = -9, /* Local file I/O operation failed */
171 YPPUSH_SKEW = -10, /* Map version skew during transfer */
172 YPPUSH_CLEAR = -11, /* Can't send "Clear" req to local ypserv */
173 YPPUSH_FORCE = -12, /* No local order number in map use -f flag. */
174 YPPUSH_XFRERR = -13, /* ypxfr error */
175 YPPUSH_REFUSED = -14 /* Transfer request refused by ypserv */
176};
177
178struct yppushresp_xfr {
179 unsigned transid;
180 yppush_status status;
181};
182
183/*
184 * Response structure and overall result status codes. Success and failure
185 * represent two separate response message types.
186 */
187
188enum ypbind_resptype {
189 YPBIND_SUCC_VAL = 1,
190 YPBIND_FAIL_VAL = 2
191};
192
193struct ypbind_binding {
194 opaque ypbind_binding_addr[4]; /* In network order */
195 opaque ypbind_binding_port[2]; /* In network order */
196};
197
198union ypbind_resp switch (ypbind_resptype ypbind_status) {
199case YPBIND_FAIL_VAL:
200 unsigned ypbind_error;
201case YPBIND_SUCC_VAL:
202 ypbind_binding ypbind_bindinfo;
203};
204
205/* Detailed failure reason codes for response field ypbind_error*/
206
207const YPBIND_ERR_ERR = 1; /* Internal error */
208const YPBIND_ERR_NOSERV = 2; /* No bound server for passed domain */
209const YPBIND_ERR_RESC = 3; /* System resource allocation failure */
210
211
212/*
213 * Request data structure for ypbind "Set domain" procedure.
214 */
215struct ypbind_setdom {
216 domainname ypsetdom_domain;
217 ypbind_binding ypsetdom_binding;
218 unsigned ypsetdom_vers;
219};
220
221
222/*
223 * NIS v1 support for backwards compatibility
224 */
225enum ypreqtype {
226 YPREQ_KEY = 1,
227 YPREQ_NOKEY = 2,
228 YPREQ_MAP_PARMS = 3
229};
230
231enum ypresptype {
232 YPRESP_VAL = 1,
233 YPRESP_KEY_VAL = 2,
234 YPRESP_MAP_PARMS = 3
235};
236
237union yprequest switch (ypreqtype yp_reqtype) {
238case YPREQ_KEY:
239 ypreq_key yp_req_keytype;
240case YPREQ_NOKEY:
241 ypreq_nokey yp_req_nokeytype;
242case YPREQ_MAP_PARMS:
243 ypmap_parms yp_req_map_parmstype;
244};
245
246union ypresponse switch (ypresptype yp_resptype) {
247case YPRESP_VAL:
248 ypresp_val yp_resp_valtype;
249case YPRESP_KEY_VAL:
250 ypresp_key_val yp_resp_key_valtype;
251case YPRESP_MAP_PARMS:
252 ypmap_parms yp_resp_map_parmstype;
253};
254
255#if !defined(YPBIND_ONLY) && !defined(YPPUSH_ONLY)
256/*
257 * YP access protocol
258 */
259program YPPROG {
260/*
261 * NIS v1 support for backwards compatibility
262 */
263 version YPOLDVERS {
264 void
265 YPOLDPROC_NULL(void) = 0;
266
267 bool
268 YPOLDPROC_DOMAIN(domainname) = 1;
269
270 bool
271 YPOLDPROC_DOMAIN_NONACK(domainname) = 2;
272
273 ypresponse
274 YPOLDPROC_MATCH(yprequest) = 3;
275
276 ypresponse
277 YPOLDPROC_FIRST(yprequest) = 4;
278
279 ypresponse
280 YPOLDPROC_NEXT(yprequest) = 5;
281
282 ypresponse
283 YPOLDPROC_POLL(yprequest) = 6;
284
285 ypresponse
286 YPOLDPROC_PUSH(yprequest) = 7;
287
288 ypresponse
289 YPOLDPROC_PULL(yprequest) = 8;
290
291 ypresponse
292 YPOLDPROC_GET(yprequest) = 9;
293 } = 1;
294
295 version YPVERS {
296 void
297 YPPROC_NULL(void) = 0;
298
299 bool
300 YPPROC_DOMAIN(domainname) = 1;
301
302 bool
303 YPPROC_DOMAIN_NONACK(domainname) = 2;
304
305 ypresp_val
306 YPPROC_MATCH(ypreq_key) = 3;
307
308 ypresp_key_val
309#ifdef STUPID_SUN_BUG /* should be ypreq_nokey */
310 YPPROC_FIRST(ypreq_key) = 4;
311#else
312 YPPROC_FIRST(ypreq_nokey) = 4;
313#endif
314 ypresp_key_val
315 YPPROC_NEXT(ypreq_key) = 5;
316
317 ypresp_xfr
318 YPPROC_XFR(ypreq_xfr) = 6;
319
320 void
321 YPPROC_CLEAR(void) = 7;
322
323 ypresp_all
324 YPPROC_ALL(ypreq_nokey) = 8;
325
326 ypresp_master
327 YPPROC_MASTER(ypreq_nokey) = 9;
328
329 ypresp_order
330 YPPROC_ORDER(ypreq_nokey) = 10;
331
332 ypresp_maplist
333 YPPROC_MAPLIST(domainname) = 11;
334 } = 2;
335} = 100004;
336#endif
337#if !defined(YPSERV_ONLY) && !defined(YPBIND_ONLY)
338/*
339 * YPPUSHPROC_XFRRESP is the callback routine for result of YPPROC_XFR
340 */
341program YPPUSH_XFRRESPPROG {
342 version YPPUSH_XFRRESPVERS {
343 void
344 YPPUSHPROC_NULL(void) = 0;
345#ifdef STUPID_SUN_BUG /* argument and return value are backwards */
346 yppushresp_xfr
347 YPPUSHPROC_XFRRESP(void) = 1;
348#else
349 void
350 YPPUSHPROC_XFRRESP(yppushresp_xfr) = 1;
351#endif
352 } = 1;
353} = 0x40000000; /* transient: could be anything up to 0x5fffffff */
354#endif
355#if !defined(YPSERV_ONLY) && !defined(YPPUSH_ONLY)
356/*
357 * YP binding protocol
358 */
359program YPBINDPROG {
360 version YPBINDVERS {
361 void
362 YPBINDPROC_NULL(void) = 0;
363
364 ypbind_resp
365 YPBINDPROC_DOMAIN(domainname) = 1;
366
367 void
368 YPBINDPROC_SETDOM(ypbind_setdom) = 2;
369 } = 2;
370} = 100007;
371
372#endif