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