yp.x revision 1.6
1/* $OpenBSD: yp.x,v 1.6 2009/10/27 23:59:30 deraadt Exp $ */ 2 3/* 4 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 5 * unrestricted use provided that this legend is included on all tape 6 * media and as a part of the software program in whole or part. Users 7 * may copy or modify Sun RPC without charge, but are not authorized 8 * to license or distribute it to anyone else except as part of a product or 9 * program developed by the user. 10 * 11 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE 12 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR 13 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. 14 * 15 * Sun RPC is provided with no support and without any obligation on the 16 * part of Sun Microsystems, Inc. to assist in its use, correction, 17 * modification or enhancement. 18 * 19 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE 20 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC 21 * OR ANY PART THEREOF. 22 * 23 * In no event will Sun Microsystems, Inc. be liable for any lost revenue 24 * or profits or other special, indirect and consequential damages, even if 25 * Sun has been advised of the possibility of such damages. 26 * 27 * Sun Microsystems, Inc. 28 * 2550 Garcia Avenue 29 * Mountain View, California 94043 30 */ 31 32/* 33 * Protocol description file for the Yellow Pages Service 34 */ 35 36#ifndef RPC_HDR 37#endif 38 39const YPMAXRECORD = 1024; 40const YPMAXDOMAIN = 64; 41const YPMAXMAP = 64; 42const YPMAXPEER = 64; 43 44 45enum ypstat { 46 YP_TRUE = 1, 47 YP_NOMORE = 2, 48 YP_FALSE = 0, 49 YP_NOMAP = -1, 50 YP_NODOM = -2, 51 YP_NOKEY = -3, 52 YP_BADOP = -4, 53 YP_BADDB = -5, 54 YP_YPERR = -6, 55 YP_BADARGS = -7, 56 YP_VERS = -8 57}; 58 59 60enum ypxfrstat { 61 YPXFR_SUCC = 1, 62 YPXFR_AGE = 2, 63 YPXFR_NOMAP = -1, 64 YPXFR_NODOM = -2, 65 YPXFR_RSRC = -3, 66 YPXFR_RPC = -4, 67 YPXFR_MADDR = -5, 68 YPXFR_YPERR = -6, 69 YPXFR_BADARGS = -7, 70 YPXFR_DBM = -8, 71 YPXFR_FILE = -9, 72 YPXFR_SKEW = -10, 73 YPXFR_CLEAR = -11, 74 YPXFR_FORCE = -12, 75 YPXFR_XFRERR = -13, 76 YPXFR_REFUSED = -14 77}; 78 79 80typedef string domainname<YPMAXDOMAIN>; 81typedef string mapname<YPMAXMAP>; 82typedef string peername<YPMAXPEER>; 83typedef opaque keydat<YPMAXRECORD>; 84typedef opaque valdat<YPMAXRECORD>; 85 86 87struct ypmap_parms { 88 domainname domain; 89 mapname map; 90 unsigned int ordernum; 91 peername peer; 92}; 93 94struct ypreq_key { 95 domainname domain; 96 mapname map; 97 keydat key; 98}; 99 100struct ypreq_nokey { 101 domainname domain; 102 mapname map; 103}; 104 105struct ypreq_xfr { 106 ypmap_parms map_parms; 107 unsigned int transid; 108 unsigned int prog; 109 unsigned int port; 110}; 111 112 113struct ypresp_val { 114 ypstat stat; 115 valdat val; 116}; 117 118struct ypresp_key_val { 119 ypstat stat; 120#ifdef STUPID_SUN_BUG /* These are backwards */ 121 keydat key; 122 valdat val; 123#else 124 valdat val; 125 keydat key; 126#endif 127}; 128 129 130struct ypresp_master { 131 ypstat stat; 132 peername peer; 133}; 134 135struct ypresp_order { 136 ypstat stat; 137 unsigned int ordernum; 138}; 139 140union ypresp_all switch (bool more) { 141case TRUE: 142 ypresp_key_val val; 143case FALSE: 144 void; 145}; 146 147struct ypresp_xfr { 148 unsigned int transid; 149 ypxfrstat xfrstat; 150}; 151 152struct ypmaplist { 153 mapname map; 154 ypmaplist *next; 155}; 156 157struct ypresp_maplist { 158 ypstat stat; 159 ypmaplist *maps; 160}; 161 162enum yppush_status { 163 YPPUSH_SUCC = 1, /* Success */ 164 YPPUSH_AGE = 2, /* Master's version not newer */ 165 YPPUSH_NOMAP = -1, /* Can't find server for map */ 166 YPPUSH_NODOM = -2, /* Domain not supported */ 167 YPPUSH_RSRC = -3, /* Local resource alloc failure */ 168 YPPUSH_RPC = -4, /* RPC failure talking to server */ 169 YPPUSH_MADDR = -5, /* Can't get master address */ 170 YPPUSH_YPERR = -6, /* YP server/map db error */ 171 YPPUSH_BADARGS = -7, /* Request arguments bad */ 172 YPPUSH_DBM = -8, /* Local dbm operation failed */ 173 YPPUSH_FILE = -9, /* Local file I/O operation failed */ 174 YPPUSH_SKEW = -10, /* Map version skew during transfer */ 175 YPPUSH_CLEAR = -11, /* Can't send "Clear" req to local ypserv */ 176 YPPUSH_FORCE = -12, /* No local order number in map use -f flag. */ 177 YPPUSH_XFRERR = -13, /* ypxfr error */ 178 YPPUSH_REFUSED = -14 /* Transfer request refused by ypserv */ 179}; 180 181struct yppushresp_xfr { 182 unsigned transid; 183 yppush_status status; 184}; 185 186/* 187 * Response structure and overall result status codes. Success and failure 188 * represent two separate response message types. 189 */ 190 191enum ypbind_resptype { 192 YPBIND_SUCC_VAL = 1, 193 YPBIND_FAIL_VAL = 2 194}; 195 196struct ypbind_binding { 197 opaque ypbind_binding_addr[4]; /* In network order */ 198 opaque ypbind_binding_port[2]; /* In network order */ 199}; 200 201union ypbind_resp switch (ypbind_resptype ypbind_status) { 202case YPBIND_FAIL_VAL: 203 unsigned ypbind_error; 204case YPBIND_SUCC_VAL: 205 ypbind_binding ypbind_bindinfo; 206}; 207 208/* Detailed failure reason codes for response field ypbind_error*/ 209 210const YPBIND_ERR_ERR = 1; /* Internal error */ 211const YPBIND_ERR_NOSERV = 2; /* No bound server for passed domain */ 212const YPBIND_ERR_RESC = 3; /* System resource allocation failure */ 213 214 215/* 216 * Request data structure for ypbind "Set domain" procedure. 217 */ 218struct ypbind_setdom { 219 domainname ypsetdom_domain; 220 ypbind_binding ypsetdom_binding; 221 unsigned ypsetdom_vers; 222}; 223 224 225/* 226 * YP access protocol 227 */ 228program YPPROG { 229 version YPVERS { 230 void 231 YPPROC_NULL(void) = 0; 232 233 bool 234 YPPROC_DOMAIN(domainname) = 1; 235 236 bool 237 YPPROC_DOMAIN_NONACK(domainname) = 2; 238 239 ypresp_val 240 YPPROC_MATCH(ypreq_key) = 3; 241 242 ypresp_key_val 243#ifdef STUPID_SUN_BUG /* should be ypreq_nokey */ 244 YPPROC_FIRST(ypreq_key) = 4; 245#else 246 YPPROC_FIRST(ypreq_nokey) = 4; 247#endif 248 249 ypresp_key_val 250 YPPROC_NEXT(ypreq_key) = 5; 251 252 ypresp_xfr 253 YPPROC_XFR(ypreq_xfr) = 6; 254 255 void 256 YPPROC_CLEAR(void) = 7; 257 258 ypresp_all 259 YPPROC_ALL(ypreq_nokey) = 8; 260 261 ypresp_master 262 YPPROC_MASTER(ypreq_nokey) = 9; 263 264 ypresp_order 265 YPPROC_ORDER(ypreq_nokey) = 10; 266 267 ypresp_maplist 268 YPPROC_MAPLIST(domainname) = 11; 269 } = 2; 270} = 100004; 271 272 273%bool_t xdr_ypresp_all_seq(XDR *, u_long *); 274 275/* 276 * YPPUSHPROC_XFRRESP is the callback routine for result of YPPROC_XFR 277 */ 278program YPPUSH_XFRRESPPROG { 279 version YPPUSH_XFRRESPVERS { 280 void 281 YPPUSHPROC_NULL(void) = 0; 282 283 yppushresp_xfr 284 YPPUSHPROC_XFRRESP(void) = 1; 285 } = 1; 286} = 0x40000000; /* transient: could be anything up to 0x5fffffff */ 287 288 289/* 290 * YP binding protocol 291 */ 292program YPBINDPROG { 293 version YPBINDVERS { 294 void 295 YPBINDPROC_NULL(void) = 0; 296 297 ypbind_resp 298 YPBINDPROC_DOMAIN(domainname) = 1; 299 300 void 301 YPBINDPROC_SETDOM(ypbind_setdom) = 2; 302 } = 2; 303} = 100007; 304 305 306