1 /* $OpenBSD: yp.x,v 1.7 2010/09/01 14:43:34 millert Exp $ */ 2 3 /* 4 * Copyright (c) 2010, Oracle America, Inc. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: 9 * 10 * * Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * * Redistributions in binary form must reproduce the above 13 * copyright notice, this list of conditions and the following 14 * disclaimer in the documentation and/or other materials 15 * provided with the distribution. 16 * * Neither the name of the "Oracle America, Inc." nor the names of its 17 * contributors may be used to endorse or promote products derived 18 * from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 25 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 27 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34 /* 35 * Protocol description file for the Yellow Pages Service 36 */ 37 38 #ifndef RPC_HDR 39 #endif 40 41 const YPMAXRECORD = 1024; 42 const YPMAXDOMAIN = 64; 43 const YPMAXMAP = 64; 44 const YPMAXPEER = 64; 45 46 47 enum ypstat { 48 YP_TRUE = 1, 49 YP_NOMORE = 2, 50 YP_FALSE = 0, 51 YP_NOMAP = -1, 52 YP_NODOM = -2, 53 YP_NOKEY = -3, 54 YP_BADOP = -4, 55 YP_BADDB = -5, 56 YP_YPERR = -6, 57 YP_BADARGS = -7, 58 YP_VERS = -8 59 }; 60 61 62 enum ypxfrstat { 63 YPXFR_SUCC = 1, 64 YPXFR_AGE = 2, 65 YPXFR_NOMAP = -1, 66 YPXFR_NODOM = -2, 67 YPXFR_RSRC = -3, 68 YPXFR_RPC = -4, 69 YPXFR_MADDR = -5, 70 YPXFR_YPERR = -6, 71 YPXFR_BADARGS = -7, 72 YPXFR_DBM = -8, 73 YPXFR_FILE = -9, 74 YPXFR_SKEW = -10, 75 YPXFR_CLEAR = -11, 76 YPXFR_FORCE = -12, 77 YPXFR_XFRERR = -13, 78 YPXFR_REFUSED = -14 79 }; 80 81 82 typedef string domainname<YPMAXDOMAIN>; 83 typedef string mapname<YPMAXMAP>; 84 typedef string peername<YPMAXPEER>; 85 typedef opaque keydat<YPMAXRECORD>; 86 typedef opaque valdat<YPMAXRECORD>; 87 88 89 struct ypmap_parms { 90 domainname domain; 91 mapname map; 92 unsigned int ordernum; 93 peername peer; 94 }; 95 96 struct ypreq_key { 97 domainname domain; 98 mapname map; 99 keydat key; 100 }; 101 102 struct ypreq_nokey { 103 domainname domain; 104 mapname map; 105 }; 106 107 struct ypreq_xfr { 108 ypmap_parms map_parms; 109 unsigned int transid; 110 unsigned int prog; 111 unsigned int port; 112 }; 113 114 115 struct ypresp_val { 116 ypstat stat; 117 valdat val; 118 }; 119 120 struct ypresp_key_val { 121 ypstat stat; 122 #ifdef STUPID_SUN_BUG /* These are backwards */ 123 keydat key; 124 valdat val; 125 #else 126 valdat val; 127 keydat key; 128 #endif 129 }; 130 131 132 struct ypresp_master { 133 ypstat stat; 134 peername peer; 135 }; 136 137 struct ypresp_order { 138 ypstat stat; 139 unsigned int ordernum; 140 }; 141 142 union ypresp_all switch (bool more) { 143 case TRUE: 144 ypresp_key_val val; 145 case FALSE: 146 void; 147 }; 148 149 struct ypresp_xfr { 150 unsigned int transid; 151 ypxfrstat xfrstat; 152 }; 153 154 struct ypmaplist { 155 mapname map; 156 ypmaplist *next; 157 }; 158 159 struct ypresp_maplist { 160 ypstat stat; 161 ypmaplist *maps; 162 }; 163 164 enum yppush_status { 165 YPPUSH_SUCC = 1, /* Success */ 166 YPPUSH_AGE = 2, /* Master's version not newer */ 167 YPPUSH_NOMAP = -1, /* Can't find server for map */ 168 YPPUSH_NODOM = -2, /* Domain not supported */ 169 YPPUSH_RSRC = -3, /* Local resource alloc failure */ 170 YPPUSH_RPC = -4, /* RPC failure talking to server */ 171 YPPUSH_MADDR = -5, /* Can't get master address */ 172 YPPUSH_YPERR = -6, /* YP server/map db error */ 173 YPPUSH_BADARGS = -7, /* Request arguments bad */ 174 YPPUSH_DBM = -8, /* Local dbm operation failed */ 175 YPPUSH_FILE = -9, /* Local file I/O operation failed */ 176 YPPUSH_SKEW = -10, /* Map version skew during transfer */ 177 YPPUSH_CLEAR = -11, /* Can't send "Clear" req to local ypserv */ 178 YPPUSH_FORCE = -12, /* No local order number in map use -f flag. */ 179 YPPUSH_XFRERR = -13, /* ypxfr error */ 180 YPPUSH_REFUSED = -14 /* Transfer request refused by ypserv */ 181 }; 182 183 struct yppushresp_xfr { 184 unsigned transid; 185 yppush_status status; 186 }; 187 188 /* 189 * Response structure and overall result status codes. Success and failure 190 * represent two separate response message types. 191 */ 192 193 enum ypbind_resptype { 194 YPBIND_SUCC_VAL = 1, 195 YPBIND_FAIL_VAL = 2 196 }; 197 198 struct ypbind_binding { 199 opaque ypbind_binding_addr[4]; /* In network order */ 200 opaque ypbind_binding_port[2]; /* In network order */ 201 }; 202 203 union ypbind_resp switch (ypbind_resptype ypbind_status) { 204 case YPBIND_FAIL_VAL: 205 unsigned ypbind_error; 206 case YPBIND_SUCC_VAL: 207 ypbind_binding ypbind_bindinfo; 208 }; 209 210 /* Detailed failure reason codes for response field ypbind_error*/ 211 212 const YPBIND_ERR_ERR = 1; /* Internal error */ 213 const YPBIND_ERR_NOSERV = 2; /* No bound server for passed domain */ 214 const YPBIND_ERR_RESC = 3; /* System resource allocation failure */ 215 216 217 /* 218 * Request data structure for ypbind "Set domain" procedure. 219 */ 220 struct ypbind_setdom { 221 domainname ypsetdom_domain; 222 ypbind_binding ypsetdom_binding; 223 unsigned ypsetdom_vers; 224 }; 225 226 227 /* 228 * YP access protocol 229 */ 230 program YPPROG { 231 version YPVERS { 232 void 233 YPPROC_NULL(void) = 0; 234 235 bool 236 YPPROC_DOMAIN(domainname) = 1; 237 238 bool 239 YPPROC_DOMAIN_NONACK(domainname) = 2; 240 241 ypresp_val 242 YPPROC_MATCH(ypreq_key) = 3; 243 244 ypresp_key_val 245 #ifdef STUPID_SUN_BUG /* should be ypreq_nokey */ 246 YPPROC_FIRST(ypreq_key) = 4; 247 #else 248 YPPROC_FIRST(ypreq_nokey) = 4; 249 #endif 250 251 ypresp_key_val 252 YPPROC_NEXT(ypreq_key) = 5; 253 254 ypresp_xfr 255 YPPROC_XFR(ypreq_xfr) = 6; 256 257 void 258 YPPROC_CLEAR(void) = 7; 259 260 ypresp_all 261 YPPROC_ALL(ypreq_nokey) = 8; 262 263 ypresp_master 264 YPPROC_MASTER(ypreq_nokey) = 9; 265 266 ypresp_order 267 YPPROC_ORDER(ypreq_nokey) = 10; 268 269 ypresp_maplist 270 YPPROC_MAPLIST(domainname) = 11; 271 } = 2; 272 } = 100004; 273 274 275 %bool_t xdr_ypresp_all_seq(XDR *, u_long *); 276 277 /* 278 * YPPUSHPROC_XFRRESP is the callback routine for result of YPPROC_XFR 279 */ 280 program YPPUSH_XFRRESPPROG { 281 version YPPUSH_XFRRESPVERS { 282 void 283 YPPUSHPROC_NULL(void) = 0; 284 285 yppushresp_xfr 286 YPPUSHPROC_XFRRESP(void) = 1; 287 } = 1; 288 } = 0x40000000; /* transient: could be anything up to 0x5fffffff */ 289 290 291 /* 292 * YP binding protocol 293 */ 294 program YPBINDPROG { 295 version YPBINDVERS { 296 void 297 YPBINDPROC_NULL(void) = 0; 298 299 ypbind_resp 300 YPBINDPROC_DOMAIN(domainname) = 1; 301 302 void 303 YPBINDPROC_SETDOM(ypbind_setdom) = 2; 304 } = 2; 305 } = 100007; 306 307 308