NetBSD/include/rpcsvc/yp_prot.h

345 lines
11 KiB
C
Raw Normal View History

1995-07-15 01:10:58 +04:00
/* $NetBSD: yp_prot.h,v 1.6 1995/07/14 21:10:58 christos Exp $ */
1994-10-26 03:55:40 +03:00
1993-04-20 10:03:55 +04:00
/*
1994-05-25 13:52:05 +04:00
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
1993-07-24 22:25:32 +04:00
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
1994-05-25 13:52:05 +04:00
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Theo de Raadt.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
1993-07-24 22:25:32 +04:00
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
1993-04-20 10:03:55 +04:00
*/
1995-07-15 01:10:58 +04:00
#ifndef _RPCSVC_YP_PROT_H_
#define _RPCSVC_YP_PROT_H_
1993-07-24 22:25:32 +04:00
1993-04-20 10:03:55 +04:00
/*
1993-07-24 22:25:32 +04:00
* YPSERV PROTOCOL:
1993-04-20 10:03:55 +04:00
*
1993-07-24 22:25:32 +04:00
* ypserv supports the following procedures:
1993-04-20 10:03:55 +04:00
*
1993-07-24 22:25:32 +04:00
* YPPROC_NULL takes (void), returns (void).
* called to check if server is alive.
* YPPROC_DOMAIN takes (char *), returns (bool_t).
* true if ypserv serves the named domain.
* YPPROC_DOMAIN_NOACK takes (char *), returns (bool_t).
* true if ypserv serves the named domain.
* used for broadcasts, does not ack if ypserv
* doesn't handle named domain.
* YPPROC_MATCH takes (struct ypreq_key), returns (struct ypresp_val)
* does a lookup.
* YPPROC_FIRST takes (struct ypreq_nokey) returns (ypresp_key_val).
* gets the first key/datum from the map.
* YPPROC_NEXT takes (struct ypreq_key) returns (ypresp_key_val).
* gets the next key/datum from the map.
* YPPROC_XFR takes (struct ypreq_xfr), returns (void).
* tells ypserv to check if there is a new version of
* the map.
* YPPROC_CLEAR takes (void), returns (void).
* tells ypserv to flush it's file cache, so that
* newly transferred files will get read.
* YPPROC_ALL takes (struct ypreq_nokey), returns (bool_t and
* struct ypresp_key_val).
* returns an array of data, with the bool_t being
* false on the last datum. read the source, it's
* convoluted.
* YPPROC_MASTER takes (struct ypreq_nokey), returns (ypresp_master).
* YPPROC_ORDER takes (struct ypreq_nokey), returns (ypresp_order).
* YPPROC_MAPLIST takes (char *), returns (struct ypmaplist *).
1993-04-20 10:03:55 +04:00
*/
1993-07-24 22:25:32 +04:00
1993-04-20 10:03:55 +04:00
#ifndef BOOL_DEFINED
1993-07-24 22:25:32 +04:00
typedef u_int bool;
1993-04-20 10:03:55 +04:00
#define BOOL_DEFINED
#endif
/* Program and version symbols, magic numbers */
#define YPPROG ((u_long)100004)
#define YPVERS ((u_long)2)
#define YPVERS_ORIG ((u_long)1)
#define YPMAXRECORD ((u_long)1024)
#define YPMAXDOMAIN ((u_long)64)
#define YPMAXMAP ((u_long)64)
#define YPMAXPEER ((u_long)256)
1993-07-24 22:25:32 +04:00
/*
* I don't know if anything of sun's depends on this, or if they
* simply defined it so that their own code wouldn't try to send
* packets over the ethernet MTU. This YP code doesn't use it.
*/
1993-04-20 10:03:55 +04:00
#define YPMSGSZ 1600
#ifndef DATUM
typedef struct {
1995-07-15 01:10:58 +04:00
const char *dptr;
int dsize;
1993-04-20 10:03:55 +04:00
} datum;
#define DATUM
#endif
struct ypmap_parms {
1995-07-15 01:10:58 +04:00
const char *domain;
const char *map;
1993-07-24 22:25:32 +04:00
u_long ordernum;
char *owner;
1993-04-20 10:03:55 +04:00
};
struct ypreq_key {
1995-07-15 01:10:58 +04:00
const char *domain;
const char *map;
1993-04-20 10:03:55 +04:00
datum keydat;
};
struct ypreq_nokey {
1995-07-15 01:10:58 +04:00
const char *domain;
const char *map;
1993-04-20 10:03:55 +04:00
};
struct ypreq_xfr {
struct ypmap_parms map_parms;
1993-07-24 22:25:32 +04:00
u_long transid;
u_long proto;
u_short port;
1993-04-20 10:03:55 +04:00
};
1993-07-24 22:25:32 +04:00
#define ypxfr_domain map_parms.domain
#define ypxfr_map map_parms.map
#define ypxfr_ordernum map_parms.ordernum
#define ypxfr_owner map_parms.owner
1993-04-20 10:03:55 +04:00
struct ypresp_val {
1993-07-24 22:25:32 +04:00
u_long status;
1993-04-20 10:03:55 +04:00
datum valdat;
};
struct ypresp_key_val {
1993-07-24 22:25:32 +04:00
u_long status;
1993-04-20 10:03:55 +04:00
datum keydat;
datum valdat;
};
struct ypresp_master {
1993-07-24 22:25:32 +04:00
u_long status;
1993-04-20 10:03:55 +04:00
char *master;
};
struct ypresp_order {
1993-07-24 22:25:32 +04:00
u_long status;
u_long ordernum;
1993-04-20 10:03:55 +04:00
};
1995-07-15 01:10:58 +04:00
struct ypresp_all {
bool_t more;
union {
struct ypresp_key_val val;
} ypresp_all_u;
};
1993-04-20 10:03:55 +04:00
struct ypmaplist {
char ypml_name[YPMAXMAP + 1];
struct ypmaplist *ypml_next;
};
struct ypresp_maplist {
1993-07-24 22:25:32 +04:00
u_long status;
1993-04-20 10:03:55 +04:00
struct ypmaplist *list;
};
1993-07-24 22:25:32 +04:00
/* ypserv procedure numbers */
#define YPPROC_NULL ((u_long)0)
#define YPPROC_DOMAIN ((u_long)1)
#define YPPROC_DOMAIN_NONACK ((u_long)2)
#define YPPROC_MATCH ((u_long)3)
#define YPPROC_FIRST ((u_long)4)
#define YPPROC_NEXT ((u_long)5)
#define YPPROC_XFR ((u_long)6)
#define YPPROC_CLEAR ((u_long)7)
#define YPPROC_ALL ((u_long)8)
#define YPPROC_MASTER ((u_long)9)
#define YPPROC_ORDER ((u_long)10)
#define YPPROC_MAPLIST ((u_long)11)
/* ypserv procedure return status values */
#define YP_TRUE ((long)1) /* general purpose success code */
#define YP_NOMORE ((long)2) /* no more entries in map */
#define YP_FALSE ((long)0) /* general purpose failure code */
#define YP_NOMAP ((long)-1) /* no such map in domain */
#define YP_NODOM ((long)-2) /* domain not supported */
#define YP_NOKEY ((long)-3) /* no such key in map */
#define YP_BADOP ((long)-4) /* invalid operation */
#define YP_BADDB ((long)-5) /* server data base is bad */
#define YP_YPERR ((long)-6) /* YP server error */
#define YP_BADARGS ((long)-7) /* request arguments bad */
#define YP_VERS ((long)-8) /* YP server version mismatch */
1993-04-20 10:03:55 +04:00
/*
1993-07-24 22:25:32 +04:00
* Sun's header file says:
* "Domain binding data structure, used by ypclnt package and ypserv modules.
1993-04-20 10:03:55 +04:00
* Users of the ypclnt package (or of this protocol) don't HAVE to know about
* it, but it must be available to users because _yp_dobind is a public
1993-07-24 22:25:32 +04:00
* interface."
*
* This is totally bogus! Nowhere else does Sun state that _yp_dobind() is
* a public interface, and I don't know any reason anyone would want to call
* it. But, just in case anyone does actually expect it to be available..
* we provide this.. exactly as Sun wants it.
1993-04-20 10:03:55 +04:00
*/
struct dom_binding {
struct dom_binding *dom_pnext;
char dom_domain[YPMAXDOMAIN + 1];
struct sockaddr_in dom_server_addr;
1993-07-24 22:25:32 +04:00
u_short dom_server_port;
1993-04-20 10:03:55 +04:00
int dom_socket;
CLIENT *dom_client;
1993-07-24 22:25:32 +04:00
u_short dom_local_port;
long dom_vers;
1993-04-20 10:03:55 +04:00
};
/*
1993-07-24 22:25:32 +04:00
* YPBIND PROTOCOL:
*
* ypbind supports the following procedures:
1993-04-20 10:03:55 +04:00
*
1993-07-24 22:25:32 +04:00
* YPBINDPROC_NULL takes (void), returns (void).
* to check if ypbind is running.
* YPBINDPROC_DOMAIN takes (char *), returns (struct ypbind_resp).
* requests that ypbind start to serve the
* named domain (if it doesn't already)
* YPBINDPROC_SETDOM takes (struct ypbind_setdom), returns (void).
* used by ypset.
1993-04-20 10:03:55 +04:00
*/
#define YPBINDPROG ((u_long)100007)
#define YPBINDVERS ((u_long)2)
#define YPBINDVERS_ORIG ((u_long)1)
1993-07-24 22:25:32 +04:00
/* ypbind procedure numbers */
1993-04-20 10:03:55 +04:00
#define YPBINDPROC_NULL ((u_long)0)
#define YPBINDPROC_DOMAIN ((u_long)1)
#define YPBINDPROC_SETDOM ((u_long)2)
1993-07-24 22:25:32 +04:00
/* error code in ypbind_resp.ypbind_status */
enum ypbind_resptype {
YPBIND_SUCC_VAL = 1,
YPBIND_FAIL_VAL = 2
};
1993-04-20 10:03:55 +04:00
1993-07-24 22:25:32 +04:00
/* network order, of course */
1993-04-20 10:03:55 +04:00
struct ypbind_binding {
1993-07-24 22:25:32 +04:00
struct in_addr ypbind_binding_addr;
u_short ypbind_binding_port;
1993-04-20 10:03:55 +04:00
};
1993-07-24 22:25:32 +04:00
1993-04-20 10:03:55 +04:00
struct ypbind_resp {
1993-07-24 22:25:32 +04:00
enum ypbind_resptype ypbind_status;
1993-04-20 10:03:55 +04:00
union {
1993-07-24 22:25:32 +04:00
u_long ypbind_error;
struct ypbind_binding ypbind_bindinfo;
1993-04-20 10:03:55 +04:00
} ypbind_respbody;
};
1993-07-24 22:25:32 +04:00
/* error code in ypbind_resp.ypbind_respbody.ypbind_error */
#define YPBIND_ERR_ERR 1 /* internal error */
#define YPBIND_ERR_NOSERV 2 /* no bound server for passed domain */
#define YPBIND_ERR_RESC 3 /* system resource allocation failure */
1993-04-20 10:03:55 +04:00
/*
* Request data structure for ypbind "Set domain" procedure.
*/
struct ypbind_setdom {
char ypsetdom_domain[YPMAXDOMAIN + 1];
struct ypbind_binding ypsetdom_binding;
1993-07-24 22:25:32 +04:00
u_short ypsetdom_vers;
1993-04-20 10:03:55 +04:00
};
#define ypsetdom_addr ypsetdom_binding.ypbind_binding_addr
#define ypsetdom_port ypsetdom_binding.ypbind_binding_port
/*
1993-07-24 22:25:32 +04:00
* YPPUSH PROTOCOL:
*
* Sun says:
* "Protocol between clients (ypxfr, only) and yppush
* yppush speaks a protocol in the transient range, which
* is supplied to ypxfr as a command-line parameter when it
* is activated by ypserv."
*
* This protocol is not implimented, naturally, because this YP
* implimentation only does the client side.
1993-04-20 10:03:55 +04:00
*/
1993-07-24 22:25:32 +04:00
#define YPPUSHVERS ((u_long)1)
1993-04-20 10:03:55 +04:00
#define YPPUSHVERS_ORIG ((u_long)1)
1993-07-24 22:25:32 +04:00
/* yppush procedure numbers */
1993-04-20 10:03:55 +04:00
#define YPPUSHPROC_NULL ((u_long)0)
#define YPPUSHPROC_XFRRESP ((u_long)1)
struct yppushresp_xfr {
1993-07-24 22:25:32 +04:00
u_long transid;
u_long status;
1993-04-20 10:03:55 +04:00
};
1993-07-24 22:25:32 +04:00
/* yppush status value in yppushresp_xfr.status */
1993-04-20 10:03:55 +04:00
#define YPPUSH_SUCC ((long)1) /* Success */
#define YPPUSH_AGE ((long)2) /* Master's version not newer */
#define YPPUSH_NOMAP ((long)-1) /* Can't find server for map */
#define YPPUSH_NODOM ((long)-2) /* Domain not supported */
#define YPPUSH_RSRC ((long)-3) /* Local resouce alloc failure */
#define YPPUSH_RPC ((long)-4) /* RPC failure talking to server */
#define YPPUSH_MADDR ((long)-5) /* Can't get master address */
1993-07-24 22:25:32 +04:00
#define YPPUSH_YPERR ((long)-6) /* YP server/map db error */
1993-04-20 10:03:55 +04:00
#define YPPUSH_BADARGS ((long)-7) /* Request arguments bad */
#define YPPUSH_DBM ((long)-8) /* Local dbm operation failed */
#define YPPUSH_FILE ((long)-9) /* Local file I/O operation failed */
#define YPPUSH_SKEW ((long)-10) /* Map version skew during transfer */
1993-07-24 22:25:32 +04:00
#define YPPUSH_CLEAR ((long)-11) /* Can't send "Clear" req to local ypserv */
#define YPPUSH_FORCE ((long)-12) /* No local order number in map - use -f */
1993-04-20 10:03:55 +04:00
#define YPPUSH_XFRERR ((long)-13) /* ypxfr error */
#define YPPUSH_REFUSED ((long)-14) /* Transfer request refused by ypserv */
1995-07-15 01:10:58 +04:00
__BEGIN_DECLS
bool_t xdr_domainname __P((XDR *, char *));
bool_t xdr_peername __P((XDR *, char *));
bool_t xdr_datum __P((XDR *, datum *));
bool_t xdr_mapname __P((XDR *, char *));
bool_t xdr_ypreq_key __P((XDR *, struct ypreq_key *));
bool_t xdr_ypreq_nokey __P((XDR *, struct ypreq_nokey *));
bool_t xdr_yp_inaddr __P((XDR *, struct in_addr *));
bool_t xdr_ypbind_binding __P((XDR *, struct ypbind_binding *));
bool_t xdr_ypbind_resptype __P((XDR *, enum ypbind_resptype *));
bool_t xdr_ypstat __P((XDR *, enum ypbind_resptype *));
bool_t xdr_ypbind_resp __P((XDR *, struct ypbind_resp *));
bool_t xdr_ypresp_val __P((XDR *, struct ypresp_val *));
bool_t xdr_ypbind_setdom __P((XDR *, struct ypbind_setdom *));
bool_t xdr_ypresp_key_val __P((XDR *, struct ypresp_key_val *));
bool_t xdr_ypresp_all __P((XDR *, struct ypresp_all *));
bool_t xdr_ypresp_all_seq __P((XDR *, u_long *));
bool_t xdr_ypresp_master __P((XDR *, struct ypresp_master *));
bool_t xdr_ypmaplist_str __P((XDR *, char *));
bool_t xdr_ypmaplist __P((XDR *, struct ypmaplist *));
bool_t xdr_ypresp_maplist __P((XDR *, struct ypresp_maplist *));
bool_t xdr_ypresp_order __P((XDR *, struct ypresp_order *));
__END_DECLS
#endif /* _RPCSVC_YP_PROT_H_ */