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