1 /* $NetBSD: yp_prot.h,v 1.12 1998/07/27 12:21:10 mycroft Exp $ */ 2 3 /* 4 * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca> 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. All advertising materials mentioning features or use of this software 16 * must display the following acknowledgement: 17 * This product includes software developed by Theo de Raadt. 18 * 4. The name of the author may not be used to endorse or promote products 19 * derived from this software without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 22 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 25 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 34 #ifndef _RPCSVC_YP_PROT_H_ 35 #define _RPCSVC_YP_PROT_H_ 36 37 /* 38 * YPSERV PROTOCOL: 39 * 40 * ypserv supports the following procedures: 41 * 42 * YPPROC_NULL takes (void), returns (void). 43 * called to check if server is alive. 44 * YPPROC_DOMAIN takes (char *), returns (bool_t). 45 * true if ypserv serves the named domain. 46 * YPPROC_DOMAIN_NOACK takes (char *), returns (bool_t). 47 * true if ypserv serves the named domain. 48 * used for broadcasts, does not ack if ypserv 49 * doesn't handle named domain. 50 * YPPROC_MATCH takes (struct ypreq_key), returns (struct ypresp_val) 51 * does a lookup. 52 * YPPROC_FIRST takes (struct ypreq_nokey) returns (ypresp_key_val). 53 * gets the first key/datum from the map. 54 * YPPROC_NEXT takes (struct ypreq_key) returns (ypresp_key_val). 55 * gets the next key/datum from the map. 56 * YPPROC_XFR takes (struct ypreq_xfr), returns (void). 57 * tells ypserv to check if there is a new version of 58 * the map. 59 * YPPROC_CLEAR takes (void), returns (void). 60 * tells ypserv to flush it's file cache, so that 61 * newly transferred files will get read. 62 * YPPROC_ALL takes (struct ypreq_nokey), returns (bool_t and 63 * struct ypresp_key_val). 64 * returns an array of data, with the bool_t being 65 * false on the last datum. read the source, it's 66 * convoluted. 67 * YPPROC_MASTER takes (struct ypreq_nokey), returns (ypresp_master). 68 * YPPROC_ORDER takes (struct ypreq_nokey), returns (ypresp_order). 69 * YPPROC_MAPLIST takes (char *), returns (struct ypmaplist *). 70 */ 71 72 #ifndef BOOL_DEFINED 73 typedef u_int bool; 74 #define BOOL_DEFINED 75 #endif 76 77 78 /* Program and version symbols, magic numbers */ 79 #define YPPROG ((unsigned long)100004) 80 #define YPVERS ((unsigned long)2) 81 #define YPVERS_ORIG ((unsigned long)1) 82 83 #define YPMAXRECORD 1024 84 #define YPMAXDOMAIN 64 85 #define YPMAXMAP 64 86 #define YPMAXPEER 256 87 88 /* 89 * I don't know if anything of sun's depends on this, or if they 90 * simply defined it so that their own code wouldn't try to send 91 * packets over the ethernet MTU. This YP code doesn't use it. 92 */ 93 #define YPMSGSZ 1600 94 95 #ifndef DATUM 96 typedef struct { 97 const char *dptr; 98 int dsize; 99 } datum; 100 #define DATUM 101 #endif 102 103 struct ypmap_parms { 104 const char *domain; 105 const char *map; 106 unsigned int ordernum; 107 char *owner; 108 }; 109 110 struct ypreq_key { 111 const char *domain; 112 const char *map; 113 datum keydat; 114 }; 115 116 struct ypreq_nokey { 117 const char *domain; 118 const char *map; 119 }; 120 121 struct ypreq_xfr { 122 struct ypmap_parms map_parms; 123 unsigned int transid; 124 unsigned int proto; 125 unsigned int port; 126 }; 127 #define ypxfr_domain map_parms.domain 128 #define ypxfr_map map_parms.map 129 #define ypxfr_ordernum map_parms.ordernum 130 #define ypxfr_owner map_parms.owner 131 132 struct ypresp_val { 133 unsigned int status; 134 datum valdat; 135 }; 136 137 struct ypresp_key_val { 138 unsigned int status; 139 datum keydat; 140 datum valdat; 141 }; 142 143 struct ypresp_master { 144 unsigned int status; 145 char *master; 146 }; 147 148 struct ypresp_order { 149 unsigned int status; 150 unsigned int ordernum; 151 }; 152 153 struct ypmaplist { 154 char ypml_name[YPMAXMAP + 1]; 155 struct ypmaplist *ypml_next; 156 }; 157 158 struct ypresp_maplist { 159 unsigned int status; 160 struct ypmaplist *list; 161 }; 162 163 /* ypserv procedure numbers */ 164 #define YPPROC_NULL ((unsigned long)0) 165 #define YPPROC_DOMAIN ((unsigned long)1) 166 #define YPPROC_DOMAIN_NONACK ((unsigned long)2) 167 #define YPPROC_MATCH ((unsigned long)3) 168 #define YPPROC_FIRST ((unsigned long)4) 169 #define YPPROC_NEXT ((unsigned long)5) 170 #define YPPROC_XFR ((unsigned long)6) 171 #define YPPROC_CLEAR ((unsigned long)7) 172 #define YPPROC_ALL ((unsigned long)8) 173 #define YPPROC_MASTER ((unsigned long)9) 174 #define YPPROC_ORDER ((unsigned long)10) 175 #define YPPROC_MAPLIST ((unsigned long)11) 176 177 /* ypserv procedure return status values */ 178 #define YP_TRUE ((unsigned int)1) /* general purpose success code */ 179 #define YP_NOMORE ((unsigned int)2) /* no more entries in map */ 180 #define YP_FALSE ((unsigned int)0) /* general purpose failure code */ 181 #define YP_NOMAP ((unsigned int)-1) /* no such map in domain */ 182 #define YP_NODOM ((unsigned int)-2) /* domain not supported */ 183 #define YP_NOKEY ((unsigned int)-3) /* no such key in map */ 184 #define YP_BADOP ((unsigned int)-4) /* invalid operation */ 185 #define YP_BADDB ((unsigned int)-5) /* server data base is bad */ 186 #define YP_YPERR ((unsigned int)-6) /* YP server error */ 187 #define YP_BADARGS ((unsigned int)-7) /* request arguments bad */ 188 #define YP_VERS ((unsigned int)-8) /* YP server version mismatch */ 189 190 /* 191 * Sun's header file says: 192 * "Domain binding data structure, used by ypclnt package and ypserv modules. 193 * Users of the ypclnt package (or of this protocol) don't HAVE to know about 194 * it, but it must be available to users because _yp_dobind is a public 195 * interface." 196 * 197 * This is totally bogus! Nowhere else does Sun state that _yp_dobind() is 198 * a public interface, and I don't know any reason anyone would want to call 199 * it. But, just in case anyone does actually expect it to be available.. 200 * we provide this.. exactly as Sun wants it. 201 */ 202 struct dom_binding { 203 struct dom_binding *dom_pnext; 204 char dom_domain[YPMAXDOMAIN + 1]; 205 struct sockaddr_in dom_server_addr; 206 u_short dom_server_port; 207 int dom_socket; 208 CLIENT *dom_client; 209 u_short dom_local_port; 210 long dom_vers; 211 }; 212 213 /* 214 * YPBIND PROTOCOL: 215 * 216 * ypbind supports the following procedures: 217 * 218 * YPBINDPROC_NULL takes (void), returns (void). 219 * to check if ypbind is running. 220 * YPBINDPROC_DOMAIN takes (char *), returns (struct ypbind_resp). 221 * requests that ypbind start to serve the 222 * named domain (if it doesn't already) 223 * YPBINDPROC_SETDOM takes (struct ypbind_setdom), returns (void). 224 * used by ypset. 225 */ 226 227 #define YPBINDPROG ((unsigned long)100007) 228 #define YPBINDVERS ((unsigned long)2) 229 #define YPBINDVERS_ORIG ((unsigned long)1) 230 231 /* ypbind procedure numbers */ 232 #define YPBINDPROC_NULL ((unsigned long)0) 233 #define YPBINDPROC_DOMAIN ((unsigned long)1) 234 #define YPBINDPROC_SETDOM ((unsigned long)2) 235 236 /* error code in ypbind_resp.ypbind_status */ 237 enum ypbind_resptype { 238 YPBIND_SUCC_VAL = 1, 239 YPBIND_FAIL_VAL = 2 240 }; 241 242 /* network order, of course */ 243 struct ypbind_binding { 244 struct in_addr ypbind_binding_addr; 245 u_int16_t ypbind_binding_port; 246 }; 247 248 struct ypbind_resp { 249 enum ypbind_resptype ypbind_status; 250 union { 251 unsigned int ypbind_error; 252 struct ypbind_binding ypbind_bindinfo; 253 } ypbind_respbody; 254 }; 255 256 /* error code in ypbind_resp.ypbind_respbody.ypbind_error */ 257 #define YPBIND_ERR_ERR 1 /* internal error */ 258 #define YPBIND_ERR_NOSERV 2 /* no bound server for passed domain */ 259 #define YPBIND_ERR_RESC 3 /* system resource allocation failure */ 260 261 /* 262 * Request data structure for ypbind "Set domain" procedure. 263 */ 264 struct ypbind_setdom { 265 char ypsetdom_domain[YPMAXDOMAIN + 1]; 266 struct ypbind_binding ypsetdom_binding; 267 unsigned int ypsetdom_vers; 268 }; 269 #define ypsetdom_addr ypsetdom_binding.ypbind_binding_addr 270 #define ypsetdom_port ypsetdom_binding.ypbind_binding_port 271 272 /* 273 * YPPUSH PROTOCOL: 274 * 275 * Sun says: 276 * "Protocol between clients (ypxfr, only) and yppush 277 * yppush speaks a protocol in the transient range, which 278 * is supplied to ypxfr as a command-line parameter when it 279 * is activated by ypserv." 280 * 281 * This protocol is not implimented, naturally, because this YP 282 * implimentation only does the client side. 283 */ 284 #define YPPUSHVERS ((unsigned long)1) 285 #define YPPUSHVERS_ORIG ((unsigned long)1) 286 287 /* yppush procedure numbers */ 288 #define YPPUSHPROC_NULL ((unsigned long)0) 289 #define YPPUSHPROC_XFRRESP ((unsigned long)1) 290 291 struct yppushresp_xfr { 292 unsigned int transid; 293 unsigned int status; 294 }; 295 296 /* yppush status value in yppushresp_xfr.status */ 297 #define YPPUSH_SUCC ((unsigned int)1) /* Success */ 298 #define YPPUSH_AGE ((unsigned int)2) /* Master's version not newer */ 299 #define YPPUSH_NOMAP ((unsigned int)-1) /* Can't find server for map */ 300 #define YPPUSH_NODOM ((unsigned int)-2) /* Domain not supported */ 301 #define YPPUSH_RSRC ((unsigned int)-3) /* Local resouce alloc failure */ 302 #define YPPUSH_RPC ((unsigned int)-4) /* RPC failure talking to server */ 303 #define YPPUSH_MADDR ((unsigned int)-5) /* Can't get master address */ 304 #define YPPUSH_YPERR ((unsigned int)-6) /* YP server/map db error */ 305 #define YPPUSH_BADARGS ((unsigned int)-7) /* Request arguments bad */ 306 #define YPPUSH_DBM ((unsigned int)-8) /* Local dbm operation failed */ 307 #define YPPUSH_FILE ((unsigned int)-9) /* Local file I/O operation failed */ 308 #define YPPUSH_SKEW ((unsigned int)-10) /* Map version skew during transfer */ 309 #define YPPUSH_CLEAR ((unsigned int)-11) /* Can't send "Clear" req to local ypserv */ 310 #define YPPUSH_FORCE ((unsigned int)-12) /* No local order number in map - use -f */ 311 #define YPPUSH_XFRERR ((unsigned int)-13) /* ypxfr error */ 312 #define YPPUSH_REFUSED ((unsigned int)-14) /* Transfer request refused by ypserv */ 313 314 struct ypall_callback; 315 316 __BEGIN_DECLS 317 bool_t xdr_domainname __P((XDR *, char *)); /* obsolete */ 318 bool_t xdr_peername __P((XDR *, char *)); /* obsolete */ 319 bool_t xdr_mapname __P((XDR *, char *)); /* obsolete */ 320 bool_t xdr_datum __P((XDR *, datum *)); 321 bool_t xdr_ypdomain_wrap_string __P((XDR *, char **)); 322 bool_t xdr_ypmap_wrap_string __P((XDR *, char **)); 323 bool_t xdr_ypreq_key __P((XDR *, struct ypreq_key *)); 324 bool_t xdr_ypreq_nokey __P((XDR *, struct ypreq_nokey *)); 325 bool_t xdr_ypreq_xfr __P((XDR *, struct ypreq_xfr *)); 326 bool_t xdr_ypresp_val __P((XDR *, struct ypresp_val *)); 327 bool_t xdr_ypresp_key_val __P((XDR *, struct ypresp_key_val *)); 328 bool_t xdr_ypmap_parms __P((XDR *, struct ypmap_parms *)); 329 bool_t xdr_ypowner_wrap_string __P((XDR *, char **)); 330 bool_t xdr_yppushresp_xfr __P((XDR *, struct yppushresp_xfr *)); 331 bool_t xdr_ypresp_order __P((XDR *, struct ypresp_order *)); 332 bool_t xdr_ypresp_master __P((XDR *, struct ypresp_master *)); 333 bool_t xdr_ypall __P((XDR *, struct ypall_callback *)); 334 bool_t xdr_ypresp_maplist __P((XDR *, struct ypresp_maplist *)); 335 bool_t xdr_ypbind_resp __P((XDR *, struct ypbind_resp *)); 336 bool_t xdr_ypbind_setdom __P((XDR *, struct ypbind_setdom *)); 337 bool_t xdr_ypmaplist __P((XDR *, struct ypmaplist *)); 338 bool_t xdr_yp_inaddr __P((XDR *, struct in_addr *)); 339 __END_DECLS 340 341 #endif /* _RPCSVC_YP_PROT_H_ */ 342