yp_prot.h revision 50473
1293873Ssephe/* 2293873Ssephe * Copyright (c) 1992/3 Theo de Raadt <deraadt@fsa.ca> 3293873Ssephe * All rights reserved. 4293873Ssephe * 5293873Ssephe * Redistribution and use in source and binary forms, with or without 6293873Ssephe * modification, are permitted provided that the following conditions 7293873Ssephe * are met: 8293873Ssephe * 1. Redistributions of source code must retain the above copyright 9293873Ssephe * notice, this list of conditions and the following disclaimer. 10293873Ssephe * 2. Redistributions in binary form must reproduce the above copyright 11293873Ssephe * notice, this list of conditions and the following disclaimer in the 12293873Ssephe * documentation and/or other materials provided with the distribution. 13293873Ssephe * 3. The name of the author may not be used to endorse or promote 14293873Ssephe * products derived from this software without specific prior written 15293873Ssephe * permission. 16293873Ssephe * 17293873Ssephe * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 18293873Ssephe * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19293873Ssephe * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20293873Ssephe * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 21293873Ssephe * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22293873Ssephe * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23293873Ssephe * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24293873Ssephe * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25293873Ssephe * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26293873Ssephe * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27293873Ssephe * SUCH DAMAGE. 28293873Ssephe * 29293873Ssephe * $FreeBSD: head/include/rpcsvc/yp_prot.h 50473 1999-08-27 23:45:13Z peter $ 30293873Ssephe */ 31293873Ssephe 32293873Ssephe#ifndef _RPCSVC_YP_PROT_H_ 33293873Ssephe#define _RPCSVC_YP_PROT_H_ 34293873Ssephe 35293873Ssephe/* 36293873Ssephe * YPSERV PROTOCOL: 37293873Ssephe * 38293873Ssephe * ypserv supports the following procedures: 39293873Ssephe * 40293873Ssephe * YPPROC_NULL takes (void), returns (void). 41293873Ssephe * called to check if server is alive. 42293873Ssephe * YPPROC_DOMAIN takes (char *), returns (bool_t). 43293873Ssephe * true if ypserv serves the named domain. 44293873Ssephe * YPPROC_DOMAIN_NOACK takes (char *), returns (bool_t). 45293873Ssephe * true if ypserv serves the named domain. 46293873Ssephe * used for broadcasts, does not ack if ypserv 47293873Ssephe * doesn't handle named domain. 48293873Ssephe * YPPROC_MATCH takes (struct ypreq_key), returns (struct ypresp_val) 49293873Ssephe * does a lookup. 50293873Ssephe * YPPROC_FIRST takes (struct ypreq_nokey) returns (ypresp_key_val). 51293873Ssephe * gets the first key/datum from the map. 52293873Ssephe * YPPROC_NEXT takes (struct ypreq_key) returns (ypresp_key_val). 53293873Ssephe * gets the next key/datum from the map. 54293873Ssephe * YPPROC_XFR takes (struct ypreq_xfr), returns (void). 55293873Ssephe * tells ypserv to check if there is a new version of 56293873Ssephe * the map. 57293873Ssephe * YPPROC_CLEAR takes (void), returns (void). 58293873Ssephe * tells ypserv to flush it's file cache, so that 59293873Ssephe * newly transferred files will get read. 60293873Ssephe * YPPROC_ALL takes (struct ypreq_nokey), returns (bool_t and 61293873Ssephe * struct ypresp_key_val). 62293873Ssephe * returns an array of data, with the bool_t being 63297176Ssephe * false on the last datum. read the source, it's 64293873Ssephe * convoluted. 65293873Ssephe * YPPROC_MASTER takes (struct ypreq_nokey), returns (ypresp_master). 66293873Ssephe * YPPROC_ORDER takes (struct ypreq_nokey), returns (ypresp_order). 67293873Ssephe * YPPROC_MAPLIST takes (char *), returns (struct ypmaplist *). 68293873Ssephe */ 69293873Ssephe 70293873Ssephe#ifndef BOOL_DEFINED 71293873Ssephetypedef u_int bool; 72293873Ssephe#define BOOL_DEFINED 73293873Ssephe#endif 74293873Ssephe 75293873Ssephe/* Program and version symbols, magic numbers */ 76293873Ssephe 77293873Ssephe#define YPPROG ((u_long)100004) 78293873Ssephe#define YPVERS ((u_long)2) 79293873Ssephe#define YPVERS_ORIG ((u_long)1) 80293873Ssephe#define YPMAXRECORD ((u_long)1024) 81293873Ssephe#define YPMAXDOMAIN ((u_long)64) 82293873Ssephe#define YPMAXMAP ((u_long)64) 83293873Ssephe#define YPMAXPEER ((u_long)256) 84293873Ssephe 85293873Ssephe/* 86293873Ssephe * I don't know if anything of sun's depends on this, or if they 87293873Ssephe * simply defined it so that their own code wouldn't try to send 88293873Ssephe * packets over the ethernet MTU. This YP code doesn't use it. 89293873Ssephe */ 90293873Ssephe#define YPMSGSZ 1600 91293873Ssephe 92293873Ssephe#ifndef DATUM 93293873Ssephetypedef struct { 94293873Ssephe char *dptr; 95293873Ssephe int dsize; 96293873Ssephe} datum; 97293873Ssephe#define DATUM 98293873Ssephe#endif 99293873Ssephe 100293873Ssephestruct ypmap_parms { 101293873Ssephe char *domain; 102293873Ssephe char *map; 103293873Ssephe u_long ordernum; 104293873Ssephe char *owner; 105293873Ssephe}; 106293873Ssephe 107293873Ssephestruct ypreq_key { 108293873Ssephe char *domain; 109293873Ssephe char *map; 110293873Ssephe datum keydat; 111293873Ssephe}; 112293873Ssephe 113293873Ssephestruct ypreq_nokey { 114293873Ssephe char *domain; 115293873Ssephe char *map; 116293873Ssephe}; 117293873Ssephe 118293873Ssephestruct ypreq_xfr { 119293873Ssephe struct ypmap_parms map_parms; 120293873Ssephe u_long transid; 121293873Ssephe u_long proto; 122293873Ssephe u_short port; 123293873Ssephe}; 124293873Ssephe#define ypxfr_domain map_parms.domain 125293873Ssephe#define ypxfr_map map_parms.map 126293873Ssephe#define ypxfr_ordernum map_parms.ordernum 127293873Ssephe#define ypxfr_owner map_parms.owner 128293873Ssephe 129293873Ssephestruct ypresp_val { 130293873Ssephe u_long status; 131293873Ssephe datum valdat; 132}; 133 134struct ypresp_key_val { 135 u_long status; 136 datum keydat; 137 datum valdat; 138}; 139 140struct ypresp_master { 141 u_long status; 142 char *master; 143}; 144 145struct ypresp_order { 146 u_long status; 147 u_long ordernum; 148}; 149 150struct ypmaplist { 151 char ypml_name[YPMAXMAP + 1]; 152 struct ypmaplist *ypml_next; 153}; 154 155struct ypresp_maplist { 156 u_long status; 157 struct ypmaplist *list; 158}; 159 160/* ypserv procedure numbers */ 161#define YPPROC_NULL ((u_long)0) 162#define YPPROC_DOMAIN ((u_long)1) 163#define YPPROC_DOMAIN_NONACK ((u_long)2) 164#define YPPROC_MATCH ((u_long)3) 165#define YPPROC_FIRST ((u_long)4) 166#define YPPROC_NEXT ((u_long)5) 167#define YPPROC_XFR ((u_long)6) 168#define YPPROC_CLEAR ((u_long)7) 169#define YPPROC_ALL ((u_long)8) 170#define YPPROC_MASTER ((u_long)9) 171#define YPPROC_ORDER ((u_long)10) 172#define YPPROC_MAPLIST ((u_long)11) 173 174/* ypserv procedure return status values */ 175#define YP_TRUE ((long)1) /* general purpose success code */ 176#define YP_NOMORE ((long)2) /* no more entries in map */ 177#define YP_FALSE ((long)0) /* general purpose failure code */ 178#define YP_NOMAP ((long)-1) /* no such map in domain */ 179#define YP_NODOM ((long)-2) /* domain not supported */ 180#define YP_NOKEY ((long)-3) /* no such key in map */ 181#define YP_BADOP ((long)-4) /* invalid operation */ 182#define YP_BADDB ((long)-5) /* server data base is bad */ 183#define YP_YPERR ((long)-6) /* YP server error */ 184#define YP_BADARGS ((long)-7) /* request arguments bad */ 185#define YP_VERS ((long)-8) /* YP server version mismatch */ 186 187/* 188 * Sun's header file says: 189 * "Domain binding data structure, used by ypclnt package and ypserv modules. 190 * Users of the ypclnt package (or of this protocol) don't HAVE to know about 191 * it, but it must be available to users because _yp_dobind is a public 192 * interface." 193 * 194 * This is totally bogus! Nowhere else does Sun state that _yp_dobind() is 195 * a public interface, and I don't know any reason anyone would want to call 196 * it. But, just in case anyone does actually expect it to be available.. 197 * we provide this.. exactly as Sun wants it. 198 */ 199struct dom_binding { 200 struct dom_binding *dom_pnext; 201 char dom_domain[YPMAXDOMAIN + 1]; 202 struct sockaddr_in dom_server_addr; 203 u_short dom_server_port; 204 int dom_socket; 205 CLIENT *dom_client; 206 u_short dom_local_port; 207 long dom_vers; 208}; 209 210/* 211 * YPBIND PROTOCOL: 212 * 213 * ypbind supports the following procedures: 214 * 215 * YPBINDPROC_NULL takes (void), returns (void). 216 * to check if ypbind is running. 217 * YPBINDPROC_DOMAIN takes (char *), returns (struct ypbind_resp). 218 * requests that ypbind start to serve the 219 * named domain (if it doesn't already) 220 * YPBINDPROC_SETDOM takes (struct ypbind_setdom), returns (void). 221 * used by ypset. 222 */ 223 224#define YPBINDPROG ((u_long)100007) 225#define YPBINDVERS ((u_long)2) 226#define YPBINDVERS_ORIG ((u_long)1) 227 228/* ypbind procedure numbers */ 229#define YPBINDPROC_NULL ((u_long)0) 230#define YPBINDPROC_DOMAIN ((u_long)1) 231#define YPBINDPROC_SETDOM ((u_long)2) 232 233/* error code in ypbind_resp.ypbind_status */ 234enum ypbind_resptype { 235 YPBIND_SUCC_VAL = 1, 236 YPBIND_FAIL_VAL = 2 237}; 238 239/* network order, of course */ 240struct ypbind_binding { 241 struct in_addr ypbind_binding_addr; 242 u_short ypbind_binding_port; 243}; 244 245struct ypbind_resp { 246 enum ypbind_resptype ypbind_status; 247 union { 248 u_long ypbind_error; 249 struct ypbind_binding ypbind_bindinfo; 250 } ypbind_respbody; 251}; 252 253/* error code in ypbind_resp.ypbind_respbody.ypbind_error */ 254#define YPBIND_ERR_ERR 1 /* internal error */ 255#define YPBIND_ERR_NOSERV 2 /* no bound server for passed domain */ 256#define YPBIND_ERR_RESC 3 /* system resource allocation failure */ 257 258/* 259 * Request data structure for ypbind "Set domain" procedure. 260 */ 261struct ypbind_setdom { 262 char ypsetdom_domain[YPMAXDOMAIN + 1]; 263 struct ypbind_binding ypsetdom_binding; 264 u_short ypsetdom_vers; 265}; 266#define ypsetdom_addr ypsetdom_binding.ypbind_binding_addr 267#define ypsetdom_port ypsetdom_binding.ypbind_binding_port 268 269/* 270 * YPPUSH PROTOCOL: 271 * 272 * Sun says: 273 * "Protocol between clients (ypxfr, only) and yppush 274 * yppush speaks a protocol in the transient range, which 275 * is supplied to ypxfr as a command-line parameter when it 276 * is activated by ypserv." 277 * 278 * This protocol is not implemented, naturally, because this YP 279 * implementation only does the client side. 280 */ 281#define YPPUSHVERS ((u_long)1) 282#define YPPUSHVERS_ORIG ((u_long)1) 283 284/* yppush procedure numbers */ 285#define YPPUSHPROC_NULL ((u_long)0) 286#define YPPUSHPROC_XFRRESP ((u_long)1) 287 288struct yppushresp_xfr { 289 u_long transid; 290 u_long status; 291}; 292 293/* yppush status value in yppushresp_xfr.status */ 294#define YPPUSH_SUCC ((long)1) /* Success */ 295#define YPPUSH_AGE ((long)2) /* Master's version not newer */ 296#define YPPUSH_NOMAP ((long)-1) /* Can't find server for map */ 297#define YPPUSH_NODOM ((long)-2) /* Domain not supported */ 298#define YPPUSH_RSRC ((long)-3) /* Local resource alloc failure */ 299#define YPPUSH_RPC ((long)-4) /* RPC failure talking to server */ 300#define YPPUSH_MADDR ((long)-5) /* Can't get master address */ 301#define YPPUSH_YPERR ((long)-6) /* YP server/map db error */ 302#define YPPUSH_BADARGS ((long)-7) /* Request arguments bad */ 303#define YPPUSH_DBM ((long)-8) /* Local dbm operation failed */ 304#define YPPUSH_FILE ((long)-9) /* Local file I/O operation failed */ 305#define YPPUSH_SKEW ((long)-10) /* Map version skew during transfer */ 306#define YPPUSH_CLEAR ((long)-11) /* Can't send "Clear" req to local ypserv */ 307#define YPPUSH_FORCE ((long)-12) /* No local order number in map - use -f */ 308#define YPPUSH_XFRERR ((long)-13) /* ypxfr error */ 309#define YPPUSH_REFUSED ((long)-14) /* Transfer request refused by ypserv */ 310 311struct inaddr; 312__BEGIN_DECLS 313bool_t xdr_datum __P((XDR *, datum *)); 314bool_t xdr_ypreq_key __P((XDR *, struct ypreq_key *)); 315bool_t xdr_ypreq_nokey __P((XDR *, struct ypreq_nokey *)); 316bool_t xdr_ypreq_xfr __P((XDR *, struct ypreq_xfr *)); 317bool_t xdr_ypresp_val __P((XDR *, struct ypresp_val *)); 318bool_t xdr_ypresp_key_val __P((XDR *, struct ypresp_key_val *)); 319bool_t xdr_ypbind_resp __P((XDR *, struct ypbind_resp *)); 320bool_t xdr_ypbind_setdom __P((XDR *, struct ypbind_setdom *)); 321bool_t xdr_yp_inaddr __P((XDR *, struct inaddr *)); 322bool_t xdr_ypmap_parms __P((XDR *, struct ypmap_parms *)); 323bool_t xdr_yppushresp_xfr __P((XDR *, struct yppushresp_xfr *)); 324bool_t xdr_ypresp_order __P((XDR *, struct ypresp_order *)); 325bool_t xdr_ypresp_master __P((XDR *, struct ypresp_master *)); 326bool_t xdr_ypresp_maplist __P((XDR *, struct ypresp_maplist *)); 327__END_DECLS 328 329#endif /* _RPCSVC_YP_PROT_H_ */ 330