131387Scharnier/* @(#)yp.x	2.1 88/08/01 4.0 RPCSRC */
231387Scharnier
3273188Shrs/*-
4273188Shrs * Copyright (c) 2010, Oracle America, Inc.
5273188Shrs *
6273188Shrs * Redistribution and use in source and binary forms, with or without
7273188Shrs * modification, are permitted provided that the following conditions are
8273188Shrs * met:
9273188Shrs *
10273188Shrs *     * Redistributions of source code must retain the above copyright
11273188Shrs *       notice, this list of conditions and the following disclaimer.
12273188Shrs *     * Redistributions in binary form must reproduce the above
13273188Shrs *       copyright notice, this list of conditions and the following
14273188Shrs *       disclaimer in the documentation and/or other materials
15273188Shrs *       provided with the distribution.
16273188Shrs *     * Neither the name of the "Oracle America, Inc." nor the names of its
17273188Shrs *       contributors may be used to endorse or promote products derived
18273188Shrs *       from this software without specific prior written permission.
19273188Shrs *
20273188Shrs *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21273188Shrs *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22273188Shrs *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23273188Shrs *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24273188Shrs *   COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
25273188Shrs *   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26273188Shrs *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
27273188Shrs *   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28273188Shrs *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29273188Shrs *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30273188Shrs *   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31273188Shrs *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
321832Swollman */
331832Swollman
341832Swollman/*
351832Swollman * Protocol description file for the Yellow Pages Service
361832Swollman */
371832Swollman
381832Swollman#ifndef RPC_HDR
39114629Sobrien%#include <sys/cdefs.h>
40114629Sobrien%__FBSDID("$FreeBSD$");
411832Swollman#endif
421832Swollman
431832Swollmanconst YPMAXRECORD = 1024;
441832Swollmanconst YPMAXDOMAIN = 64;
451832Swollmanconst YPMAXMAP = 64;
461832Swollmanconst YPMAXPEER = 64;
471832Swollman
481832Swollman
491832Swollmanenum ypstat {
501832Swollman	YP_TRUE		=  1,
511832Swollman	YP_NOMORE	=  2,
521832Swollman	YP_FALSE	=  0,
531832Swollman	YP_NOMAP	= -1,
541832Swollman	YP_NODOM	= -2,
551832Swollman	YP_NOKEY	= -3,
561832Swollman	YP_BADOP	= -4,
571832Swollman	YP_BADDB	= -5,
581832Swollman	YP_YPERR	= -6,
591832Swollman	YP_BADARGS	= -7,
601832Swollman	YP_VERS		= -8
611832Swollman};
621832Swollman
631832Swollman
641832Swollmanenum ypxfrstat {
651832Swollman	YPXFR_SUCC	=  1,
661832Swollman	YPXFR_AGE	=  2,
671832Swollman	YPXFR_NOMAP	= -1,
681832Swollman	YPXFR_NODOM	= -2,
691832Swollman	YPXFR_RSRC	= -3,
701832Swollman	YPXFR_RPC	= -4,
711832Swollman	YPXFR_MADDR	= -5,
721832Swollman	YPXFR_YPERR	= -6,
731832Swollman	YPXFR_BADARGS	= -7,
741832Swollman	YPXFR_DBM	= -8,
751832Swollman	YPXFR_FILE	= -9,
761832Swollman	YPXFR_SKEW	= -10,
771832Swollman	YPXFR_CLEAR	= -11,
781832Swollman	YPXFR_FORCE	= -12,
791832Swollman	YPXFR_XFRERR	= -13,
801832Swollman	YPXFR_REFUSED	= -14
811832Swollman};
821832Swollman
831832Swollman
841832Swollmantypedef string domainname<YPMAXDOMAIN>;
851832Swollmantypedef string mapname<YPMAXMAP>;
861832Swollmantypedef string peername<YPMAXPEER>;
871832Swollmantypedef opaque keydat<YPMAXRECORD>;
881832Swollmantypedef opaque valdat<YPMAXRECORD>;
891832Swollman
901832Swollman
911832Swollmanstruct ypmap_parms {
921832Swollman	domainname domain;
931832Swollman	mapname map;
941832Swollman	unsigned int ordernum;
951832Swollman	peername peer;
961832Swollman};
971832Swollman
981832Swollmanstruct ypreq_key {
991832Swollman	domainname domain;
1001832Swollman	mapname map;
1011832Swollman	keydat key;
1021832Swollman};
1031832Swollman
1041832Swollmanstruct ypreq_nokey {
1051832Swollman	domainname domain;
1061832Swollman	mapname map;
1071832Swollman};
1081832Swollman
1091832Swollmanstruct ypreq_xfr {
1101832Swollman	ypmap_parms map_parms;
1111832Swollman	unsigned int transid;
1121832Swollman	unsigned int prog;
1131832Swollman	unsigned int port;
1141832Swollman};
1151832Swollman
1161832Swollman
1171832Swollmanstruct ypresp_val {
1181832Swollman	ypstat stat;
1191832Swollman	valdat val;
1201832Swollman};
1211832Swollman
1221832Swollmanstruct ypresp_key_val {
1231832Swollman	ypstat stat;
12412677Swpaul#ifdef STUPID_SUN_BUG /* These are backwards */
1251832Swollman	keydat key;
1261832Swollman	valdat val;
12712677Swpaul#else
12812677Swpaul	valdat val;
12912677Swpaul	keydat key;
13012677Swpaul#endif
1311832Swollman};
1321832Swollman
1331832Swollman
1341832Swollmanstruct ypresp_master {
1351832Swollman	ypstat stat;
1361832Swollman	peername peer;
1371832Swollman};
1381832Swollman
1391832Swollmanstruct ypresp_order {
1401832Swollman	ypstat stat;
1411832Swollman	unsigned int ordernum;
1421832Swollman};
1431832Swollman
1441832Swollmanunion ypresp_all switch (bool more) {
1451832Swollmancase TRUE:
1461832Swollman	ypresp_key_val val;
1471832Swollmancase FALSE:
1481832Swollman	void;
1491832Swollman};
1501832Swollman
1511832Swollmanstruct ypresp_xfr {
1521832Swollman	unsigned int transid;
1531832Swollman	ypxfrstat xfrstat;
1541832Swollman};
1551832Swollman
1561832Swollmanstruct ypmaplist {
1571832Swollman	mapname map;
1581832Swollman	ypmaplist *next;
1591832Swollman};
1601832Swollman
1611832Swollmanstruct ypresp_maplist {
1621832Swollman	ypstat stat;
1631832Swollman	ypmaplist *maps;
1641832Swollman};
1651832Swollman
1661832Swollmanenum yppush_status {
1671832Swollman	YPPUSH_SUCC	=  1,	/* Success */
1681832Swollman	YPPUSH_AGE 	=  2,	/* Master's version not newer */
1691832Swollman	YPPUSH_NOMAP	= -1,	/* Can't find server for map */
1701832Swollman	YPPUSH_NODOM	= -2,	/* Domain not supported */
1711832Swollman	YPPUSH_RSRC	= -3,	/* Local resource alloc failure */
1721832Swollman	YPPUSH_RPC	= -4,	/* RPC failure talking to server */
1731832Swollman	YPPUSH_MADDR 	= -5,	/* Can't get master address */
1741832Swollman	YPPUSH_YPERR	= -6,	/* YP server/map db error */
1751832Swollman	YPPUSH_BADARGS	= -7,	/* Request arguments bad */
1761832Swollman	YPPUSH_DBM	= -8,	/* Local dbm operation failed */
1771832Swollman	YPPUSH_FILE	= -9,	/* Local file I/O operation failed */
1781832Swollman	YPPUSH_SKEW	= -10,	/* Map version skew during transfer */
1791832Swollman	YPPUSH_CLEAR	= -11,	/* Can't send "Clear" req to local ypserv */
1801832Swollman	YPPUSH_FORCE	= -12,	/* No local order number in map  use -f flag. */
1811832Swollman	YPPUSH_XFRERR 	= -13,	/* ypxfr error */
1821832Swollman	YPPUSH_REFUSED	= -14 	/* Transfer request refused by ypserv */
1831832Swollman};
1841832Swollman
1851832Swollmanstruct yppushresp_xfr {
1861832Swollman	unsigned transid;
1871832Swollman	yppush_status status;
1881832Swollman};
1891832Swollman
1901832Swollman/*
1911832Swollman * Response structure and overall result status codes.  Success and failure
1921832Swollman * represent two separate response message types.
1931832Swollman */
1941832Swollman
1951832Swollmanenum ypbind_resptype {
1961832Swollman	YPBIND_SUCC_VAL = 1,
1971832Swollman	YPBIND_FAIL_VAL = 2
1981832Swollman};
1991832Swollman
2001832Swollmanstruct ypbind_binding {
2011832Swollman    opaque ypbind_binding_addr[4]; /* In network order */
2021832Swollman    opaque ypbind_binding_port[2]; /* In network order */
2031832Swollman};
2041832Swollman
2051832Swollmanunion ypbind_resp switch (ypbind_resptype ypbind_status) {
2061832Swollmancase YPBIND_FAIL_VAL:
2071832Swollman        unsigned ypbind_error;
2081832Swollmancase YPBIND_SUCC_VAL:
2091832Swollman        ypbind_binding ypbind_bindinfo;
2101832Swollman};
2111832Swollman
2121832Swollman/* Detailed failure reason codes for response field ypbind_error*/
2131832Swollman
2141832Swollmanconst YPBIND_ERR_ERR    = 1;	/* Internal error */
2151832Swollmanconst YPBIND_ERR_NOSERV = 2;	/* No bound server for passed domain */
2161832Swollmanconst YPBIND_ERR_RESC   = 3;	/* System resource allocation failure */
2171832Swollman
2181832Swollman
2191832Swollman/*
2201832Swollman * Request data structure for ypbind "Set domain" procedure.
2211832Swollman */
2221832Swollmanstruct ypbind_setdom {
2231832Swollman	domainname ypsetdom_domain;
2241832Swollman	ypbind_binding ypsetdom_binding;
2251832Swollman	unsigned ypsetdom_vers;
2261832Swollman};
2271832Swollman
22814261Swpaul
22914261Swpaul/*
23014261Swpaul * NIS v1 support for backwards compatibility
23114261Swpaul */
23214261Swpaulenum ypreqtype {
23314261Swpaul	YPREQ_KEY = 1,
23414261Swpaul	YPREQ_NOKEY = 2,
23514261Swpaul	YPREQ_MAP_PARMS = 3
23614261Swpaul};
23714261Swpaul
23814261Swpaulenum ypresptype {
23914261Swpaul	YPRESP_VAL = 1,
24014261Swpaul	YPRESP_KEY_VAL = 2,
24114261Swpaul	YPRESP_MAP_PARMS = 3
24214261Swpaul};
24314261Swpaul
24414261Swpaulunion yprequest switch (ypreqtype yp_reqtype) {
24514261Swpaulcase YPREQ_KEY:
24614261Swpaul	ypreq_key yp_req_keytype;
24714261Swpaulcase YPREQ_NOKEY:
24814261Swpaul	ypreq_nokey yp_req_nokeytype;
24914261Swpaulcase YPREQ_MAP_PARMS:
25014261Swpaul	ypmap_parms yp_req_map_parmstype;
25114261Swpaul};
25214261Swpaul
25314261Swpaulunion ypresponse switch (ypresptype yp_resptype) {
25414261Swpaulcase YPRESP_VAL:
25514261Swpaul	ypresp_val yp_resp_valtype;
25614261Swpaulcase YPRESP_KEY_VAL:
25714261Swpaul	ypresp_key_val yp_resp_key_valtype;
25814261Swpaulcase YPRESP_MAP_PARMS:
25914261Swpaul	ypmap_parms yp_resp_map_parmstype;
26014261Swpaul};
26114261Swpaul
26212677Swpaul#if !defined(YPBIND_ONLY) && !defined(YPPUSH_ONLY)
2631832Swollman/*
2641832Swollman * YP access protocol
2651832Swollman */
2661832Swollmanprogram YPPROG {
26714261Swpaul/*
26814261Swpaul * NIS v1 support for backwards compatibility
26914261Swpaul */
27014261Swpaul	version YPOLDVERS {
27114261Swpaul		void
27214261Swpaul		YPOLDPROC_NULL(void) = 0;
27314261Swpaul
27414261Swpaul		bool
27514261Swpaul		YPOLDPROC_DOMAIN(domainname) = 1;
27614261Swpaul
27714261Swpaul		bool
27814261Swpaul		YPOLDPROC_DOMAIN_NONACK(domainname) = 2;
27914261Swpaul
28014261Swpaul		ypresponse
28114261Swpaul		YPOLDPROC_MATCH(yprequest) = 3;
28214261Swpaul
28314261Swpaul		ypresponse
28414261Swpaul		YPOLDPROC_FIRST(yprequest) = 4;
28514261Swpaul
28614261Swpaul		ypresponse
28714261Swpaul		YPOLDPROC_NEXT(yprequest) = 5;
28814261Swpaul
28914261Swpaul		ypresponse
29014261Swpaul		YPOLDPROC_POLL(yprequest) = 6;
29114261Swpaul
29214261Swpaul		ypresponse
29314261Swpaul		YPOLDPROC_PUSH(yprequest) = 7;
29414261Swpaul
29514261Swpaul		ypresponse
29614261Swpaul		YPOLDPROC_PULL(yprequest) = 8;
29714261Swpaul
29814261Swpaul		ypresponse
29914261Swpaul		YPOLDPROC_GET(yprequest) = 9;
30014261Swpaul	} = 1;
30114261Swpaul
3021832Swollman	version YPVERS {
3031832Swollman		void
3041832Swollman		YPPROC_NULL(void) = 0;
3051832Swollman
3061832Swollman		bool
3071832Swollman		YPPROC_DOMAIN(domainname) = 1;
3081832Swollman
3091832Swollman		bool
3101832Swollman		YPPROC_DOMAIN_NONACK(domainname) = 2;
3111832Swollman
3121832Swollman		ypresp_val
3131832Swollman		YPPROC_MATCH(ypreq_key) = 3;
3141832Swollman
3151832Swollman		ypresp_key_val
31612690Swpaul#ifdef STUPID_SUN_BUG /* should be ypreq_nokey */
3171832Swollman		YPPROC_FIRST(ypreq_key) = 4;
31812690Swpaul#else
31912690Swpaul		YPPROC_FIRST(ypreq_nokey) = 4;
32012690Swpaul#endif
3211832Swollman		ypresp_key_val
3221832Swollman		YPPROC_NEXT(ypreq_key) = 5;
3231832Swollman
3241832Swollman		ypresp_xfr
3251832Swollman		YPPROC_XFR(ypreq_xfr) = 6;
3261832Swollman
3271832Swollman		void
3281832Swollman		YPPROC_CLEAR(void) = 7;
3291832Swollman
3301832Swollman		ypresp_all
3311832Swollman		YPPROC_ALL(ypreq_nokey) = 8;
3321832Swollman
3331832Swollman		ypresp_master
3341832Swollman		YPPROC_MASTER(ypreq_nokey) = 9;
3351832Swollman
3361832Swollman		ypresp_order
3371832Swollman		YPPROC_ORDER(ypreq_nokey) = 10;
3381832Swollman
3391832Swollman		ypresp_maplist
3401832Swollman		YPPROC_MAPLIST(domainname) = 11;
3411832Swollman	} = 2;
3421832Swollman} = 100004;
34312677Swpaul#endif
34412677Swpaul#if !defined(YPSERV_ONLY) && !defined(YPBIND_ONLY)
3451832Swollman/*
3461832Swollman * YPPUSHPROC_XFRRESP is the callback routine for result of YPPROC_XFR
3471832Swollman */
3481832Swollmanprogram YPPUSH_XFRRESPPROG {
3491832Swollman	version YPPUSH_XFRRESPVERS {
3501832Swollman		void
3511832Swollman		YPPUSHPROC_NULL(void) = 0;
35212957Swpaul#ifdef STUPID_SUN_BUG /* argument and return value are backwards */
3531832Swollman		yppushresp_xfr
3541832Swollman		YPPUSHPROC_XFRRESP(void) = 1;
35512957Swpaul#else
35614261Swpaul		void
35712957Swpaul		YPPUSHPROC_XFRRESP(yppushresp_xfr) = 1;
35812957Swpaul#endif
3591832Swollman	} = 1;
3601832Swollman} = 0x40000000;	/* transient: could be anything up to 0x5fffffff */
36112677Swpaul#endif
36212677Swpaul#if !defined(YPSERV_ONLY) && !defined(YPPUSH_ONLY)
3631832Swollman/*
3641832Swollman * YP binding protocol
3651832Swollman */
3661832Swollmanprogram YPBINDPROG {
3671832Swollman	version YPBINDVERS {
3681832Swollman		void
3691832Swollman		YPBINDPROC_NULL(void) = 0;
3701832Swollman
3711832Swollman		ypbind_resp
3721832Swollman		YPBINDPROC_DOMAIN(domainname) = 1;
3731832Swollman
3741832Swollman		void
3751832Swollman		YPBINDPROC_SETDOM(ypbind_setdom) = 2;
3761832Swollman	} = 2;
3771832Swollman} = 100007;
3781832Swollman
37912677Swpaul#endif
380