yp_prot.h revision 8858
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 * 298858Srgrimes * $Id: yp_prot.h,v 1.1 1994/08/04 19:01:56 wollman Exp $ 301832Swollman */ 311832Swollman 321832Swollman#ifndef _YP_PROT_H_ 331832Swollman#define _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 751832Swollmanbool_t xdr_datum(); 761832Swollmanbool_t xdr_ypdomain_wrap_string(); 771832Swollmanbool_t xdr_ypmap_wrap_string(); 781832Swollmanbool_t xdr_ypreq_key(); 791832Swollmanbool_t xdr_ypreq_nokey(); 801832Swollmanbool_t xdr_ypreq_xfr(); 811832Swollmanbool_t xdr_ypresp_val(); 821832Swollmanbool_t xdr_ypresp_key_val(); 831832Swollmanbool_t xdr_ypbind_resp(); 841832Swollmanbool_t xdr_ypbind_setdom(); 851832Swollmanbool_t xdr_yp_inaddr(); 861832Swollmanbool_t xdr_ypmap_parms(); 871832Swollmanbool_t xdr_ypowner_wrap_string(); 881832Swollmanbool_t xdr_yppushresp_xfr(); 891832Swollmanbool_t xdr_ypresp_order(); 901832Swollmanbool_t xdr_ypresp_master(); 911832Swollmanbool_t xdr_ypall(); 921832Swollmanbool_t xdr_ypresp_maplist(); 931832Swollman 941832Swollman/* Program and version symbols, magic numbers */ 951832Swollman 961832Swollman#define YPPROG ((u_long)100004) 971832Swollman#define YPVERS ((u_long)2) 981832Swollman#define YPVERS_ORIG ((u_long)1) 991832Swollman#define YPMAXRECORD ((u_long)1024) 1001832Swollman#define YPMAXDOMAIN ((u_long)64) 1011832Swollman#define YPMAXMAP ((u_long)64) 1021832Swollman#define YPMAXPEER ((u_long)256) 1031832Swollman 1041832Swollman/* 1051832Swollman * I don't know if anything of sun's depends on this, or if they 1061832Swollman * simply defined it so that their own code wouldn't try to send 1071832Swollman * packets over the ethernet MTU. This YP code doesn't use it. 1081832Swollman */ 1091832Swollman#define YPMSGSZ 1600 1101832Swollman 1111832Swollman#ifndef DATUM 1121832Swollmantypedef struct { 1131832Swollman char *dptr; 1141832Swollman int dsize; 1151832Swollman} datum; 1161832Swollman#define DATUM 1171832Swollman#endif 1181832Swollman 1191832Swollmanstruct ypmap_parms { 1201832Swollman char *domain; 1211832Swollman char *map; 1221832Swollman u_long ordernum; 1231832Swollman char *owner; 1241832Swollman}; 1251832Swollman 1261832Swollmanstruct ypreq_key { 1271832Swollman char *domain; 1281832Swollman char *map; 1291832Swollman datum keydat; 1301832Swollman}; 1311832Swollman 1321832Swollmanstruct ypreq_nokey { 1331832Swollman char *domain; 1341832Swollman char *map; 1351832Swollman}; 1361832Swollman 1371832Swollmanstruct ypreq_xfr { 1381832Swollman struct ypmap_parms map_parms; 1391832Swollman u_long transid; 1401832Swollman u_long proto; 1411832Swollman u_short port; 1421832Swollman}; 1431832Swollman#define ypxfr_domain map_parms.domain 1441832Swollman#define ypxfr_map map_parms.map 1451832Swollman#define ypxfr_ordernum map_parms.ordernum 1461832Swollman#define ypxfr_owner map_parms.owner 1471832Swollman 1481832Swollmanstruct ypresp_val { 1491832Swollman u_long status; 1501832Swollman datum valdat; 1511832Swollman}; 1521832Swollman 1531832Swollmanstruct ypresp_key_val { 1541832Swollman u_long status; 1551832Swollman datum keydat; 1561832Swollman datum valdat; 1571832Swollman}; 1581832Swollman 1591832Swollmanstruct ypresp_master { 1601832Swollman u_long status; 1611832Swollman char *master; 1621832Swollman}; 1631832Swollman 1641832Swollmanstruct ypresp_order { 1651832Swollman u_long status; 1661832Swollman u_long ordernum; 1671832Swollman}; 1681832Swollman 1691832Swollmanstruct ypmaplist { 1701832Swollman char ypml_name[YPMAXMAP + 1]; 1711832Swollman struct ypmaplist *ypml_next; 1721832Swollman}; 1731832Swollman 1741832Swollmanstruct ypresp_maplist { 1751832Swollman u_long status; 1761832Swollman struct ypmaplist *list; 1771832Swollman}; 1781832Swollman 1791832Swollman/* ypserv procedure numbers */ 1801832Swollman#define YPPROC_NULL ((u_long)0) 1811832Swollman#define YPPROC_DOMAIN ((u_long)1) 1821832Swollman#define YPPROC_DOMAIN_NONACK ((u_long)2) 1831832Swollman#define YPPROC_MATCH ((u_long)3) 1841832Swollman#define YPPROC_FIRST ((u_long)4) 1851832Swollman#define YPPROC_NEXT ((u_long)5) 1861832Swollman#define YPPROC_XFR ((u_long)6) 1871832Swollman#define YPPROC_CLEAR ((u_long)7) 1881832Swollman#define YPPROC_ALL ((u_long)8) 1891832Swollman#define YPPROC_MASTER ((u_long)9) 1901832Swollman#define YPPROC_ORDER ((u_long)10) 1911832Swollman#define YPPROC_MAPLIST ((u_long)11) 1921832Swollman 1931832Swollman/* ypserv procedure return status values */ 1941832Swollman#define YP_TRUE ((long)1) /* general purpose success code */ 1951832Swollman#define YP_NOMORE ((long)2) /* no more entries in map */ 1961832Swollman#define YP_FALSE ((long)0) /* general purpose failure code */ 1971832Swollman#define YP_NOMAP ((long)-1) /* no such map in domain */ 1981832Swollman#define YP_NODOM ((long)-2) /* domain not supported */ 1991832Swollman#define YP_NOKEY ((long)-3) /* no such key in map */ 2001832Swollman#define YP_BADOP ((long)-4) /* invalid operation */ 2011832Swollman#define YP_BADDB ((long)-5) /* server data base is bad */ 2021832Swollman#define YP_YPERR ((long)-6) /* YP server error */ 2031832Swollman#define YP_BADARGS ((long)-7) /* request arguments bad */ 2041832Swollman#define YP_VERS ((long)-8) /* YP server version mismatch */ 2051832Swollman 2061832Swollman/* 2071832Swollman * Sun's header file says: 2081832Swollman * "Domain binding data structure, used by ypclnt package and ypserv modules. 2091832Swollman * Users of the ypclnt package (or of this protocol) don't HAVE to know about 2101832Swollman * it, but it must be available to users because _yp_dobind is a public 2111832Swollman * interface." 2128858Srgrimes * 2131832Swollman * This is totally bogus! Nowhere else does Sun state that _yp_dobind() is 2141832Swollman * a public interface, and I don't know any reason anyone would want to call 2151832Swollman * it. But, just in case anyone does actually expect it to be available.. 2161832Swollman * we provide this.. exactly as Sun wants it. 2171832Swollman */ 2181832Swollmanstruct dom_binding { 2191832Swollman struct dom_binding *dom_pnext; 2201832Swollman char dom_domain[YPMAXDOMAIN + 1]; 2211832Swollman struct sockaddr_in dom_server_addr; 2221832Swollman u_short dom_server_port; 2231832Swollman int dom_socket; 2241832Swollman CLIENT *dom_client; 2251832Swollman u_short dom_local_port; 2261832Swollman long dom_vers; 2271832Swollman}; 2281832Swollman 2291832Swollman/* 2301832Swollman * YPBIND PROTOCOL: 2318858Srgrimes * 2321832Swollman * ypbind supports the following procedures: 2331832Swollman * 2341832Swollman * YPBINDPROC_NULL takes (void), returns (void). 2351832Swollman * to check if ypbind is running. 2361832Swollman * YPBINDPROC_DOMAIN takes (char *), returns (struct ypbind_resp). 2371832Swollman * requests that ypbind start to serve the 2381832Swollman * named domain (if it doesn't already) 2391832Swollman * YPBINDPROC_SETDOM takes (struct ypbind_setdom), returns (void). 2401832Swollman * used by ypset. 2411832Swollman */ 2428858Srgrimes 2431832Swollman#define YPBINDPROG ((u_long)100007) 2441832Swollman#define YPBINDVERS ((u_long)2) 2451832Swollman#define YPBINDVERS_ORIG ((u_long)1) 2461832Swollman 2471832Swollman/* ypbind procedure numbers */ 2481832Swollman#define YPBINDPROC_NULL ((u_long)0) 2491832Swollman#define YPBINDPROC_DOMAIN ((u_long)1) 2501832Swollman#define YPBINDPROC_SETDOM ((u_long)2) 2511832Swollman 2521832Swollman/* error code in ypbind_resp.ypbind_status */ 2531832Swollmanenum ypbind_resptype { 2541832Swollman YPBIND_SUCC_VAL = 1, 2551832Swollman YPBIND_FAIL_VAL = 2 2561832Swollman}; 2571832Swollman 2581832Swollman/* network order, of course */ 2591832Swollmanstruct ypbind_binding { 2601832Swollman struct in_addr ypbind_binding_addr; 2611832Swollman u_short ypbind_binding_port; 2621832Swollman}; 2631832Swollman 2641832Swollmanstruct ypbind_resp { 2651832Swollman enum ypbind_resptype ypbind_status; 2661832Swollman union { 2671832Swollman u_long ypbind_error; 2681832Swollman struct ypbind_binding ypbind_bindinfo; 2691832Swollman } ypbind_respbody; 2701832Swollman}; 2711832Swollman 2721832Swollman/* error code in ypbind_resp.ypbind_respbody.ypbind_error */ 2731832Swollman#define YPBIND_ERR_ERR 1 /* internal error */ 2741832Swollman#define YPBIND_ERR_NOSERV 2 /* no bound server for passed domain */ 2751832Swollman#define YPBIND_ERR_RESC 3 /* system resource allocation failure */ 2761832Swollman 2771832Swollman/* 2781832Swollman * Request data structure for ypbind "Set domain" procedure. 2791832Swollman */ 2801832Swollmanstruct ypbind_setdom { 2811832Swollman char ypsetdom_domain[YPMAXDOMAIN + 1]; 2821832Swollman struct ypbind_binding ypsetdom_binding; 2831832Swollman u_short ypsetdom_vers; 2841832Swollman}; 2851832Swollman#define ypsetdom_addr ypsetdom_binding.ypbind_binding_addr 2861832Swollman#define ypsetdom_port ypsetdom_binding.ypbind_binding_port 2871832Swollman 2881832Swollman/* 2891832Swollman * YPPUSH PROTOCOL: 2908858Srgrimes * 2911832Swollman * Sun says: 2921832Swollman * "Protocol between clients (ypxfr, only) and yppush 2931832Swollman * yppush speaks a protocol in the transient range, which 2941832Swollman * is supplied to ypxfr as a command-line parameter when it 2951832Swollman * is activated by ypserv." 2968858Srgrimes * 2971832Swollman * This protocol is not implimented, naturally, because this YP 2981832Swollman * implimentation only does the client side. 2991832Swollman */ 3001832Swollman#define YPPUSHVERS ((u_long)1) 3011832Swollman#define YPPUSHVERS_ORIG ((u_long)1) 3021832Swollman 3031832Swollman/* yppush procedure numbers */ 3041832Swollman#define YPPUSHPROC_NULL ((u_long)0) 3051832Swollman#define YPPUSHPROC_XFRRESP ((u_long)1) 3061832Swollman 3071832Swollmanstruct yppushresp_xfr { 3081832Swollman u_long transid; 3091832Swollman u_long status; 3101832Swollman}; 3111832Swollman 3121832Swollman/* yppush status value in yppushresp_xfr.status */ 3131832Swollman#define YPPUSH_SUCC ((long)1) /* Success */ 3141832Swollman#define YPPUSH_AGE ((long)2) /* Master's version not newer */ 3151832Swollman#define YPPUSH_NOMAP ((long)-1) /* Can't find server for map */ 3161832Swollman#define YPPUSH_NODOM ((long)-2) /* Domain not supported */ 3171832Swollman#define YPPUSH_RSRC ((long)-3) /* Local resouce alloc failure */ 3181832Swollman#define YPPUSH_RPC ((long)-4) /* RPC failure talking to server */ 3191832Swollman#define YPPUSH_MADDR ((long)-5) /* Can't get master address */ 3201832Swollman#define YPPUSH_YPERR ((long)-6) /* YP server/map db error */ 3211832Swollman#define YPPUSH_BADARGS ((long)-7) /* Request arguments bad */ 3221832Swollman#define YPPUSH_DBM ((long)-8) /* Local dbm operation failed */ 3231832Swollman#define YPPUSH_FILE ((long)-9) /* Local file I/O operation failed */ 3241832Swollman#define YPPUSH_SKEW ((long)-10) /* Map version skew during transfer */ 3251832Swollman#define YPPUSH_CLEAR ((long)-11) /* Can't send "Clear" req to local ypserv */ 3261832Swollman#define YPPUSH_FORCE ((long)-12) /* No local order number in map - use -f */ 3271832Swollman#define YPPUSH_XFRERR ((long)-13) /* ypxfr error */ 3281832Swollman#define YPPUSH_REFUSED ((long)-14) /* Transfer request refused by ypserv */ 3291832Swollman 3301832Swollman#endif /* _YP_PROT_H_ */ 331