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