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