1e58eb3c4SPedro F. Giffuni /*- 2e58eb3c4SPedro F. Giffuni * SPDX-License-Identifier: BSD-3-Clause 3e58eb3c4SPedro F. Giffuni * 475b63130SGarrett Wollman * Copyright (c) 1992/3 Theo de Raadt <deraadt@fsa.ca> 575b63130SGarrett Wollman * All rights reserved. 675b63130SGarrett Wollman * 775b63130SGarrett Wollman * Redistribution and use in source and binary forms, with or without 875b63130SGarrett Wollman * modification, are permitted provided that the following conditions 975b63130SGarrett Wollman * are met: 1075b63130SGarrett Wollman * 1. Redistributions of source code must retain the above copyright 1175b63130SGarrett Wollman * notice, this list of conditions and the following disclaimer. 1275b63130SGarrett Wollman * 2. Redistributions in binary form must reproduce the above copyright 1375b63130SGarrett Wollman * notice, this list of conditions and the following disclaimer in the 1475b63130SGarrett Wollman * documentation and/or other materials provided with the distribution. 1575b63130SGarrett Wollman * 3. The name of the author may not be used to endorse or promote 1675b63130SGarrett Wollman * products derived from this software without specific prior written 1775b63130SGarrett Wollman * permission. 1875b63130SGarrett Wollman * 1975b63130SGarrett Wollman * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 2075b63130SGarrett Wollman * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 2175b63130SGarrett Wollman * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2275b63130SGarrett Wollman * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 2375b63130SGarrett Wollman * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2475b63130SGarrett Wollman * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2575b63130SGarrett Wollman * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2675b63130SGarrett Wollman * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2775b63130SGarrett Wollman * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2875b63130SGarrett Wollman * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2975b63130SGarrett Wollman * SUCH DAMAGE. 3075b63130SGarrett Wollman */ 3175b63130SGarrett Wollman 322a053fb1SPeter Wemm #ifndef _RPCSVC_YP_PROT_H_ 332a053fb1SPeter Wemm #define _RPCSVC_YP_PROT_H_ 3475b63130SGarrett Wollman 3575b63130SGarrett Wollman /* 3675b63130SGarrett Wollman * YPSERV PROTOCOL: 3775b63130SGarrett Wollman * 3875b63130SGarrett Wollman * ypserv supports the following procedures: 3975b63130SGarrett Wollman * 4075b63130SGarrett Wollman * YPPROC_NULL takes (void), returns (void). 4175b63130SGarrett Wollman * called to check if server is alive. 4275b63130SGarrett Wollman * YPPROC_DOMAIN takes (char *), returns (bool_t). 4375b63130SGarrett Wollman * true if ypserv serves the named domain. 4475b63130SGarrett Wollman * YPPROC_DOMAIN_NOACK takes (char *), returns (bool_t). 4575b63130SGarrett Wollman * true if ypserv serves the named domain. 4675b63130SGarrett Wollman * used for broadcasts, does not ack if ypserv 4775b63130SGarrett Wollman * doesn't handle named domain. 4875b63130SGarrett Wollman * YPPROC_MATCH takes (struct ypreq_key), returns (struct ypresp_val) 4975b63130SGarrett Wollman * does a lookup. 5075b63130SGarrett Wollman * YPPROC_FIRST takes (struct ypreq_nokey) returns (ypresp_key_val). 5175b63130SGarrett Wollman * gets the first key/datum from the map. 5275b63130SGarrett Wollman * YPPROC_NEXT takes (struct ypreq_key) returns (ypresp_key_val). 5375b63130SGarrett Wollman * gets the next key/datum from the map. 5475b63130SGarrett Wollman * YPPROC_XFR takes (struct ypreq_xfr), returns (void). 5575b63130SGarrett Wollman * tells ypserv to check if there is a new version of 5675b63130SGarrett Wollman * the map. 5775b63130SGarrett Wollman * YPPROC_CLEAR takes (void), returns (void). 5875b63130SGarrett Wollman * tells ypserv to flush it's file cache, so that 5975b63130SGarrett Wollman * newly transferred files will get read. 6075b63130SGarrett Wollman * YPPROC_ALL takes (struct ypreq_nokey), returns (bool_t and 6175b63130SGarrett Wollman * struct ypresp_key_val). 6275b63130SGarrett Wollman * returns an array of data, with the bool_t being 6375b63130SGarrett Wollman * false on the last datum. read the source, it's 6475b63130SGarrett Wollman * convoluted. 6575b63130SGarrett Wollman * YPPROC_MASTER takes (struct ypreq_nokey), returns (ypresp_master). 6675b63130SGarrett Wollman * YPPROC_ORDER takes (struct ypreq_nokey), returns (ypresp_order). 6775b63130SGarrett Wollman * YPPROC_MAPLIST takes (char *), returns (struct ypmaplist *). 6875b63130SGarrett Wollman */ 6975b63130SGarrett Wollman 7075b63130SGarrett Wollman #ifndef BOOL_DEFINED 7175b63130SGarrett Wollman typedef u_int bool; 7275b63130SGarrett Wollman #define BOOL_DEFINED 7375b63130SGarrett Wollman #endif 7475b63130SGarrett Wollman 7575b63130SGarrett Wollman /* Program and version symbols, magic numbers */ 7675b63130SGarrett Wollman 7775b63130SGarrett Wollman #define YPPROG ((u_long)100004) 7875b63130SGarrett Wollman #define YPVERS ((u_long)2) 7975b63130SGarrett Wollman #define YPVERS_ORIG ((u_long)1) 806b462d27SKonstantin Belousov #define YPMAXRECORD ((u_long)16 * 1024 * 1024) 8175b63130SGarrett Wollman #define YPMAXDOMAIN ((u_long)64) 8275b63130SGarrett Wollman #define YPMAXMAP ((u_long)64) 8375b63130SGarrett Wollman #define YPMAXPEER ((u_long)256) 8475b63130SGarrett Wollman 8575b63130SGarrett Wollman /* 8675b63130SGarrett Wollman * I don't know if anything of sun's depends on this, or if they 8775b63130SGarrett Wollman * simply defined it so that their own code wouldn't try to send 8875b63130SGarrett Wollman * packets over the ethernet MTU. This YP code doesn't use it. 8975b63130SGarrett Wollman */ 9075b63130SGarrett Wollman #define YPMSGSZ 1600 9175b63130SGarrett Wollman 9275b63130SGarrett Wollman #ifndef DATUM 9375b63130SGarrett Wollman typedef struct { 9475b63130SGarrett Wollman char *dptr; 9575b63130SGarrett Wollman int dsize; 9675b63130SGarrett Wollman } datum; 9775b63130SGarrett Wollman #define DATUM 9875b63130SGarrett Wollman #endif 9975b63130SGarrett Wollman 10075b63130SGarrett Wollman struct ypmap_parms { 10175b63130SGarrett Wollman char *domain; 10275b63130SGarrett Wollman char *map; 1032815e4b0SThomas Moestl u_int ordernum; 10475b63130SGarrett Wollman char *owner; 10575b63130SGarrett Wollman }; 10675b63130SGarrett Wollman 10775b63130SGarrett Wollman struct ypreq_key { 10875b63130SGarrett Wollman char *domain; 10975b63130SGarrett Wollman char *map; 11075b63130SGarrett Wollman datum keydat; 11175b63130SGarrett Wollman }; 11275b63130SGarrett Wollman 11375b63130SGarrett Wollman struct ypreq_nokey { 11475b63130SGarrett Wollman char *domain; 11575b63130SGarrett Wollman char *map; 11675b63130SGarrett Wollman }; 11775b63130SGarrett Wollman 11875b63130SGarrett Wollman struct ypreq_xfr { 11975b63130SGarrett Wollman struct ypmap_parms map_parms; 1202815e4b0SThomas Moestl u_int transid; 1212815e4b0SThomas Moestl u_int proto; 1222815e4b0SThomas Moestl u_int port; 12375b63130SGarrett Wollman }; 12475b63130SGarrett Wollman #define ypxfr_domain map_parms.domain 12575b63130SGarrett Wollman #define ypxfr_map map_parms.map 12675b63130SGarrett Wollman #define ypxfr_ordernum map_parms.ordernum 12775b63130SGarrett Wollman #define ypxfr_owner map_parms.owner 12875b63130SGarrett Wollman 12975b63130SGarrett Wollman struct ypresp_val { 1302815e4b0SThomas Moestl u_int status; 13175b63130SGarrett Wollman datum valdat; 13275b63130SGarrett Wollman }; 13375b63130SGarrett Wollman 13475b63130SGarrett Wollman struct ypresp_key_val { 1352815e4b0SThomas Moestl u_int status; 13675b63130SGarrett Wollman datum keydat; 13775b63130SGarrett Wollman datum valdat; 13875b63130SGarrett Wollman }; 13975b63130SGarrett Wollman 14075b63130SGarrett Wollman struct ypresp_master { 1412815e4b0SThomas Moestl u_int status; 14275b63130SGarrett Wollman char *master; 14375b63130SGarrett Wollman }; 14475b63130SGarrett Wollman 14575b63130SGarrett Wollman struct ypresp_order { 1462815e4b0SThomas Moestl u_int status; 1472815e4b0SThomas Moestl u_int ordernum; 14875b63130SGarrett Wollman }; 14975b63130SGarrett Wollman 15075b63130SGarrett Wollman struct ypmaplist { 1517bb2af36SPeter Wemm char *ypml_name; 15275b63130SGarrett Wollman struct ypmaplist *ypml_next; 15375b63130SGarrett Wollman }; 15475b63130SGarrett Wollman 15575b63130SGarrett Wollman struct ypresp_maplist { 1562815e4b0SThomas Moestl u_int status; 15775b63130SGarrett Wollman struct ypmaplist *list; 15875b63130SGarrett Wollman }; 15975b63130SGarrett Wollman 16075b63130SGarrett Wollman /* ypserv procedure numbers */ 16175b63130SGarrett Wollman #define YPPROC_NULL ((u_long)0) 16275b63130SGarrett Wollman #define YPPROC_DOMAIN ((u_long)1) 16375b63130SGarrett Wollman #define YPPROC_DOMAIN_NONACK ((u_long)2) 16475b63130SGarrett Wollman #define YPPROC_MATCH ((u_long)3) 16575b63130SGarrett Wollman #define YPPROC_FIRST ((u_long)4) 16675b63130SGarrett Wollman #define YPPROC_NEXT ((u_long)5) 16775b63130SGarrett Wollman #define YPPROC_XFR ((u_long)6) 16875b63130SGarrett Wollman #define YPPROC_CLEAR ((u_long)7) 16975b63130SGarrett Wollman #define YPPROC_ALL ((u_long)8) 17075b63130SGarrett Wollman #define YPPROC_MASTER ((u_long)9) 17175b63130SGarrett Wollman #define YPPROC_ORDER ((u_long)10) 17275b63130SGarrett Wollman #define YPPROC_MAPLIST ((u_long)11) 17375b63130SGarrett Wollman 17475b63130SGarrett Wollman /* ypserv procedure return status values */ 17575b63130SGarrett Wollman #define YP_TRUE ((long)1) /* general purpose success code */ 17675b63130SGarrett Wollman #define YP_NOMORE ((long)2) /* no more entries in map */ 17775b63130SGarrett Wollman #define YP_FALSE ((long)0) /* general purpose failure code */ 17875b63130SGarrett Wollman #define YP_NOMAP ((long)-1) /* no such map in domain */ 17975b63130SGarrett Wollman #define YP_NODOM ((long)-2) /* domain not supported */ 18075b63130SGarrett Wollman #define YP_NOKEY ((long)-3) /* no such key in map */ 18175b63130SGarrett Wollman #define YP_BADOP ((long)-4) /* invalid operation */ 18275b63130SGarrett Wollman #define YP_BADDB ((long)-5) /* server data base is bad */ 18375b63130SGarrett Wollman #define YP_YPERR ((long)-6) /* YP server error */ 18475b63130SGarrett Wollman #define YP_BADARGS ((long)-7) /* request arguments bad */ 18575b63130SGarrett Wollman #define YP_VERS ((long)-8) /* YP server version mismatch */ 18675b63130SGarrett Wollman 18775b63130SGarrett Wollman /* 18875b63130SGarrett Wollman * Sun's header file says: 18975b63130SGarrett Wollman * "Domain binding data structure, used by ypclnt package and ypserv modules. 19075b63130SGarrett Wollman * Users of the ypclnt package (or of this protocol) don't HAVE to know about 19175b63130SGarrett Wollman * it, but it must be available to users because _yp_dobind is a public 19275b63130SGarrett Wollman * interface." 19375b63130SGarrett Wollman * 19475b63130SGarrett Wollman * This is totally bogus! Nowhere else does Sun state that _yp_dobind() is 19575b63130SGarrett Wollman * a public interface, and I don't know any reason anyone would want to call 19675b63130SGarrett Wollman * it. But, just in case anyone does actually expect it to be available.. 19775b63130SGarrett Wollman * we provide this.. exactly as Sun wants it. 19875b63130SGarrett Wollman */ 19975b63130SGarrett Wollman struct dom_binding { 20075b63130SGarrett Wollman struct dom_binding *dom_pnext; 20175b63130SGarrett Wollman char dom_domain[YPMAXDOMAIN + 1]; 20275b63130SGarrett Wollman struct sockaddr_in dom_server_addr; 20375b63130SGarrett Wollman u_short dom_server_port; 20475b63130SGarrett Wollman int dom_socket; 20575b63130SGarrett Wollman CLIENT *dom_client; 20675b63130SGarrett Wollman u_short dom_local_port; 20775b63130SGarrett Wollman long dom_vers; 20875b63130SGarrett Wollman }; 20975b63130SGarrett Wollman 21075b63130SGarrett Wollman /* 21175b63130SGarrett Wollman * YPBIND PROTOCOL: 21275b63130SGarrett Wollman * 21375b63130SGarrett Wollman * ypbind supports the following procedures: 21475b63130SGarrett Wollman * 21575b63130SGarrett Wollman * YPBINDPROC_NULL takes (void), returns (void). 21675b63130SGarrett Wollman * to check if ypbind is running. 21775b63130SGarrett Wollman * YPBINDPROC_DOMAIN takes (char *), returns (struct ypbind_resp). 21875b63130SGarrett Wollman * requests that ypbind start to serve the 21975b63130SGarrett Wollman * named domain (if it doesn't already) 22075b63130SGarrett Wollman * YPBINDPROC_SETDOM takes (struct ypbind_setdom), returns (void). 22175b63130SGarrett Wollman * used by ypset. 22275b63130SGarrett Wollman */ 22375b63130SGarrett Wollman 22475b63130SGarrett Wollman #define YPBINDPROG ((u_long)100007) 22575b63130SGarrett Wollman #define YPBINDVERS ((u_long)2) 22675b63130SGarrett Wollman #define YPBINDVERS_ORIG ((u_long)1) 22775b63130SGarrett Wollman 22875b63130SGarrett Wollman /* ypbind procedure numbers */ 22975b63130SGarrett Wollman #define YPBINDPROC_NULL ((u_long)0) 23075b63130SGarrett Wollman #define YPBINDPROC_DOMAIN ((u_long)1) 23175b63130SGarrett Wollman #define YPBINDPROC_SETDOM ((u_long)2) 23275b63130SGarrett Wollman 23375b63130SGarrett Wollman /* error code in ypbind_resp.ypbind_status */ 23475b63130SGarrett Wollman enum ypbind_resptype { 23575b63130SGarrett Wollman YPBIND_SUCC_VAL = 1, 23675b63130SGarrett Wollman YPBIND_FAIL_VAL = 2 23775b63130SGarrett Wollman }; 23875b63130SGarrett Wollman 23975b63130SGarrett Wollman /* network order, of course */ 24075b63130SGarrett Wollman struct ypbind_binding { 24175b63130SGarrett Wollman struct in_addr ypbind_binding_addr; 24275b63130SGarrett Wollman u_short ypbind_binding_port; 24375b63130SGarrett Wollman }; 24475b63130SGarrett Wollman 24575b63130SGarrett Wollman struct ypbind_resp { 24675b63130SGarrett Wollman enum ypbind_resptype ypbind_status; 24775b63130SGarrett Wollman union { 2482815e4b0SThomas Moestl u_int ypbind_error; 24975b63130SGarrett Wollman struct ypbind_binding ypbind_bindinfo; 25075b63130SGarrett Wollman } ypbind_respbody; 25175b63130SGarrett Wollman }; 25275b63130SGarrett Wollman 25375b63130SGarrett Wollman /* error code in ypbind_resp.ypbind_respbody.ypbind_error */ 25475b63130SGarrett Wollman #define YPBIND_ERR_ERR 1 /* internal error */ 25575b63130SGarrett Wollman #define YPBIND_ERR_NOSERV 2 /* no bound server for passed domain */ 25675b63130SGarrett Wollman #define YPBIND_ERR_RESC 3 /* system resource allocation failure */ 25775b63130SGarrett Wollman 25875b63130SGarrett Wollman /* 25975b63130SGarrett Wollman * Request data structure for ypbind "Set domain" procedure. 26075b63130SGarrett Wollman */ 26175b63130SGarrett Wollman struct ypbind_setdom { 26275b63130SGarrett Wollman char ypsetdom_domain[YPMAXDOMAIN + 1]; 26375b63130SGarrett Wollman struct ypbind_binding ypsetdom_binding; 2642815e4b0SThomas Moestl u_int ypsetdom_vers; 26575b63130SGarrett Wollman }; 26675b63130SGarrett Wollman #define ypsetdom_addr ypsetdom_binding.ypbind_binding_addr 26775b63130SGarrett Wollman #define ypsetdom_port ypsetdom_binding.ypbind_binding_port 26875b63130SGarrett Wollman 26975b63130SGarrett Wollman /* 27075b63130SGarrett Wollman * YPPUSH PROTOCOL: 27175b63130SGarrett Wollman * 27275b63130SGarrett Wollman * Sun says: 27375b63130SGarrett Wollman * "Protocol between clients (ypxfr, only) and yppush 274*5e2a4192SElyes Haouas * speaks a protocol in the transient range, which 27575b63130SGarrett Wollman * is supplied to ypxfr as a command-line parameter when it 27675b63130SGarrett Wollman * is activated by ypserv." 27775b63130SGarrett Wollman * 27871d9c781SMike Pritchard * This protocol is not implemented, naturally, because this YP 27971d9c781SMike Pritchard * implementation only does the client side. 28075b63130SGarrett Wollman */ 28175b63130SGarrett Wollman #define YPPUSHVERS ((u_long)1) 28275b63130SGarrett Wollman #define YPPUSHVERS_ORIG ((u_long)1) 28375b63130SGarrett Wollman 28475b63130SGarrett Wollman /* yppush procedure numbers */ 28575b63130SGarrett Wollman #define YPPUSHPROC_NULL ((u_long)0) 28675b63130SGarrett Wollman #define YPPUSHPROC_XFRRESP ((u_long)1) 28775b63130SGarrett Wollman 28875b63130SGarrett Wollman struct yppushresp_xfr { 2892815e4b0SThomas Moestl u_int transid; 2902815e4b0SThomas Moestl u_int status; 29175b63130SGarrett Wollman }; 29275b63130SGarrett Wollman 29375b63130SGarrett Wollman /* yppush status value in yppushresp_xfr.status */ 29475b63130SGarrett Wollman #define YPPUSH_SUCC ((long)1) /* Success */ 29575b63130SGarrett Wollman #define YPPUSH_AGE ((long)2) /* Master's version not newer */ 29675b63130SGarrett Wollman #define YPPUSH_NOMAP ((long)-1) /* Can't find server for map */ 29775b63130SGarrett Wollman #define YPPUSH_NODOM ((long)-2) /* Domain not supported */ 29871d9c781SMike Pritchard #define YPPUSH_RSRC ((long)-3) /* Local resource alloc failure */ 29975b63130SGarrett Wollman #define YPPUSH_RPC ((long)-4) /* RPC failure talking to server */ 30075b63130SGarrett Wollman #define YPPUSH_MADDR ((long)-5) /* Can't get master address */ 30175b63130SGarrett Wollman #define YPPUSH_YPERR ((long)-6) /* YP server/map db error */ 30275b63130SGarrett Wollman #define YPPUSH_BADARGS ((long)-7) /* Request arguments bad */ 30375b63130SGarrett Wollman #define YPPUSH_DBM ((long)-8) /* Local dbm operation failed */ 30475b63130SGarrett Wollman #define YPPUSH_FILE ((long)-9) /* Local file I/O operation failed */ 30575b63130SGarrett Wollman #define YPPUSH_SKEW ((long)-10) /* Map version skew during transfer */ 30675b63130SGarrett Wollman #define YPPUSH_CLEAR ((long)-11) /* Can't send "Clear" req to local ypserv */ 30775b63130SGarrett Wollman #define YPPUSH_FORCE ((long)-12) /* No local order number in map - use -f */ 30875b63130SGarrett Wollman #define YPPUSH_XFRERR ((long)-13) /* ypxfr error */ 30975b63130SGarrett Wollman #define YPPUSH_REFUSED ((long)-14) /* Transfer request refused by ypserv */ 31075b63130SGarrett Wollman 3112a053fb1SPeter Wemm struct inaddr; 3122a053fb1SPeter Wemm __BEGIN_DECLS 313ed4d1c46SDag-Erling Smørgrav bool_t xdr_datum(XDR *, datum *); 314ed4d1c46SDag-Erling Smørgrav bool_t xdr_ypreq_key(XDR *, struct ypreq_key *); 315ed4d1c46SDag-Erling Smørgrav bool_t xdr_ypreq_nokey(XDR *, struct ypreq_nokey *); 316ed4d1c46SDag-Erling Smørgrav bool_t xdr_ypreq_xfr(XDR *, struct ypreq_xfr *); 317ed4d1c46SDag-Erling Smørgrav bool_t xdr_ypresp_val(XDR *, struct ypresp_val *); 318ed4d1c46SDag-Erling Smørgrav bool_t xdr_ypresp_key_val(XDR *, struct ypresp_key_val *); 319ed4d1c46SDag-Erling Smørgrav bool_t xdr_ypbind_resp(XDR *, struct ypbind_resp *); 320ed4d1c46SDag-Erling Smørgrav bool_t xdr_ypbind_setdom(XDR *, struct ypbind_setdom *); 321ed4d1c46SDag-Erling Smørgrav bool_t xdr_yp_inaddr(XDR *, struct inaddr *); 322ed4d1c46SDag-Erling Smørgrav bool_t xdr_ypmap_parms(XDR *, struct ypmap_parms *); 323ed4d1c46SDag-Erling Smørgrav bool_t xdr_yppushresp_xfr(XDR *, struct yppushresp_xfr *); 324ed4d1c46SDag-Erling Smørgrav bool_t xdr_ypresp_order(XDR *, struct ypresp_order *); 325ed4d1c46SDag-Erling Smørgrav bool_t xdr_ypresp_master(XDR *, struct ypresp_master *); 326ed4d1c46SDag-Erling Smørgrav bool_t xdr_ypresp_maplist(XDR *, struct ypresp_maplist *); 3272a053fb1SPeter Wemm __END_DECLS 3282a053fb1SPeter Wemm 3292a053fb1SPeter Wemm #endif /* _RPCSVC_YP_PROT_H_ */ 330