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