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