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