yp_prot.h revision 90297
1125699Spjd/*
2163872Spjd * Copyright (c) 1992/3 Theo de Raadt <deraadt@fsa.ca>
3125699Spjd * All rights reserved.
4125699Spjd *
5125699Spjd * Redistribution and use in source and binary forms, with or without
6125699Spjd * modification, are permitted provided that the following conditions
7125699Spjd * are met:
8125699Spjd * 1. Redistributions of source code must retain the above copyright
9125699Spjd *    notice, this list of conditions and the following disclaimer.
10125699Spjd * 2. Redistributions in binary form must reproduce the above copyright
11125699Spjd *    notice, this list of conditions and the following disclaimer in the
12125699Spjd *    documentation and/or other materials provided with the distribution.
13125699Spjd * 3. The name of the author may not be used to endorse or promote
14125699Spjd *    products derived from this software without specific prior written
15125699Spjd *    permission.
16125699Spjd *
17125699Spjd * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
18125699Spjd * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19125699Spjd * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20125699Spjd * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
21125699Spjd * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22125699Spjd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23125699Spjd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24125699Spjd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25125699Spjd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26125699Spjd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27163872Spjd * SUCH DAMAGE.
28131689Sru *
29125699Spjd * $FreeBSD: head/include/rpcsvc/yp_prot.h 90297 2002-02-06 13:30:31Z des $
30125699Spjd */
31125699Spjd
32125699Spjd#ifndef _RPCSVC_YP_PROT_H_
33125714Spjd#define _RPCSVC_YP_PROT_H_
34125714Spjd
35129381Sle/*
36125699Spjd * YPSERV PROTOCOL:
37125699Spjd *
38125699Spjd * ypserv supports the following procedures:
39125699Spjd *
40125699Spjd * YPPROC_NULL		takes (void), returns (void).
41125699Spjd * 			called to check if server is alive.
42163872Spjd * YPPROC_DOMAIN	takes (char *), returns (bool_t).
43163872Spjd * 			true if ypserv serves the named domain.
44125699Spjd * YPPROC_DOMAIN_NOACK	takes (char *), returns (bool_t).
45163872Spjd * 			true if ypserv serves the named domain.
46163872Spjd *			used for broadcasts, does not ack if ypserv
47125699Spjd *			doesn't handle named domain.
48125699Spjd * YPPROC_MATCH		takes (struct ypreq_key), returns (struct ypresp_val)
49125714Spjd * 			does a lookup.
50125714Spjd * YPPROC_FIRST		takes (struct ypreq_nokey) returns (ypresp_key_val).
51125699Spjd * 			gets the first key/datum from the map.
52129381Sle * YPPROC_NEXT		takes (struct ypreq_key) returns (ypresp_key_val).
53131689Sru * 			gets the next key/datum from the map.
54129381Sle * YPPROC_XFR		takes (struct ypreq_xfr), returns (void).
55129381Sle * 			tells ypserv to check if there is a new version of
56125699Spjd *			the map.
57125699Spjd * YPPROC_CLEAR		takes (void), returns (void).
58129381Sle * 			tells ypserv to flush it's file cache, so that
59125699Spjd *			newly transferred files will get read.
60131689Sru * YPPROC_ALL		takes (struct ypreq_nokey), returns (bool_t and
61125699Spjd *			struct ypresp_key_val).
62129381Sle * 			returns an array of data, with the bool_t being
63125699Spjd * 			false on the last datum. read the source, it's
64129381Sle *			convoluted.
65125699Spjd * YPPROC_MASTER	takes (struct ypreq_nokey), returns (ypresp_master).
66129381Sle * YPPROC_ORDER		takes (struct ypreq_nokey), returns (ypresp_order).
67125699Spjd * YPPROC_MAPLIST	takes (char *), returns (struct ypmaplist *).
68125699Spjd */
69125699Spjd
70125699Spjd#ifndef BOOL_DEFINED
71125699Spjdtypedef u_int bool;
72125699Spjd#define BOOL_DEFINED
73129387Sle#endif
74125699Spjd
75125699Spjd/* Program and version symbols, magic numbers */
76125699Spjd
77125699Spjd#define YPPROG		((u_long)100004)
78163870Spjd#define YPVERS		((u_long)2)
79163873Spjd#define YPVERS_ORIG	((u_long)1)
80125699Spjd#define YPMAXRECORD	((u_long)1024)
81125699Spjd#define YPMAXDOMAIN	((u_long)64)
82125699Spjd#define YPMAXMAP	((u_long)64)
83133142Spjd#define YPMAXPEER	((u_long)256)
84125699Spjd
85125699Spjd/*
86129381Sle * I don't know if anything of sun's depends on this, or if they
87129381Sle * simply defined it so that their own code wouldn't try to send
88125699Spjd * packets over the ethernet MTU. This YP code doesn't use it.
89125699Spjd */
90125699Spjd#define YPMSGSZ		1600
91133142Spjd
92133142Spjd#ifndef DATUM
93133142Spjdtypedef struct {
94133142Spjd	char	*dptr;
95133142Spjd	int	dsize;
96133142Spjd} datum;
97133142Spjd#define DATUM
98133142Spjd#endif
99125699Spjd
100131689Srustruct ypmap_parms {
101131689Sru	char *domain;
102131689Sru	char *map;
103125699Spjd	u_long ordernum;
104129381Sle	char *owner;
105125699Spjd};
106133142Spjd
107125699Spjdstruct ypreq_key {
108133142Spjd	char *domain;
109125699Spjd	char *map;
110133142Spjd	datum keydat;
111125699Spjd};
112133142Spjd
113125699Spjdstruct ypreq_nokey {
114131689Sru	char *domain;
115131689Sru	char *map;
116131689Sru};
117125699Spjd
118125699Spjdstruct ypreq_xfr {
119125699Spjd	struct ypmap_parms map_parms;
120131689Sru	u_long transid;
121125699Spjd	u_long proto;
122131689Sru	u_short port;
123125699Spjd};
124125699Spjd#define ypxfr_domain	map_parms.domain
125125699Spjd#define ypxfr_map	map_parms.map
126125699Spjd#define ypxfr_ordernum	map_parms.ordernum
127125699Spjd#define ypxfr_owner	map_parms.owner
128125699Spjd
129131689Srustruct ypresp_val {
130131689Sru	u_long status;
131131689Sru	datum valdat;
132125699Spjd};
133131689Sru
134131689Srustruct ypresp_key_val {
135131689Sru	u_long status;
136125699Spjd	datum keydat;
137131689Sru	datum valdat;
138131689Sru};
139125699Spjd
140125699Spjdstruct ypresp_master {
141125699Spjd	u_long status;
142125699Spjd	char *master;
143125699Spjd};
144125699Spjd
145125699Spjdstruct ypresp_order {
146125699Spjd	u_long status;
147163872Spjd	u_long ordernum;
148163872Spjd};
149163872Spjd
150163872Spjdstruct ypmaplist {
151163872Spjd	char ypml_name[YPMAXMAP + 1];
152163872Spjd	struct ypmaplist *ypml_next;
153163872Spjd};
154125699Spjd
155125699Spjdstruct ypresp_maplist {
156125699Spjd	u_long status;
157125699Spjd	struct ypmaplist *list;
158129381Sle};
159125699Spjd
160129381Sle/* ypserv procedure numbers */
161125699Spjd#define YPPROC_NULL		((u_long)0)
162125699Spjd#define YPPROC_DOMAIN		((u_long)1)
163125699Spjd#define YPPROC_DOMAIN_NONACK	((u_long)2)
164125699Spjd#define YPPROC_MATCH		((u_long)3)
165125699Spjd#define YPPROC_FIRST		((u_long)4)
166125699Spjd#define YPPROC_NEXT		((u_long)5)
167125699Spjd#define YPPROC_XFR		((u_long)6)
168129381Sle#define YPPROC_CLEAR		((u_long)7)
169125699Spjd#define YPPROC_ALL		((u_long)8)
170125699Spjd#define YPPROC_MASTER		((u_long)9)
171125699Spjd#define YPPROC_ORDER		((u_long)10)
172129381Sle#define YPPROC_MAPLIST		((u_long)11)
173129381Sle
174129381Sle/* ypserv procedure return status values */
175125699Spjd#define YP_TRUE	 	((long)1)	/* general purpose success code */
176125699Spjd#define YP_NOMORE 	((long)2)	/* no more entries in map */
177125699Spjd#define YP_FALSE 	((long)0)	/* general purpose failure code */
178125699Spjd#define YP_NOMAP 	((long)-1)	/* no such map in domain */
179125699Spjd#define YP_NODOM 	((long)-2)	/* domain not supported */
180125699Spjd#define YP_NOKEY 	((long)-3)	/* no such key in map */
181125699Spjd#define YP_BADOP 	((long)-4)	/* invalid operation */
182129381Sle#define YP_BADDB 	((long)-5)	/* server data base is bad */
183125699Spjd#define YP_YPERR 	((long)-6)	/* YP server error */
184125699Spjd#define YP_BADARGS 	((long)-7)	/* request arguments bad */
185125699Spjd#define YP_VERS		((long)-8)	/* YP server version mismatch */
186125699Spjd
187125699Spjd/*
188125699Spjd * Sun's header file says:
189125699Spjd * "Domain binding data structure, used by ypclnt package and ypserv modules.
190163872Spjd * Users of the ypclnt package (or of this protocol) don't HAVE to know about
191163872Spjd * it, but it must be available to users because _yp_dobind is a public
192163872Spjd * interface."
193163872Spjd *
194163872Spjd * This is totally bogus! Nowhere else does Sun state that _yp_dobind() is
195163872Spjd * a public interface, and I don't know any reason anyone would want to call
196163872Spjd * it. But, just in case anyone does actually expect it to be available..
197125699Spjd * we provide this.. exactly as Sun wants it.
198125699Spjd */
199129381Slestruct dom_binding {
200125699Spjd	struct dom_binding *dom_pnext;
201125699Spjd	char dom_domain[YPMAXDOMAIN + 1];
202125714Spjd	struct sockaddr_in dom_server_addr;
203125714Spjd	u_short dom_server_port;
204125714Spjd	int dom_socket;
205129381Sle	CLIENT *dom_client;
206125714Spjd	u_short dom_local_port;
207129381Sle	long dom_vers;
208129381Sle};
209129381Sle
210129381Sle/*
211129381Sle * YPBIND PROTOCOL:
212129381Sle *
213129381Sle * ypbind supports the following procedures:
214129381Sle *
215131689Sru * YPBINDPROC_NULL	takes (void), returns (void).
216131689Sru *			to check if ypbind is running.
217131689Sru * YPBINDPROC_DOMAIN	takes (char *), returns (struct ypbind_resp).
218125699Spjd *			requests that ypbind start to serve the
219125699Spjd *			named domain (if it doesn't already)
220131689Sru * YPBINDPROC_SETDOM	takes (struct ypbind_setdom), returns (void).
221125699Spjd *			used by ypset.
222125699Spjd */
223131689Sru
224125699Spjd#define YPBINDPROG		((u_long)100007)
225125699Spjd#define YPBINDVERS		((u_long)2)
226125699Spjd#define YPBINDVERS_ORIG		((u_long)1)
227125699Spjd
228125699Spjd/* ypbind procedure numbers */
229125699Spjd#define YPBINDPROC_NULL		((u_long)0)
230125699Spjd#define YPBINDPROC_DOMAIN	((u_long)1)
231125699Spjd#define YPBINDPROC_SETDOM	((u_long)2)
232125699Spjd
233125699Spjd/* error code in ypbind_resp.ypbind_status */
234125699Spjdenum ypbind_resptype {
235125714Spjd	YPBIND_SUCC_VAL = 1,
236169308Swkoszek	YPBIND_FAIL_VAL = 2
237125714Spjd};
238125714Spjd
239125699Spjd/* network order, of course */
240125699Spjdstruct ypbind_binding {
241125699Spjd	struct in_addr	ypbind_binding_addr;
242125699Spjd	u_short		ypbind_binding_port;
243125699Spjd};
244125699Spjd
245125699Spjdstruct ypbind_resp {
246125699Spjd	enum ypbind_resptype	ypbind_status;
247125699Spjd	union {
248125699Spjd		u_long			ypbind_error;
249125699Spjd		struct ypbind_binding	ypbind_bindinfo;
250125699Spjd	} ypbind_respbody;
251125699Spjd};
252125699Spjd
253125699Spjd/* error code in ypbind_resp.ypbind_respbody.ypbind_error */
254125699Spjd#define YPBIND_ERR_ERR		1	/* internal error */
255125699Spjd#define YPBIND_ERR_NOSERV	2	/* no bound server for passed domain */
256125699Spjd#define YPBIND_ERR_RESC		3	/* system resource allocation failure */
257125699Spjd
258125699Spjd/*
259125699Spjd * Request data structure for ypbind "Set domain" procedure.
260125699Spjd */
261125699Spjdstruct ypbind_setdom {
262125699Spjd	char ypsetdom_domain[YPMAXDOMAIN + 1];
263131594Sru	struct ypbind_binding ypsetdom_binding;
264125699Spjd	u_short ypsetdom_vers;
265126861Spjd};
266125699Spjd#define ypsetdom_addr ypsetdom_binding.ypbind_binding_addr
267125699Spjd#define ypsetdom_port ypsetdom_binding.ypbind_binding_port
268125699Spjd
269125699Spjd/*
270125699Spjd * YPPUSH PROTOCOL:
271125699Spjd *
272125699Spjd * Sun says:
273125699Spjd * "Protocol between clients (ypxfr, only) and yppush
274125699Spjd *  yppush speaks a protocol in the transient range, which
275125699Spjd *  is supplied to ypxfr as a command-line parameter when it
276125699Spjd *  is activated by ypserv."
277125699Spjd *
278 * This protocol is not implemented, naturally, because this YP
279 * implementation only does the client side.
280 */
281#define YPPUSHVERS		((u_long)1)
282#define YPPUSHVERS_ORIG		((u_long)1)
283
284/* yppush procedure numbers */
285#define YPPUSHPROC_NULL		((u_long)0)
286#define YPPUSHPROC_XFRRESP	((u_long)1)
287
288struct yppushresp_xfr {
289	u_long	transid;
290	u_long	status;
291};
292
293/* yppush status value in yppushresp_xfr.status */
294#define YPPUSH_SUCC	((long)1)	/* Success */
295#define YPPUSH_AGE	((long)2)	/* Master's version not newer */
296#define YPPUSH_NOMAP 	((long)-1)	/* Can't find server for map */
297#define YPPUSH_NODOM 	((long)-2)	/* Domain not supported */
298#define YPPUSH_RSRC 	((long)-3)	/* Local resource alloc failure */
299#define YPPUSH_RPC 	((long)-4)	/* RPC failure talking to server */
300#define YPPUSH_MADDR	((long)-5)	/* Can't get master address */
301#define YPPUSH_YPERR 	((long)-6)	/* YP server/map db error */
302#define YPPUSH_BADARGS 	((long)-7)	/* Request arguments bad */
303#define YPPUSH_DBM	((long)-8)	/* Local dbm operation failed */
304#define YPPUSH_FILE	((long)-9)	/* Local file I/O operation failed */
305#define YPPUSH_SKEW	((long)-10)	/* Map version skew during transfer */
306#define YPPUSH_CLEAR	((long)-11)	/* Can't send "Clear" req to local ypserv */
307#define YPPUSH_FORCE	((long)-12)	/* No local order number in map - use -f */
308#define YPPUSH_XFRERR	((long)-13)	/* ypxfr error */
309#define YPPUSH_REFUSED	((long)-14)	/* Transfer request refused by ypserv */
310
311struct inaddr;
312__BEGIN_DECLS
313bool_t	xdr_datum(XDR *, datum *);
314bool_t	xdr_ypreq_key(XDR *, struct ypreq_key *);
315bool_t	xdr_ypreq_nokey(XDR *, struct ypreq_nokey *);
316bool_t	xdr_ypreq_xfr(XDR *, struct ypreq_xfr *);
317bool_t	xdr_ypresp_val(XDR *, struct ypresp_val *);
318bool_t	xdr_ypresp_key_val(XDR *, struct ypresp_key_val *);
319bool_t	xdr_ypbind_resp(XDR *, struct ypbind_resp *);
320bool_t	xdr_ypbind_setdom(XDR *, struct ypbind_setdom *);
321bool_t	xdr_yp_inaddr(XDR *, struct inaddr *);
322bool_t	xdr_ypmap_parms(XDR *, struct ypmap_parms *);
323bool_t	xdr_yppushresp_xfr(XDR *, struct yppushresp_xfr *);
324bool_t	xdr_ypresp_order(XDR *, struct ypresp_order *);
325bool_t	xdr_ypresp_master(XDR *, struct ypresp_master *);
326bool_t	xdr_ypresp_maplist(XDR *, struct ypresp_maplist *);
327__END_DECLS
328
329#endif /* _RPCSVC_YP_PROT_H_ */
330