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