Home | History | Annotate | Line # | Download | only in rpcsvc
yp_prot.h revision 1.8
      1  1.8   thorpej /*	$NetBSD: yp_prot.h,v 1.8 1996/08/09 10:06:02 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.8   thorpej #define YPPROG		((unsigned long)100004)
     80  1.8   thorpej #define YPVERS		((unsigned long)2)
     81  1.8   thorpej #define YPVERS_ORIG	((unsigned long)1)
     82  1.8   thorpej 
     83  1.8   thorpej #define YPMAXRECORD	1024
     84  1.8   thorpej #define YPMAXDOMAIN	64
     85  1.8   thorpej #define YPMAXMAP	64
     86  1.8   thorpej #define YPMAXPEER	256
     87  1.1   deraadt 
     88  1.2   deraadt /*
     89  1.2   deraadt  * I don't know if anything of sun's depends on this, or if they
     90  1.2   deraadt  * simply defined it so that their own code wouldn't try to send
     91  1.2   deraadt  * packets over the ethernet MTU. This YP code doesn't use it.
     92  1.2   deraadt  */
     93  1.1   deraadt #define YPMSGSZ		1600
     94  1.1   deraadt 
     95  1.1   deraadt #ifndef DATUM
     96  1.1   deraadt typedef struct {
     97  1.6  christos 	const char	*dptr;
     98  1.6  christos 	int		 dsize;
     99  1.1   deraadt } datum;
    100  1.1   deraadt #define DATUM
    101  1.1   deraadt #endif
    102  1.1   deraadt 
    103  1.1   deraadt struct ypmap_parms {
    104  1.6  christos 	const char *domain;
    105  1.6  christos 	const char *map;
    106  1.8   thorpej 	unsigned int ordernum;
    107  1.2   deraadt 	char *owner;
    108  1.1   deraadt };
    109  1.1   deraadt 
    110  1.1   deraadt struct ypreq_key {
    111  1.6  christos 	const char *domain;
    112  1.6  christos 	const char *map;
    113  1.1   deraadt 	datum keydat;
    114  1.1   deraadt };
    115  1.1   deraadt 
    116  1.1   deraadt struct ypreq_nokey {
    117  1.6  christos 	const char *domain;
    118  1.6  christos 	const char *map;
    119  1.1   deraadt };
    120  1.1   deraadt 
    121  1.1   deraadt struct ypreq_xfr {
    122  1.1   deraadt 	struct ypmap_parms map_parms;
    123  1.8   thorpej 	unsigned int transid;
    124  1.8   thorpej 	unsigned int proto;
    125  1.8   thorpej 	unsigned int port;
    126  1.2   deraadt };
    127  1.2   deraadt #define ypxfr_domain	map_parms.domain
    128  1.2   deraadt #define ypxfr_map	map_parms.map
    129  1.2   deraadt #define ypxfr_ordernum	map_parms.ordernum
    130  1.2   deraadt #define ypxfr_owner	map_parms.owner
    131  1.1   deraadt 
    132  1.1   deraadt struct ypresp_val {
    133  1.8   thorpej 	int status;
    134  1.1   deraadt 	datum valdat;
    135  1.1   deraadt };
    136  1.1   deraadt 
    137  1.1   deraadt struct ypresp_key_val {
    138  1.8   thorpej 	int status;
    139  1.1   deraadt 	datum keydat;
    140  1.1   deraadt 	datum valdat;
    141  1.1   deraadt };
    142  1.1   deraadt 
    143  1.1   deraadt struct ypresp_master {
    144  1.8   thorpej 	int status;
    145  1.1   deraadt 	char *master;
    146  1.1   deraadt };
    147  1.1   deraadt 
    148  1.1   deraadt struct ypresp_order {
    149  1.8   thorpej 	int status;
    150  1.8   thorpej 	unsigned int ordernum;
    151  1.1   deraadt };
    152  1.1   deraadt 
    153  1.1   deraadt struct ypmaplist {
    154  1.1   deraadt 	char ypml_name[YPMAXMAP + 1];
    155  1.1   deraadt 	struct ypmaplist *ypml_next;
    156  1.1   deraadt };
    157  1.1   deraadt 
    158  1.1   deraadt struct ypresp_maplist {
    159  1.8   thorpej 	int status;
    160  1.1   deraadt 	struct ypmaplist *list;
    161  1.1   deraadt };
    162  1.1   deraadt 
    163  1.2   deraadt /* ypserv procedure numbers */
    164  1.8   thorpej #define YPPROC_NULL		((unsigned long)0)
    165  1.8   thorpej #define YPPROC_DOMAIN		((unsigned long)1)
    166  1.8   thorpej #define YPPROC_DOMAIN_NONACK	((unsigned long)2)
    167  1.8   thorpej #define YPPROC_MATCH		((unsigned long)3)
    168  1.8   thorpej #define YPPROC_FIRST		((unsigned long)4)
    169  1.8   thorpej #define YPPROC_NEXT		((unsigned long)5)
    170  1.8   thorpej #define YPPROC_XFR		((unsigned long)6)
    171  1.8   thorpej #define YPPROC_CLEAR		((unsigned long)7)
    172  1.8   thorpej #define YPPROC_ALL		((unsigned long)8)
    173  1.8   thorpej #define YPPROC_MASTER		((unsigned long)9)
    174  1.8   thorpej #define YPPROC_ORDER		((unsigned long)10)
    175  1.8   thorpej #define YPPROC_MAPLIST		((unsigned long)11)
    176  1.2   deraadt 
    177  1.2   deraadt /* ypserv procedure return status values */
    178  1.8   thorpej #define YP_TRUE	 	((int)1)	/* general purpose success code */
    179  1.8   thorpej #define YP_NOMORE 	((int)2)	/* no more entries in map */
    180  1.8   thorpej #define YP_FALSE 	((int)0)	/* general purpose failure code */
    181  1.8   thorpej #define YP_NOMAP 	((int)-1)	/* no such map in domain */
    182  1.8   thorpej #define YP_NODOM 	((int)-2)	/* domain not supported */
    183  1.8   thorpej #define YP_NOKEY 	((int)-3)	/* no such key in map */
    184  1.8   thorpej #define YP_BADOP 	((int)-4)	/* invalid operation */
    185  1.8   thorpej #define YP_BADDB 	((int)-5)	/* server data base is bad */
    186  1.8   thorpej #define YP_YPERR 	((int)-6)	/* YP server error */
    187  1.8   thorpej #define YP_BADARGS 	((int)-7)	/* request arguments bad */
    188  1.8   thorpej #define YP_VERS		((int)-8)	/* YP server version mismatch */
    189  1.1   deraadt 
    190  1.1   deraadt /*
    191  1.2   deraadt  * Sun's header file says:
    192  1.2   deraadt  * "Domain binding data structure, used by ypclnt package and ypserv modules.
    193  1.1   deraadt  * Users of the ypclnt package (or of this protocol) don't HAVE to know about
    194  1.1   deraadt  * it, but it must be available to users because _yp_dobind is a public
    195  1.2   deraadt  * interface."
    196  1.2   deraadt  *
    197  1.2   deraadt  * This is totally bogus! Nowhere else does Sun state that _yp_dobind() is
    198  1.2   deraadt  * a public interface, and I don't know any reason anyone would want to call
    199  1.2   deraadt  * it. But, just in case anyone does actually expect it to be available..
    200  1.2   deraadt  * we provide this.. exactly as Sun wants it.
    201  1.1   deraadt  */
    202  1.1   deraadt struct dom_binding {
    203  1.1   deraadt 	struct dom_binding *dom_pnext;
    204  1.1   deraadt 	char dom_domain[YPMAXDOMAIN + 1];
    205  1.1   deraadt 	struct sockaddr_in dom_server_addr;
    206  1.2   deraadt 	u_short dom_server_port;
    207  1.1   deraadt 	int dom_socket;
    208  1.1   deraadt 	CLIENT *dom_client;
    209  1.2   deraadt 	u_short dom_local_port;
    210  1.2   deraadt 	long dom_vers;
    211  1.1   deraadt };
    212  1.1   deraadt 
    213  1.1   deraadt /*
    214  1.2   deraadt  * YPBIND PROTOCOL:
    215  1.2   deraadt  *
    216  1.2   deraadt  * ypbind supports the following procedures:
    217  1.1   deraadt  *
    218  1.2   deraadt  * YPBINDPROC_NULL	takes (void), returns (void).
    219  1.2   deraadt  *			to check if ypbind is running.
    220  1.2   deraadt  * YPBINDPROC_DOMAIN	takes (char *), returns (struct ypbind_resp).
    221  1.2   deraadt  *			requests that ypbind start to serve the
    222  1.2   deraadt  *			named domain (if it doesn't already)
    223  1.2   deraadt  * YPBINDPROC_SETDOM	takes (struct ypbind_setdom), returns (void).
    224  1.2   deraadt  *			used by ypset.
    225  1.1   deraadt  */
    226  1.1   deraadt 
    227  1.8   thorpej #define YPBINDPROG		((unsigned long)100007)
    228  1.8   thorpej #define YPBINDVERS		((unsigned long)2)
    229  1.8   thorpej #define YPBINDVERS_ORIG		((unsigned long)1)
    230  1.1   deraadt 
    231  1.2   deraadt /* ypbind procedure numbers */
    232  1.8   thorpej #define YPBINDPROC_NULL		((unsigned long)0)
    233  1.8   thorpej #define YPBINDPROC_DOMAIN	((unsigned long)1)
    234  1.8   thorpej #define YPBINDPROC_SETDOM	((unsigned long)2)
    235  1.1   deraadt 
    236  1.2   deraadt /* error code in ypbind_resp.ypbind_status */
    237  1.2   deraadt enum ypbind_resptype {
    238  1.2   deraadt 	YPBIND_SUCC_VAL = 1,
    239  1.2   deraadt 	YPBIND_FAIL_VAL = 2
    240  1.2   deraadt };
    241  1.1   deraadt 
    242  1.2   deraadt /* network order, of course */
    243  1.1   deraadt struct ypbind_binding {
    244  1.2   deraadt 	struct in_addr	ypbind_binding_addr;
    245  1.8   thorpej 	u_int16_t	ypbind_binding_port;
    246  1.1   deraadt };
    247  1.2   deraadt 
    248  1.1   deraadt struct ypbind_resp {
    249  1.2   deraadt 	enum ypbind_resptype	ypbind_status;
    250  1.1   deraadt 	union {
    251  1.8   thorpej 		unsigned int		ypbind_error;
    252  1.2   deraadt 		struct ypbind_binding	ypbind_bindinfo;
    253  1.1   deraadt 	} ypbind_respbody;
    254  1.1   deraadt };
    255  1.1   deraadt 
    256  1.2   deraadt /* error code in ypbind_resp.ypbind_respbody.ypbind_error */
    257  1.2   deraadt #define YPBIND_ERR_ERR		1	/* internal error */
    258  1.2   deraadt #define YPBIND_ERR_NOSERV	2	/* no bound server for passed domain */
    259  1.2   deraadt #define YPBIND_ERR_RESC		3	/* system resource allocation failure */
    260  1.1   deraadt 
    261  1.1   deraadt /*
    262  1.1   deraadt  * Request data structure for ypbind "Set domain" procedure.
    263  1.1   deraadt  */
    264  1.1   deraadt struct ypbind_setdom {
    265  1.1   deraadt 	char ypsetdom_domain[YPMAXDOMAIN + 1];
    266  1.1   deraadt 	struct ypbind_binding ypsetdom_binding;
    267  1.8   thorpej 	unsigned int ypsetdom_vers;
    268  1.1   deraadt };
    269  1.1   deraadt #define ypsetdom_addr ypsetdom_binding.ypbind_binding_addr
    270  1.1   deraadt #define ypsetdom_port ypsetdom_binding.ypbind_binding_port
    271  1.1   deraadt 
    272  1.1   deraadt /*
    273  1.2   deraadt  * YPPUSH PROTOCOL:
    274  1.2   deraadt  *
    275  1.2   deraadt  * Sun says:
    276  1.2   deraadt  * "Protocol between clients (ypxfr, only) and yppush
    277  1.2   deraadt  *  yppush speaks a protocol in the transient range, which
    278  1.2   deraadt  *  is supplied to ypxfr as a command-line parameter when it
    279  1.2   deraadt  *  is activated by ypserv."
    280  1.2   deraadt  *
    281  1.2   deraadt  * This protocol is not implimented, naturally, because this YP
    282  1.2   deraadt  * implimentation only does the client side.
    283  1.1   deraadt  */
    284  1.8   thorpej #define YPPUSHVERS		((unsigned long)1)
    285  1.8   thorpej #define YPPUSHVERS_ORIG		((unsigned long)1)
    286  1.1   deraadt 
    287  1.2   deraadt /* yppush procedure numbers */
    288  1.8   thorpej #define YPPUSHPROC_NULL		((unsigned long)0)
    289  1.8   thorpej #define YPPUSHPROC_XFRRESP	((unsigned long)1)
    290  1.1   deraadt 
    291  1.1   deraadt struct yppushresp_xfr {
    292  1.8   thorpej 	unsigned int	transid;
    293  1.8   thorpej 	unsigned int	status;
    294  1.1   deraadt };
    295  1.1   deraadt 
    296  1.2   deraadt /* yppush status value in yppushresp_xfr.status */
    297  1.8   thorpej #define YPPUSH_SUCC	((int)1)	/* Success */
    298  1.8   thorpej #define YPPUSH_AGE	((int)2)	/* Master's version not newer */
    299  1.8   thorpej #define YPPUSH_NOMAP 	((int)-1)	/* Can't find server for map */
    300  1.8   thorpej #define YPPUSH_NODOM 	((int)-2)	/* Domain not supported */
    301  1.8   thorpej #define YPPUSH_RSRC 	((int)-3)	/* Local resouce alloc failure */
    302  1.8   thorpej #define YPPUSH_RPC 	((int)-4)	/* RPC failure talking to server */
    303  1.8   thorpej #define YPPUSH_MADDR	((int)-5)	/* Can't get master address */
    304  1.8   thorpej #define YPPUSH_YPERR 	((int)-6)	/* YP server/map db error */
    305  1.8   thorpej #define YPPUSH_BADARGS 	((int)-7)	/* Request arguments bad */
    306  1.8   thorpej #define YPPUSH_DBM	((int)-8)	/* Local dbm operation failed */
    307  1.8   thorpej #define YPPUSH_FILE	((int)-9)	/* Local file I/O operation failed */
    308  1.8   thorpej #define YPPUSH_SKEW	((int)-10)	/* Map version skew during transfer */
    309  1.8   thorpej #define YPPUSH_CLEAR	((int)-11)	/* Can't send "Clear" req to local ypserv */
    310  1.8   thorpej #define YPPUSH_FORCE	((int)-12)	/* No local order number in map - use -f */
    311  1.8   thorpej #define YPPUSH_XFRERR	((int)-13)	/* ypxfr error */
    312  1.8   thorpej #define YPPUSH_REFUSED	((int)-14)	/* Transfer request refused by ypserv */
    313  1.1   deraadt 
    314  1.7   thorpej struct ypall_callback;
    315  1.7   thorpej 
    316  1.6  christos __BEGIN_DECLS
    317  1.6  christos bool_t xdr_datum __P((XDR *, datum *));
    318  1.7   thorpej bool_t xdr_ypdomain_wrap_string __P((XDR *, char **));
    319  1.7   thorpej bool_t xdr_ypmap_wrap_string __P((XDR *, char **));
    320  1.6  christos bool_t xdr_ypreq_key __P((XDR *, struct ypreq_key *));
    321  1.6  christos bool_t xdr_ypreq_nokey __P((XDR *, struct ypreq_nokey *));
    322  1.7   thorpej bool_t xdr_ypreq_xfr __P((XDR *, struct ypreq_xfr *));
    323  1.6  christos bool_t xdr_ypresp_val __P((XDR *, struct ypresp_val *));
    324  1.6  christos bool_t xdr_ypresp_key_val __P((XDR *, struct ypresp_key_val *));
    325  1.7   thorpej bool_t xdr_ypmap_parms __P((XDR *, struct ypmap_parms *));
    326  1.7   thorpej bool_t xdr_ypowner_wrap_string __P((XDR *, char **));
    327  1.7   thorpej bool_t xdr_yppushresp_xfr __P((XDR *, struct yppushresp_xfr *));
    328  1.7   thorpej bool_t xdr_ypresp_order __P((XDR *, struct ypresp_order *));
    329  1.6  christos bool_t xdr_ypresp_master __P((XDR *, struct ypresp_master *));
    330  1.7   thorpej bool_t xdr_ypall __P((XDR *, struct ypall_callback *));
    331  1.7   thorpej bool_t xdr_ypresp_maplist __P((XDR *, struct ypresp_maplist *));
    332  1.7   thorpej bool_t xdr_ypbind_resp __P((XDR *, struct ypbind_resp *));
    333  1.7   thorpej bool_t xdr_ypbind_setdom __P((XDR *, struct ypbind_setdom *));
    334  1.6  christos bool_t xdr_ypmaplist __P((XDR *, struct ypmaplist *));
    335  1.7   thorpej bool_t xdr_yp_inaddr __P((XDR *, struct in_addr *));
    336  1.6  christos __END_DECLS
    337  1.6  christos 
    338  1.6  christos #endif /* _RPCSVC_YP_PROT_H_ */
    339