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