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