11832Swollman/* 21832Swollman * Copyright (c) 1992/3 Theo de Raadt <deraadt@fsa.ca> 31832Swollman * All rights reserved. 41832Swollman * 51832Swollman * Redistribution and use in source and binary forms, with or without 61832Swollman * modification, are permitted provided that the following conditions 71832Swollman * are met: 81832Swollman * 1. Redistributions of source code must retain the above copyright 91832Swollman * notice, this list of conditions and the following disclaimer. 101832Swollman * 2. Redistributions in binary form must reproduce the above copyright 111832Swollman * notice, this list of conditions and the following disclaimer in the 121832Swollman * documentation and/or other materials provided with the distribution. 131832Swollman * 3. The name of the author may not be used to endorse or promote 141832Swollman * products derived from this software without specific prior written 151832Swollman * permission. 161832Swollman * 171832Swollman * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 181832Swollman * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 191832Swollman * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 201832Swollman * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 211832Swollman * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 221832Swollman * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 231832Swollman * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 241832Swollman * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 251832Swollman * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 261832Swollman * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 271832Swollman * SUCH DAMAGE. 281832Swollman * 2950473Speter * $FreeBSD$ 301832Swollman */ 311832Swollman 3221060Speter#ifndef _RPCSVC_YP_PROT_H_ 3321060Speter#define _RPCSVC_YP_PROT_H_ 341832Swollman 351832Swollman/* 361832Swollman * YPSERV PROTOCOL: 378858Srgrimes * 381832Swollman * ypserv supports the following procedures: 398858Srgrimes * 401832Swollman * YPPROC_NULL takes (void), returns (void). 411832Swollman * called to check if server is alive. 421832Swollman * YPPROC_DOMAIN takes (char *), returns (bool_t). 431832Swollman * true if ypserv serves the named domain. 441832Swollman * YPPROC_DOMAIN_NOACK takes (char *), returns (bool_t). 451832Swollman * true if ypserv serves the named domain. 461832Swollman * used for broadcasts, does not ack if ypserv 471832Swollman * doesn't handle named domain. 481832Swollman * YPPROC_MATCH takes (struct ypreq_key), returns (struct ypresp_val) 491832Swollman * does a lookup. 501832Swollman * YPPROC_FIRST takes (struct ypreq_nokey) returns (ypresp_key_val). 511832Swollman * gets the first key/datum from the map. 521832Swollman * YPPROC_NEXT takes (struct ypreq_key) returns (ypresp_key_val). 531832Swollman * gets the next key/datum from the map. 541832Swollman * YPPROC_XFR takes (struct ypreq_xfr), returns (void). 551832Swollman * tells ypserv to check if there is a new version of 561832Swollman * the map. 571832Swollman * YPPROC_CLEAR takes (void), returns (void). 581832Swollman * tells ypserv to flush it's file cache, so that 591832Swollman * newly transferred files will get read. 601832Swollman * YPPROC_ALL takes (struct ypreq_nokey), returns (bool_t and 611832Swollman * struct ypresp_key_val). 621832Swollman * returns an array of data, with the bool_t being 631832Swollman * false on the last datum. read the source, it's 641832Swollman * convoluted. 651832Swollman * YPPROC_MASTER takes (struct ypreq_nokey), returns (ypresp_master). 661832Swollman * YPPROC_ORDER takes (struct ypreq_nokey), returns (ypresp_order). 671832Swollman * YPPROC_MAPLIST takes (char *), returns (struct ypmaplist *). 681832Swollman */ 691832Swollman 701832Swollman#ifndef BOOL_DEFINED 711832Swollmantypedef u_int bool; 721832Swollman#define BOOL_DEFINED 731832Swollman#endif 741832Swollman 751832Swollman/* Program and version symbols, magic numbers */ 761832Swollman 771832Swollman#define YPPROG ((u_long)100004) 781832Swollman#define YPVERS ((u_long)2) 791832Swollman#define YPVERS_ORIG ((u_long)1) 801832Swollman#define YPMAXRECORD ((u_long)1024) 811832Swollman#define YPMAXDOMAIN ((u_long)64) 821832Swollman#define YPMAXMAP ((u_long)64) 831832Swollman#define YPMAXPEER ((u_long)256) 841832Swollman 851832Swollman/* 861832Swollman * I don't know if anything of sun's depends on this, or if they 871832Swollman * simply defined it so that their own code wouldn't try to send 881832Swollman * packets over the ethernet MTU. This YP code doesn't use it. 891832Swollman */ 901832Swollman#define YPMSGSZ 1600 911832Swollman 921832Swollman#ifndef DATUM 931832Swollmantypedef struct { 941832Swollman char *dptr; 951832Swollman int dsize; 961832Swollman} datum; 971832Swollman#define DATUM 981832Swollman#endif 991832Swollman 1001832Swollmanstruct ypmap_parms { 1011832Swollman char *domain; 1021832Swollman char *map; 103129777Stmm u_int ordernum; 1041832Swollman char *owner; 1051832Swollman}; 1061832Swollman 1071832Swollmanstruct ypreq_key { 1081832Swollman char *domain; 1091832Swollman char *map; 1101832Swollman datum keydat; 1111832Swollman}; 1121832Swollman 1131832Swollmanstruct ypreq_nokey { 1141832Swollman char *domain; 1151832Swollman char *map; 1161832Swollman}; 1171832Swollman 1181832Swollmanstruct ypreq_xfr { 1191832Swollman struct ypmap_parms map_parms; 120129777Stmm u_int transid; 121129777Stmm u_int proto; 122129777Stmm u_int port; 1231832Swollman}; 1241832Swollman#define ypxfr_domain map_parms.domain 1251832Swollman#define ypxfr_map map_parms.map 1261832Swollman#define ypxfr_ordernum map_parms.ordernum 1271832Swollman#define ypxfr_owner map_parms.owner 1281832Swollman 1291832Swollmanstruct ypresp_val { 130129777Stmm u_int status; 1311832Swollman datum valdat; 1321832Swollman}; 1331832Swollman 1341832Swollmanstruct ypresp_key_val { 135129777Stmm u_int status; 1361832Swollman datum keydat; 1371832Swollman datum valdat; 1381832Swollman}; 1391832Swollman 1401832Swollmanstruct ypresp_master { 141129777Stmm u_int status; 1421832Swollman char *master; 1431832Swollman}; 1441832Swollman 1451832Swollmanstruct ypresp_order { 146129777Stmm u_int status; 147129777Stmm u_int ordernum; 1481832Swollman}; 1491832Swollman 1501832Swollmanstruct ypmaplist { 151153149Speter char *ypml_name; 1521832Swollman struct ypmaplist *ypml_next; 1531832Swollman}; 1541832Swollman 1551832Swollmanstruct ypresp_maplist { 156129777Stmm u_int status; 1571832Swollman struct ypmaplist *list; 1581832Swollman}; 1591832Swollman 1601832Swollman/* ypserv procedure numbers */ 1611832Swollman#define YPPROC_NULL ((u_long)0) 1621832Swollman#define YPPROC_DOMAIN ((u_long)1) 1631832Swollman#define YPPROC_DOMAIN_NONACK ((u_long)2) 1641832Swollman#define YPPROC_MATCH ((u_long)3) 1651832Swollman#define YPPROC_FIRST ((u_long)4) 1661832Swollman#define YPPROC_NEXT ((u_long)5) 1671832Swollman#define YPPROC_XFR ((u_long)6) 1681832Swollman#define YPPROC_CLEAR ((u_long)7) 1691832Swollman#define YPPROC_ALL ((u_long)8) 1701832Swollman#define YPPROC_MASTER ((u_long)9) 1711832Swollman#define YPPROC_ORDER ((u_long)10) 1721832Swollman#define YPPROC_MAPLIST ((u_long)11) 1731832Swollman 1741832Swollman/* ypserv procedure return status values */ 1751832Swollman#define YP_TRUE ((long)1) /* general purpose success code */ 1761832Swollman#define YP_NOMORE ((long)2) /* no more entries in map */ 1771832Swollman#define YP_FALSE ((long)0) /* general purpose failure code */ 1781832Swollman#define YP_NOMAP ((long)-1) /* no such map in domain */ 1791832Swollman#define YP_NODOM ((long)-2) /* domain not supported */ 1801832Swollman#define YP_NOKEY ((long)-3) /* no such key in map */ 1811832Swollman#define YP_BADOP ((long)-4) /* invalid operation */ 1821832Swollman#define YP_BADDB ((long)-5) /* server data base is bad */ 1831832Swollman#define YP_YPERR ((long)-6) /* YP server error */ 1841832Swollman#define YP_BADARGS ((long)-7) /* request arguments bad */ 1851832Swollman#define YP_VERS ((long)-8) /* YP server version mismatch */ 1861832Swollman 1871832Swollman/* 1881832Swollman * Sun's header file says: 1891832Swollman * "Domain binding data structure, used by ypclnt package and ypserv modules. 1901832Swollman * Users of the ypclnt package (or of this protocol) don't HAVE to know about 1911832Swollman * it, but it must be available to users because _yp_dobind is a public 1921832Swollman * interface." 1938858Srgrimes * 1941832Swollman * This is totally bogus! Nowhere else does Sun state that _yp_dobind() is 1951832Swollman * a public interface, and I don't know any reason anyone would want to call 1961832Swollman * it. But, just in case anyone does actually expect it to be available.. 1971832Swollman * we provide this.. exactly as Sun wants it. 1981832Swollman */ 1991832Swollmanstruct dom_binding { 2001832Swollman struct dom_binding *dom_pnext; 2011832Swollman char dom_domain[YPMAXDOMAIN + 1]; 2021832Swollman struct sockaddr_in dom_server_addr; 2031832Swollman u_short dom_server_port; 2041832Swollman int dom_socket; 2051832Swollman CLIENT *dom_client; 2061832Swollman u_short dom_local_port; 2071832Swollman long dom_vers; 2081832Swollman}; 2091832Swollman 2101832Swollman/* 2111832Swollman * YPBIND PROTOCOL: 2128858Srgrimes * 2131832Swollman * ypbind supports the following procedures: 2141832Swollman * 2151832Swollman * YPBINDPROC_NULL takes (void), returns (void). 2161832Swollman * to check if ypbind is running. 2171832Swollman * YPBINDPROC_DOMAIN takes (char *), returns (struct ypbind_resp). 2181832Swollman * requests that ypbind start to serve the 2191832Swollman * named domain (if it doesn't already) 2201832Swollman * YPBINDPROC_SETDOM takes (struct ypbind_setdom), returns (void). 2211832Swollman * used by ypset. 2221832Swollman */ 2238858Srgrimes 2241832Swollman#define YPBINDPROG ((u_long)100007) 2251832Swollman#define YPBINDVERS ((u_long)2) 2261832Swollman#define YPBINDVERS_ORIG ((u_long)1) 2271832Swollman 2281832Swollman/* ypbind procedure numbers */ 2291832Swollman#define YPBINDPROC_NULL ((u_long)0) 2301832Swollman#define YPBINDPROC_DOMAIN ((u_long)1) 2311832Swollman#define YPBINDPROC_SETDOM ((u_long)2) 2321832Swollman 2331832Swollman/* error code in ypbind_resp.ypbind_status */ 2341832Swollmanenum ypbind_resptype { 2351832Swollman YPBIND_SUCC_VAL = 1, 2361832Swollman YPBIND_FAIL_VAL = 2 2371832Swollman}; 2381832Swollman 2391832Swollman/* network order, of course */ 2401832Swollmanstruct ypbind_binding { 2411832Swollman struct in_addr ypbind_binding_addr; 2421832Swollman u_short ypbind_binding_port; 2431832Swollman}; 2441832Swollman 2451832Swollmanstruct ypbind_resp { 2461832Swollman enum ypbind_resptype ypbind_status; 2471832Swollman union { 248129777Stmm u_int ypbind_error; 2491832Swollman struct ypbind_binding ypbind_bindinfo; 2501832Swollman } ypbind_respbody; 2511832Swollman}; 2521832Swollman 2531832Swollman/* error code in ypbind_resp.ypbind_respbody.ypbind_error */ 2541832Swollman#define YPBIND_ERR_ERR 1 /* internal error */ 2551832Swollman#define YPBIND_ERR_NOSERV 2 /* no bound server for passed domain */ 2561832Swollman#define YPBIND_ERR_RESC 3 /* system resource allocation failure */ 2571832Swollman 2581832Swollman/* 2591832Swollman * Request data structure for ypbind "Set domain" procedure. 2601832Swollman */ 2611832Swollmanstruct ypbind_setdom { 2621832Swollman char ypsetdom_domain[YPMAXDOMAIN + 1]; 2631832Swollman struct ypbind_binding ypsetdom_binding; 264129777Stmm u_int ypsetdom_vers; 2651832Swollman}; 2661832Swollman#define ypsetdom_addr ypsetdom_binding.ypbind_binding_addr 2671832Swollman#define ypsetdom_port ypsetdom_binding.ypbind_binding_port 2681832Swollman 2691832Swollman/* 2701832Swollman * YPPUSH PROTOCOL: 2718858Srgrimes * 2721832Swollman * Sun says: 2731832Swollman * "Protocol between clients (ypxfr, only) and yppush 2741832Swollman * yppush speaks a protocol in the transient range, which 2751832Swollman * is supplied to ypxfr as a command-line parameter when it 2761832Swollman * is activated by ypserv." 2778858Srgrimes * 27813771Smpp * This protocol is not implemented, naturally, because this YP 27913771Smpp * implementation only does the client side. 2801832Swollman */ 2811832Swollman#define YPPUSHVERS ((u_long)1) 2821832Swollman#define YPPUSHVERS_ORIG ((u_long)1) 2831832Swollman 2841832Swollman/* yppush procedure numbers */ 2851832Swollman#define YPPUSHPROC_NULL ((u_long)0) 2861832Swollman#define YPPUSHPROC_XFRRESP ((u_long)1) 2871832Swollman 2881832Swollmanstruct yppushresp_xfr { 289129777Stmm u_int transid; 290129777Stmm u_int status; 2911832Swollman}; 2921832Swollman 2931832Swollman/* yppush status value in yppushresp_xfr.status */ 2941832Swollman#define YPPUSH_SUCC ((long)1) /* Success */ 2951832Swollman#define YPPUSH_AGE ((long)2) /* Master's version not newer */ 2961832Swollman#define YPPUSH_NOMAP ((long)-1) /* Can't find server for map */ 2971832Swollman#define YPPUSH_NODOM ((long)-2) /* Domain not supported */ 29813771Smpp#define YPPUSH_RSRC ((long)-3) /* Local resource alloc failure */ 2991832Swollman#define YPPUSH_RPC ((long)-4) /* RPC failure talking to server */ 3001832Swollman#define YPPUSH_MADDR ((long)-5) /* Can't get master address */ 3011832Swollman#define YPPUSH_YPERR ((long)-6) /* YP server/map db error */ 3021832Swollman#define YPPUSH_BADARGS ((long)-7) /* Request arguments bad */ 3031832Swollman#define YPPUSH_DBM ((long)-8) /* Local dbm operation failed */ 3041832Swollman#define YPPUSH_FILE ((long)-9) /* Local file I/O operation failed */ 3051832Swollman#define YPPUSH_SKEW ((long)-10) /* Map version skew during transfer */ 3061832Swollman#define YPPUSH_CLEAR ((long)-11) /* Can't send "Clear" req to local ypserv */ 3071832Swollman#define YPPUSH_FORCE ((long)-12) /* No local order number in map - use -f */ 3081832Swollman#define YPPUSH_XFRERR ((long)-13) /* ypxfr error */ 3091832Swollman#define YPPUSH_REFUSED ((long)-14) /* Transfer request refused by ypserv */ 3101832Swollman 31121060Speterstruct inaddr; 31221060Speter__BEGIN_DECLS 31390297Sdesbool_t xdr_datum(XDR *, datum *); 31490297Sdesbool_t xdr_ypreq_key(XDR *, struct ypreq_key *); 31590297Sdesbool_t xdr_ypreq_nokey(XDR *, struct ypreq_nokey *); 31690297Sdesbool_t xdr_ypreq_xfr(XDR *, struct ypreq_xfr *); 31790297Sdesbool_t xdr_ypresp_val(XDR *, struct ypresp_val *); 31890297Sdesbool_t xdr_ypresp_key_val(XDR *, struct ypresp_key_val *); 31990297Sdesbool_t xdr_ypbind_resp(XDR *, struct ypbind_resp *); 32090297Sdesbool_t xdr_ypbind_setdom(XDR *, struct ypbind_setdom *); 32190297Sdesbool_t xdr_yp_inaddr(XDR *, struct inaddr *); 32290297Sdesbool_t xdr_ypmap_parms(XDR *, struct ypmap_parms *); 32390297Sdesbool_t xdr_yppushresp_xfr(XDR *, struct yppushresp_xfr *); 32490297Sdesbool_t xdr_ypresp_order(XDR *, struct ypresp_order *); 32590297Sdesbool_t xdr_ypresp_master(XDR *, struct ypresp_master *); 32690297Sdesbool_t xdr_ypresp_maplist(XDR *, struct ypresp_maplist *); 32721060Speter__END_DECLS 32821060Speter 32921060Speter#endif /* _RPCSVC_YP_PROT_H_ */ 330