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