18785398fSHiroki Sato /*- 28785398fSHiroki Sato * Copyright (c) 2010, Oracle America, Inc. 375b63130SGarrett Wollman * 48785398fSHiroki Sato * Redistribution and use in source and binary forms, with or without 58785398fSHiroki Sato * modification, are permitted provided that the following conditions are 68785398fSHiroki Sato * met: 775b63130SGarrett Wollman * 88785398fSHiroki Sato * * Redistributions of source code must retain the above copyright 98785398fSHiroki Sato * notice, this list of conditions and the following disclaimer. 108785398fSHiroki Sato * * Redistributions in binary form must reproduce the above 118785398fSHiroki Sato * copyright notice, this list of conditions and the following 128785398fSHiroki Sato * disclaimer in the documentation and/or other materials 138785398fSHiroki Sato * provided with the distribution. 148785398fSHiroki Sato * * Neither the name of the "Oracle America, Inc." nor the names of its 158785398fSHiroki Sato * contributors may be used to endorse or promote products derived 168785398fSHiroki Sato * from this software without specific prior written permission. 1775b63130SGarrett Wollman * 188785398fSHiroki Sato * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 198785398fSHiroki Sato * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 208785398fSHiroki Sato * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 218785398fSHiroki Sato * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 228785398fSHiroki Sato * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 238785398fSHiroki Sato * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 248785398fSHiroki Sato * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 258785398fSHiroki Sato * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 268785398fSHiroki Sato * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 278785398fSHiroki Sato * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 288785398fSHiroki Sato * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 298785398fSHiroki Sato * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3075b63130SGarrett Wollman */ 3175b63130SGarrett Wollman 3275b63130SGarrett Wollman /* 3375b63130SGarrett Wollman * Protocol description file for the Yellow Pages Service 3475b63130SGarrett Wollman */ 3575b63130SGarrett Wollman 36*6b462d27SKonstantin Belousov const YPMAXRECORD = 16777216; 3775b63130SGarrett Wollman const YPMAXDOMAIN = 64; 3875b63130SGarrett Wollman const YPMAXMAP = 64; 3975b63130SGarrett Wollman const YPMAXPEER = 64; 4075b63130SGarrett Wollman 4175b63130SGarrett Wollman 4275b63130SGarrett Wollman enum ypstat { 4375b63130SGarrett Wollman YP_TRUE = 1, 4475b63130SGarrett Wollman YP_NOMORE = 2, 4575b63130SGarrett Wollman YP_FALSE = 0, 4675b63130SGarrett Wollman YP_NOMAP = -1, 4775b63130SGarrett Wollman YP_NODOM = -2, 4875b63130SGarrett Wollman YP_NOKEY = -3, 4975b63130SGarrett Wollman YP_BADOP = -4, 5075b63130SGarrett Wollman YP_BADDB = -5, 5175b63130SGarrett Wollman YP_YPERR = -6, 5275b63130SGarrett Wollman YP_BADARGS = -7, 5375b63130SGarrett Wollman YP_VERS = -8 5475b63130SGarrett Wollman }; 5575b63130SGarrett Wollman 5675b63130SGarrett Wollman 5775b63130SGarrett Wollman enum ypxfrstat { 5875b63130SGarrett Wollman YPXFR_SUCC = 1, 5975b63130SGarrett Wollman YPXFR_AGE = 2, 6075b63130SGarrett Wollman YPXFR_NOMAP = -1, 6175b63130SGarrett Wollman YPXFR_NODOM = -2, 6275b63130SGarrett Wollman YPXFR_RSRC = -3, 6375b63130SGarrett Wollman YPXFR_RPC = -4, 6475b63130SGarrett Wollman YPXFR_MADDR = -5, 6575b63130SGarrett Wollman YPXFR_YPERR = -6, 6675b63130SGarrett Wollman YPXFR_BADARGS = -7, 6775b63130SGarrett Wollman YPXFR_DBM = -8, 6875b63130SGarrett Wollman YPXFR_FILE = -9, 6975b63130SGarrett Wollman YPXFR_SKEW = -10, 7075b63130SGarrett Wollman YPXFR_CLEAR = -11, 7175b63130SGarrett Wollman YPXFR_FORCE = -12, 7275b63130SGarrett Wollman YPXFR_XFRERR = -13, 7375b63130SGarrett Wollman YPXFR_REFUSED = -14 7475b63130SGarrett Wollman }; 7575b63130SGarrett Wollman 7675b63130SGarrett Wollman 7775b63130SGarrett Wollman typedef string domainname<YPMAXDOMAIN>; 7875b63130SGarrett Wollman typedef string mapname<YPMAXMAP>; 7975b63130SGarrett Wollman typedef string peername<YPMAXPEER>; 8075b63130SGarrett Wollman typedef opaque keydat<YPMAXRECORD>; 8175b63130SGarrett Wollman typedef opaque valdat<YPMAXRECORD>; 8275b63130SGarrett Wollman 8375b63130SGarrett Wollman 8475b63130SGarrett Wollman struct ypmap_parms { 8575b63130SGarrett Wollman domainname domain; 8675b63130SGarrett Wollman mapname map; 8775b63130SGarrett Wollman unsigned int ordernum; 8875b63130SGarrett Wollman peername peer; 8975b63130SGarrett Wollman }; 9075b63130SGarrett Wollman 9175b63130SGarrett Wollman struct ypreq_key { 9275b63130SGarrett Wollman domainname domain; 9375b63130SGarrett Wollman mapname map; 9475b63130SGarrett Wollman keydat key; 9575b63130SGarrett Wollman }; 9675b63130SGarrett Wollman 9775b63130SGarrett Wollman struct ypreq_nokey { 9875b63130SGarrett Wollman domainname domain; 9975b63130SGarrett Wollman mapname map; 10075b63130SGarrett Wollman }; 10175b63130SGarrett Wollman 10275b63130SGarrett Wollman struct ypreq_xfr { 10375b63130SGarrett Wollman ypmap_parms map_parms; 10475b63130SGarrett Wollman unsigned int transid; 10575b63130SGarrett Wollman unsigned int prog; 10675b63130SGarrett Wollman unsigned int port; 10775b63130SGarrett Wollman }; 10875b63130SGarrett Wollman 10975b63130SGarrett Wollman 11075b63130SGarrett Wollman struct ypresp_val { 11175b63130SGarrett Wollman ypstat stat; 11275b63130SGarrett Wollman valdat val; 11375b63130SGarrett Wollman }; 11475b63130SGarrett Wollman 11575b63130SGarrett Wollman struct ypresp_key_val { 11675b63130SGarrett Wollman ypstat stat; 11704228afaSBill Paul #ifdef STUPID_SUN_BUG /* These are backwards */ 11875b63130SGarrett Wollman keydat key; 11975b63130SGarrett Wollman valdat val; 12004228afaSBill Paul #else 12104228afaSBill Paul valdat val; 12204228afaSBill Paul keydat key; 12304228afaSBill Paul #endif 12475b63130SGarrett Wollman }; 12575b63130SGarrett Wollman 12675b63130SGarrett Wollman 12775b63130SGarrett Wollman struct ypresp_master { 12875b63130SGarrett Wollman ypstat stat; 12975b63130SGarrett Wollman peername peer; 13075b63130SGarrett Wollman }; 13175b63130SGarrett Wollman 13275b63130SGarrett Wollman struct ypresp_order { 13375b63130SGarrett Wollman ypstat stat; 13475b63130SGarrett Wollman unsigned int ordernum; 13575b63130SGarrett Wollman }; 13675b63130SGarrett Wollman 13775b63130SGarrett Wollman union ypresp_all switch (bool more) { 13875b63130SGarrett Wollman case TRUE: 13975b63130SGarrett Wollman ypresp_key_val val; 14075b63130SGarrett Wollman case FALSE: 14175b63130SGarrett Wollman void; 14275b63130SGarrett Wollman }; 14375b63130SGarrett Wollman 14475b63130SGarrett Wollman struct ypresp_xfr { 14575b63130SGarrett Wollman unsigned int transid; 14675b63130SGarrett Wollman ypxfrstat xfrstat; 14775b63130SGarrett Wollman }; 14875b63130SGarrett Wollman 14975b63130SGarrett Wollman struct ypmaplist { 15075b63130SGarrett Wollman mapname map; 15175b63130SGarrett Wollman ypmaplist *next; 15275b63130SGarrett Wollman }; 15375b63130SGarrett Wollman 15475b63130SGarrett Wollman struct ypresp_maplist { 15575b63130SGarrett Wollman ypstat stat; 15675b63130SGarrett Wollman ypmaplist *maps; 15775b63130SGarrett Wollman }; 15875b63130SGarrett Wollman 15975b63130SGarrett Wollman enum yppush_status { 16075b63130SGarrett Wollman YPPUSH_SUCC = 1, /* Success */ 16175b63130SGarrett Wollman YPPUSH_AGE = 2, /* Master's version not newer */ 16275b63130SGarrett Wollman YPPUSH_NOMAP = -1, /* Can't find server for map */ 16375b63130SGarrett Wollman YPPUSH_NODOM = -2, /* Domain not supported */ 16475b63130SGarrett Wollman YPPUSH_RSRC = -3, /* Local resource alloc failure */ 16575b63130SGarrett Wollman YPPUSH_RPC = -4, /* RPC failure talking to server */ 16675b63130SGarrett Wollman YPPUSH_MADDR = -5, /* Can't get master address */ 16775b63130SGarrett Wollman YPPUSH_YPERR = -6, /* YP server/map db error */ 16875b63130SGarrett Wollman YPPUSH_BADARGS = -7, /* Request arguments bad */ 16975b63130SGarrett Wollman YPPUSH_DBM = -8, /* Local dbm operation failed */ 17075b63130SGarrett Wollman YPPUSH_FILE = -9, /* Local file I/O operation failed */ 17175b63130SGarrett Wollman YPPUSH_SKEW = -10, /* Map version skew during transfer */ 17275b63130SGarrett Wollman YPPUSH_CLEAR = -11, /* Can't send "Clear" req to local ypserv */ 17375b63130SGarrett Wollman YPPUSH_FORCE = -12, /* No local order number in map use -f flag. */ 17475b63130SGarrett Wollman YPPUSH_XFRERR = -13, /* ypxfr error */ 17575b63130SGarrett Wollman YPPUSH_REFUSED = -14 /* Transfer request refused by ypserv */ 17675b63130SGarrett Wollman }; 17775b63130SGarrett Wollman 17875b63130SGarrett Wollman struct yppushresp_xfr { 17975b63130SGarrett Wollman unsigned transid; 18075b63130SGarrett Wollman yppush_status status; 18175b63130SGarrett Wollman }; 18275b63130SGarrett Wollman 18375b63130SGarrett Wollman /* 18475b63130SGarrett Wollman * Response structure and overall result status codes. Success and failure 18575b63130SGarrett Wollman * represent two separate response message types. 18675b63130SGarrett Wollman */ 18775b63130SGarrett Wollman 18875b63130SGarrett Wollman enum ypbind_resptype { 18975b63130SGarrett Wollman YPBIND_SUCC_VAL = 1, 19075b63130SGarrett Wollman YPBIND_FAIL_VAL = 2 19175b63130SGarrett Wollman }; 19275b63130SGarrett Wollman 19375b63130SGarrett Wollman struct ypbind_binding { 19475b63130SGarrett Wollman opaque ypbind_binding_addr[4]; /* In network order */ 19575b63130SGarrett Wollman opaque ypbind_binding_port[2]; /* In network order */ 19675b63130SGarrett Wollman }; 19775b63130SGarrett Wollman 19875b63130SGarrett Wollman union ypbind_resp switch (ypbind_resptype ypbind_status) { 19975b63130SGarrett Wollman case YPBIND_FAIL_VAL: 20075b63130SGarrett Wollman unsigned ypbind_error; 20175b63130SGarrett Wollman case YPBIND_SUCC_VAL: 20275b63130SGarrett Wollman ypbind_binding ypbind_bindinfo; 20375b63130SGarrett Wollman }; 20475b63130SGarrett Wollman 20575b63130SGarrett Wollman /* Detailed failure reason codes for response field ypbind_error*/ 20675b63130SGarrett Wollman 20775b63130SGarrett Wollman const YPBIND_ERR_ERR = 1; /* Internal error */ 20875b63130SGarrett Wollman const YPBIND_ERR_NOSERV = 2; /* No bound server for passed domain */ 20975b63130SGarrett Wollman const YPBIND_ERR_RESC = 3; /* System resource allocation failure */ 21075b63130SGarrett Wollman 21175b63130SGarrett Wollman 21275b63130SGarrett Wollman /* 21375b63130SGarrett Wollman * Request data structure for ypbind "Set domain" procedure. 21475b63130SGarrett Wollman */ 21575b63130SGarrett Wollman struct ypbind_setdom { 21675b63130SGarrett Wollman domainname ypsetdom_domain; 21775b63130SGarrett Wollman ypbind_binding ypsetdom_binding; 21875b63130SGarrett Wollman unsigned ypsetdom_vers; 21975b63130SGarrett Wollman }; 22075b63130SGarrett Wollman 2212a781cb8SBill Paul 2222a781cb8SBill Paul /* 2232a781cb8SBill Paul * NIS v1 support for backwards compatibility 2242a781cb8SBill Paul */ 2252a781cb8SBill Paul enum ypreqtype { 2262a781cb8SBill Paul YPREQ_KEY = 1, 2272a781cb8SBill Paul YPREQ_NOKEY = 2, 2282a781cb8SBill Paul YPREQ_MAP_PARMS = 3 2292a781cb8SBill Paul }; 2302a781cb8SBill Paul 2312a781cb8SBill Paul enum ypresptype { 2322a781cb8SBill Paul YPRESP_VAL = 1, 2332a781cb8SBill Paul YPRESP_KEY_VAL = 2, 2342a781cb8SBill Paul YPRESP_MAP_PARMS = 3 2352a781cb8SBill Paul }; 2362a781cb8SBill Paul 2372a781cb8SBill Paul union yprequest switch (ypreqtype yp_reqtype) { 2382a781cb8SBill Paul case YPREQ_KEY: 2392a781cb8SBill Paul ypreq_key yp_req_keytype; 2402a781cb8SBill Paul case YPREQ_NOKEY: 2412a781cb8SBill Paul ypreq_nokey yp_req_nokeytype; 2422a781cb8SBill Paul case YPREQ_MAP_PARMS: 2432a781cb8SBill Paul ypmap_parms yp_req_map_parmstype; 2442a781cb8SBill Paul }; 2452a781cb8SBill Paul 2462a781cb8SBill Paul union ypresponse switch (ypresptype yp_resptype) { 2472a781cb8SBill Paul case YPRESP_VAL: 2482a781cb8SBill Paul ypresp_val yp_resp_valtype; 2492a781cb8SBill Paul case YPRESP_KEY_VAL: 2502a781cb8SBill Paul ypresp_key_val yp_resp_key_valtype; 2512a781cb8SBill Paul case YPRESP_MAP_PARMS: 2522a781cb8SBill Paul ypmap_parms yp_resp_map_parmstype; 2532a781cb8SBill Paul }; 2542a781cb8SBill Paul 25504228afaSBill Paul #if !defined(YPBIND_ONLY) && !defined(YPPUSH_ONLY) 25675b63130SGarrett Wollman /* 25775b63130SGarrett Wollman * YP access protocol 25875b63130SGarrett Wollman */ 25975b63130SGarrett Wollman program YPPROG { 2602a781cb8SBill Paul /* 2612a781cb8SBill Paul * NIS v1 support for backwards compatibility 2622a781cb8SBill Paul */ 2632a781cb8SBill Paul version YPOLDVERS { 2642a781cb8SBill Paul void 2652a781cb8SBill Paul YPOLDPROC_NULL(void) = 0; 2662a781cb8SBill Paul 2672a781cb8SBill Paul bool 2682a781cb8SBill Paul YPOLDPROC_DOMAIN(domainname) = 1; 2692a781cb8SBill Paul 2702a781cb8SBill Paul bool 2712a781cb8SBill Paul YPOLDPROC_DOMAIN_NONACK(domainname) = 2; 2722a781cb8SBill Paul 2732a781cb8SBill Paul ypresponse 2742a781cb8SBill Paul YPOLDPROC_MATCH(yprequest) = 3; 2752a781cb8SBill Paul 2762a781cb8SBill Paul ypresponse 2772a781cb8SBill Paul YPOLDPROC_FIRST(yprequest) = 4; 2782a781cb8SBill Paul 2792a781cb8SBill Paul ypresponse 2802a781cb8SBill Paul YPOLDPROC_NEXT(yprequest) = 5; 2812a781cb8SBill Paul 2822a781cb8SBill Paul ypresponse 2832a781cb8SBill Paul YPOLDPROC_POLL(yprequest) = 6; 2842a781cb8SBill Paul 2852a781cb8SBill Paul ypresponse 2862a781cb8SBill Paul YPOLDPROC_PUSH(yprequest) = 7; 2872a781cb8SBill Paul 2882a781cb8SBill Paul ypresponse 2892a781cb8SBill Paul YPOLDPROC_PULL(yprequest) = 8; 2902a781cb8SBill Paul 2912a781cb8SBill Paul ypresponse 2922a781cb8SBill Paul YPOLDPROC_GET(yprequest) = 9; 2932a781cb8SBill Paul } = 1; 2942a781cb8SBill Paul 29575b63130SGarrett Wollman version YPVERS { 29675b63130SGarrett Wollman void 29775b63130SGarrett Wollman YPPROC_NULL(void) = 0; 29875b63130SGarrett Wollman 29975b63130SGarrett Wollman bool 30075b63130SGarrett Wollman YPPROC_DOMAIN(domainname) = 1; 30175b63130SGarrett Wollman 30275b63130SGarrett Wollman bool 30375b63130SGarrett Wollman YPPROC_DOMAIN_NONACK(domainname) = 2; 30475b63130SGarrett Wollman 30575b63130SGarrett Wollman ypresp_val 30675b63130SGarrett Wollman YPPROC_MATCH(ypreq_key) = 3; 30775b63130SGarrett Wollman 30875b63130SGarrett Wollman ypresp_key_val 309d8880047SBill Paul #ifdef STUPID_SUN_BUG /* should be ypreq_nokey */ 31075b63130SGarrett Wollman YPPROC_FIRST(ypreq_key) = 4; 311d8880047SBill Paul #else 312d8880047SBill Paul YPPROC_FIRST(ypreq_nokey) = 4; 313d8880047SBill Paul #endif 31475b63130SGarrett Wollman ypresp_key_val 31575b63130SGarrett Wollman YPPROC_NEXT(ypreq_key) = 5; 31675b63130SGarrett Wollman 31775b63130SGarrett Wollman ypresp_xfr 31875b63130SGarrett Wollman YPPROC_XFR(ypreq_xfr) = 6; 31975b63130SGarrett Wollman 32075b63130SGarrett Wollman void 32175b63130SGarrett Wollman YPPROC_CLEAR(void) = 7; 32275b63130SGarrett Wollman 32375b63130SGarrett Wollman ypresp_all 32475b63130SGarrett Wollman YPPROC_ALL(ypreq_nokey) = 8; 32575b63130SGarrett Wollman 32675b63130SGarrett Wollman ypresp_master 32775b63130SGarrett Wollman YPPROC_MASTER(ypreq_nokey) = 9; 32875b63130SGarrett Wollman 32975b63130SGarrett Wollman ypresp_order 33075b63130SGarrett Wollman YPPROC_ORDER(ypreq_nokey) = 10; 33175b63130SGarrett Wollman 33275b63130SGarrett Wollman ypresp_maplist 33375b63130SGarrett Wollman YPPROC_MAPLIST(domainname) = 11; 33475b63130SGarrett Wollman } = 2; 33575b63130SGarrett Wollman } = 100004; 33604228afaSBill Paul #endif 33704228afaSBill Paul #if !defined(YPSERV_ONLY) && !defined(YPBIND_ONLY) 33875b63130SGarrett Wollman /* 33975b63130SGarrett Wollman * YPPUSHPROC_XFRRESP is the callback routine for result of YPPROC_XFR 34075b63130SGarrett Wollman */ 34175b63130SGarrett Wollman program YPPUSH_XFRRESPPROG { 34275b63130SGarrett Wollman version YPPUSH_XFRRESPVERS { 34375b63130SGarrett Wollman void 34475b63130SGarrett Wollman YPPUSHPROC_NULL(void) = 0; 345898daf2bSBill Paul #ifdef STUPID_SUN_BUG /* argument and return value are backwards */ 34675b63130SGarrett Wollman yppushresp_xfr 34775b63130SGarrett Wollman YPPUSHPROC_XFRRESP(void) = 1; 348898daf2bSBill Paul #else 349898daf2bSBill Paul void 350898daf2bSBill Paul YPPUSHPROC_XFRRESP(yppushresp_xfr) = 1; 351898daf2bSBill Paul #endif 35275b63130SGarrett Wollman } = 1; 35375b63130SGarrett Wollman } = 0x40000000; /* transient: could be anything up to 0x5fffffff */ 35404228afaSBill Paul #endif 35504228afaSBill Paul #if !defined(YPSERV_ONLY) && !defined(YPPUSH_ONLY) 35675b63130SGarrett Wollman /* 35775b63130SGarrett Wollman * YP binding protocol 35875b63130SGarrett Wollman */ 35975b63130SGarrett Wollman program YPBINDPROG { 36075b63130SGarrett Wollman version YPBINDVERS { 36175b63130SGarrett Wollman void 36275b63130SGarrett Wollman YPBINDPROC_NULL(void) = 0; 36375b63130SGarrett Wollman 36475b63130SGarrett Wollman ypbind_resp 36575b63130SGarrett Wollman YPBINDPROC_DOMAIN(domainname) = 1; 36675b63130SGarrett Wollman 36775b63130SGarrett Wollman void 36875b63130SGarrett Wollman YPBINDPROC_SETDOM(ypbind_setdom) = 2; 36975b63130SGarrett Wollman } = 2; 37075b63130SGarrett Wollman } = 100007; 37175b63130SGarrett Wollman 37204228afaSBill Paul #endif 373