1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 1997 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 28*0Sstevel@tonic-gate 29*0Sstevel@tonic-gate /* 30*0Sstevel@tonic-gate * This file contains symbols and structures defining the rpc protocol 31*0Sstevel@tonic-gate * between the NIS clients and the NIS servers. The servers 32*0Sstevel@tonic-gate * are the NIS database servers, and the NIS binders. 33*0Sstevel@tonic-gate */ 34*0Sstevel@tonic-gate 35*0Sstevel@tonic-gate /* 36*0Sstevel@tonic-gate * The following procedures are supported by the protocol: 37*0Sstevel@tonic-gate * 38*0Sstevel@tonic-gate * YPPROC_NULL() returns () takes nothing, returns nothing. This indicates 39*0Sstevel@tonic-gate * that the NIS server is alive. 40*0Sstevel@tonic-gate * 41*0Sstevel@tonic-gate * YPPROC_DOMAIN (char *) returns (bool_t) TRUE. Indicates that the 42*0Sstevel@tonic-gate * responding NIS server does serve the named domain; FALSE indicates no 43*0Sstevel@tonic-gate * support. 44*0Sstevel@tonic-gate * 45*0Sstevel@tonic-gate * YPPROC_DOMAIN_NONACK (char *) returns (TRUE) if the NIS server does serve 46*0Sstevel@tonic-gate * the named domain, otherwise does not return. Used in the broadcast case. 47*0Sstevel@tonic-gate * 48*0Sstevel@tonic-gate * YPPROC_MATCH (struct ypreq_key) returns (struct ypresp_val). Returns the 49*0Sstevel@tonic-gate * right-hand value for a passed left-hand key, within a named map and 50*0Sstevel@tonic-gate * domain. 51*0Sstevel@tonic-gate * 52*0Sstevel@tonic-gate * YPPROC_FIRST (struct ypreq_nokey) returns (struct ypresp_key_val). 53*0Sstevel@tonic-gate * Returns the first key-value pair from a named domain and map. 54*0Sstevel@tonic-gate * 55*0Sstevel@tonic-gate * YPPROC_NEXT (struct ypreq_key) returns (struct ypresp_key_val). Returns 56*0Sstevel@tonic-gate * the key-value pair following a passed key-value pair within a named 57*0Sstevel@tonic-gate * domain and map. 58*0Sstevel@tonic-gate * 59*0Sstevel@tonic-gate * YPPROC_XFR (struct ypreq_xfr) returns nothing. Indicates to a server that 60*0Sstevel@tonic-gate * a map should be updated. 61*0Sstevel@tonic-gate * 62*0Sstevel@tonic-gate * YPPROC_CLEAR takes nothing, returns nothing. Instructs a NIS server to 63*0Sstevel@tonic-gate * close the current map, so that old versions of the disk file don't get 64*0Sstevel@tonic-gate * held open. 65*0Sstevel@tonic-gate * 66*0Sstevel@tonic-gate * YPPROC_ALL (struct ypreq_nokey), returns 67*0Sstevel@tonic-gate * union switch (bool more) { 68*0Sstevel@tonic-gate * TRUE: (struct ypresp_key_val); 69*0Sstevel@tonic-gate * FALSE: (struct) {}; 70*0Sstevel@tonic-gate * } 71*0Sstevel@tonic-gate * 72*0Sstevel@tonic-gate * YPPROC_MASTER (struct ypreq_nokey), returns (ypresp_master) 73*0Sstevel@tonic-gate * 74*0Sstevel@tonic-gate * YPPROC_ORDER (struct ypreq_nokey), returns (ypresp_order) 75*0Sstevel@tonic-gate * 76*0Sstevel@tonic-gate * YPPROC_MAPLIST (char *), returns (struct ypmaplist *) 77*0Sstevel@tonic-gate */ 78*0Sstevel@tonic-gate #ifndef BOOL_DEFINED 79*0Sstevel@tonic-gate typedef unsigned int bool; 80*0Sstevel@tonic-gate #define BOOL_DEFINED 81*0Sstevel@tonic-gate #endif 82*0Sstevel@tonic-gate 83*0Sstevel@tonic-gate extern bool xdr_datum(); 84*0Sstevel@tonic-gate extern bool xdr_ypdomain_wrap_string(); 85*0Sstevel@tonic-gate extern bool xdr_ypmap_wrap_string(); 86*0Sstevel@tonic-gate extern bool xdr_ypreq_key(); 87*0Sstevel@tonic-gate extern bool xdr_ypreq_nokey(); 88*0Sstevel@tonic-gate extern bool xdr_ypreq_xfr(); 89*0Sstevel@tonic-gate extern bool xdr_ypresp_val(); 90*0Sstevel@tonic-gate extern bool xdr_ypresp_key_val(); 91*0Sstevel@tonic-gate extern bool xdr_ypbind_resp(); 92*0Sstevel@tonic-gate extern bool xdr_ypbind_setdom(); 93*0Sstevel@tonic-gate extern bool xdr_yp_inaddr(); 94*0Sstevel@tonic-gate extern bool xdr_ypmap_parms(); 95*0Sstevel@tonic-gate extern bool xdr_ypowner_wrap_string(); 96*0Sstevel@tonic-gate extern bool xdr_yppushresp_xfr(); 97*0Sstevel@tonic-gate extern bool xdr_ypresp_order(); 98*0Sstevel@tonic-gate extern bool xdr_ypresp_master(); 99*0Sstevel@tonic-gate extern bool xdr_ypall(); 100*0Sstevel@tonic-gate extern bool xdr_ypresp_maplist(); 101*0Sstevel@tonic-gate 102*0Sstevel@tonic-gate /* Program and version symbols, magic numbers */ 103*0Sstevel@tonic-gate 104*0Sstevel@tonic-gate #define YPPROG ((u_long)100004) 105*0Sstevel@tonic-gate #define YPVERS ((u_long)2) 106*0Sstevel@tonic-gate #define YPVERS_ORIG ((u_long)1) 107*0Sstevel@tonic-gate #define YPMAXRECORD ((u_long)1024) 108*0Sstevel@tonic-gate #define YPMAXDOMAIN ((u_long)256) 109*0Sstevel@tonic-gate #define YPMAXMAP ((u_long)64) 110*0Sstevel@tonic-gate #define YPMAXPEER ((u_long)256) 111*0Sstevel@tonic-gate 112*0Sstevel@tonic-gate /* byte size of a large NIS packet */ 113*0Sstevel@tonic-gate #define YPMSGSZ 1600 114*0Sstevel@tonic-gate 115*0Sstevel@tonic-gate #ifndef DATUM 116*0Sstevel@tonic-gate typedef struct { 117*0Sstevel@tonic-gate char *dptr; 118*0Sstevel@tonic-gate int dsize; 119*0Sstevel@tonic-gate } datum; 120*0Sstevel@tonic-gate #define DATUM 121*0Sstevel@tonic-gate #endif 122*0Sstevel@tonic-gate 123*0Sstevel@tonic-gate struct ypmap_parms { 124*0Sstevel@tonic-gate char *domain; /* Null string means not available */ 125*0Sstevel@tonic-gate char *map; /* Null string means not available */ 126*0Sstevel@tonic-gate unsigned long int ordernum; /* 0 means not available */ 127*0Sstevel@tonic-gate char *owner; /* Null string means not available */ 128*0Sstevel@tonic-gate }; 129*0Sstevel@tonic-gate 130*0Sstevel@tonic-gate /* 131*0Sstevel@tonic-gate * Request parameter structures 132*0Sstevel@tonic-gate */ 133*0Sstevel@tonic-gate 134*0Sstevel@tonic-gate struct ypreq_key { 135*0Sstevel@tonic-gate char *domain; 136*0Sstevel@tonic-gate char *map; 137*0Sstevel@tonic-gate datum keydat; 138*0Sstevel@tonic-gate }; 139*0Sstevel@tonic-gate 140*0Sstevel@tonic-gate struct ypreq_nokey { 141*0Sstevel@tonic-gate char *domain; 142*0Sstevel@tonic-gate char *map; 143*0Sstevel@tonic-gate }; 144*0Sstevel@tonic-gate 145*0Sstevel@tonic-gate struct ypreq_xfr { 146*0Sstevel@tonic-gate struct ypmap_parms map_parms; 147*0Sstevel@tonic-gate unsigned long transid; 148*0Sstevel@tonic-gate unsigned long proto; 149*0Sstevel@tonic-gate unsigned short port; 150*0Sstevel@tonic-gate }; 151*0Sstevel@tonic-gate #define ypxfr_domain map_parms.domain 152*0Sstevel@tonic-gate #define ypxfr_map map_parms.map 153*0Sstevel@tonic-gate #define ypxfr_ordernum map_parms.ordernum 154*0Sstevel@tonic-gate #define ypxfr_owner map_parms.owner 155*0Sstevel@tonic-gate 156*0Sstevel@tonic-gate /* 157*0Sstevel@tonic-gate * Response parameter structures 158*0Sstevel@tonic-gate */ 159*0Sstevel@tonic-gate 160*0Sstevel@tonic-gate struct ypresp_val { 161*0Sstevel@tonic-gate long unsigned status; 162*0Sstevel@tonic-gate datum valdat; 163*0Sstevel@tonic-gate }; 164*0Sstevel@tonic-gate 165*0Sstevel@tonic-gate struct ypresp_key_val { 166*0Sstevel@tonic-gate long unsigned status; 167*0Sstevel@tonic-gate datum keydat; 168*0Sstevel@tonic-gate datum valdat; 169*0Sstevel@tonic-gate }; 170*0Sstevel@tonic-gate 171*0Sstevel@tonic-gate struct ypresp_master { 172*0Sstevel@tonic-gate long unsigned status; 173*0Sstevel@tonic-gate char *master; 174*0Sstevel@tonic-gate }; 175*0Sstevel@tonic-gate 176*0Sstevel@tonic-gate struct ypresp_order { 177*0Sstevel@tonic-gate long unsigned status; 178*0Sstevel@tonic-gate unsigned long int ordernum; 179*0Sstevel@tonic-gate }; 180*0Sstevel@tonic-gate 181*0Sstevel@tonic-gate struct ypmaplist { 182*0Sstevel@tonic-gate char ypml_name[YPMAXMAP + 1]; 183*0Sstevel@tonic-gate struct ypmaplist *ypml_next; 184*0Sstevel@tonic-gate }; 185*0Sstevel@tonic-gate 186*0Sstevel@tonic-gate struct ypresp_maplist { 187*0Sstevel@tonic-gate long unsigned status; 188*0Sstevel@tonic-gate struct ypmaplist *list; 189*0Sstevel@tonic-gate }; 190*0Sstevel@tonic-gate 191*0Sstevel@tonic-gate /* 192*0Sstevel@tonic-gate * Procedure symbols. YPPROC_NULL, YPPROC_DOMAIN, and YPPROC_DOMAIN_NONACK 193*0Sstevel@tonic-gate * must keep the same values (0, 1, and 2) that they had in the first version 194*0Sstevel@tonic-gate * of the protocol. 195*0Sstevel@tonic-gate */ 196*0Sstevel@tonic-gate 197*0Sstevel@tonic-gate #define YPPROC_NULL ((u_long)0) 198*0Sstevel@tonic-gate #define YPPROC_DOMAIN ((u_long)1) 199*0Sstevel@tonic-gate #define YPPROC_DOMAIN_NONACK ((u_long)2) 200*0Sstevel@tonic-gate #define YPPROC_MATCH ((u_long)3) 201*0Sstevel@tonic-gate #define YPPROC_FIRST ((u_long)4) 202*0Sstevel@tonic-gate #define YPPROC_NEXT ((u_long)5) 203*0Sstevel@tonic-gate #define YPPROC_XFR ((u_long)6) 204*0Sstevel@tonic-gate #define YPPROC_CLEAR ((u_long)7) 205*0Sstevel@tonic-gate #define YPPROC_ALL ((u_long)8) 206*0Sstevel@tonic-gate #define YPPROC_MASTER ((u_long)9) 207*0Sstevel@tonic-gate #define YPPROC_ORDER ((u_long)10) 208*0Sstevel@tonic-gate #define YPPROC_MAPLIST ((u_long)11) 209*0Sstevel@tonic-gate 210*0Sstevel@tonic-gate /* Return status values */ 211*0Sstevel@tonic-gate 212*0Sstevel@tonic-gate #define YP_TRUE ((long)1) /* General purpose success code */ 213*0Sstevel@tonic-gate #define YP_NOMORE ((long)2) /* No more entries in map */ 214*0Sstevel@tonic-gate #define YP_FALSE ((long)0) /* General purpose failure code */ 215*0Sstevel@tonic-gate #define YP_NOMAP ((long)-1) /* No such map in domain */ 216*0Sstevel@tonic-gate #define YP_NODOM ((long)-2) /* Domain not supported */ 217*0Sstevel@tonic-gate #define YP_NOKEY ((long)-3) /* No such key in map */ 218*0Sstevel@tonic-gate #define YP_BADOP ((long)-4) /* Invalid operation */ 219*0Sstevel@tonic-gate #define YP_BADDB ((long)-5) /* Server data base is bad */ 220*0Sstevel@tonic-gate #define YP_YPERR ((long)-6) /* NIS server error */ 221*0Sstevel@tonic-gate #define YP_BADARGS ((long)-7) /* Request arguments bad */ 222*0Sstevel@tonic-gate #define YP_VERS ((long)-8) /* NIS server version mismatch - server 223*0Sstevel@tonic-gate * can't supply requested service. */ 224*0Sstevel@tonic-gate 225*0Sstevel@tonic-gate /* 226*0Sstevel@tonic-gate * Domain binding data structure, used by ypclnt package and ypserv modules. 227*0Sstevel@tonic-gate * Users of the ypclnt package (or of this protocol) don't HAVE to know about 228*0Sstevel@tonic-gate * it, but it must be available to users because _yp_dobind is a public 229*0Sstevel@tonic-gate * interface. 230*0Sstevel@tonic-gate */ 231*0Sstevel@tonic-gate 232*0Sstevel@tonic-gate struct dom_binding { 233*0Sstevel@tonic-gate struct dom_binding *dom_pnext; 234*0Sstevel@tonic-gate char dom_domain[YPMAXDOMAIN + 1]; 235*0Sstevel@tonic-gate struct sockaddr_in dom_server_addr; 236*0Sstevel@tonic-gate unsigned short int dom_server_port; 237*0Sstevel@tonic-gate int dom_socket; 238*0Sstevel@tonic-gate CLIENT *dom_client; 239*0Sstevel@tonic-gate unsigned short int dom_local_port; 240*0Sstevel@tonic-gate long int dom_vers; 241*0Sstevel@tonic-gate }; 242*0Sstevel@tonic-gate 243*0Sstevel@tonic-gate 244*0Sstevel@tonic-gate /* 245*0Sstevel@tonic-gate * Protocol between clients and NIS binder servers 246*0Sstevel@tonic-gate */ 247*0Sstevel@tonic-gate 248*0Sstevel@tonic-gate /* 249*0Sstevel@tonic-gate * The following procedures are supported by the protocol: 250*0Sstevel@tonic-gate * 251*0Sstevel@tonic-gate * YPBINDPROC_NULL() returns () 252*0Sstevel@tonic-gate * takes nothing, returns nothing 253*0Sstevel@tonic-gate * 254*0Sstevel@tonic-gate * YPBINDPROC_DOMAIN takes (char *) returns (struct ypbind_resp) 255*0Sstevel@tonic-gate * 256*0Sstevel@tonic-gate * YPBINDPROC_SETDOM takes (struct ypbind_setdom) returns nothing 257*0Sstevel@tonic-gate */ 258*0Sstevel@tonic-gate 259*0Sstevel@tonic-gate /* Program and version symbols, magic numbers */ 260*0Sstevel@tonic-gate 261*0Sstevel@tonic-gate #define YPBINDPROG ((u_long)100007) 262*0Sstevel@tonic-gate #define YPBINDVERS ((u_long)2) 263*0Sstevel@tonic-gate #define YPBINDVERS_ORIG ((u_long)1) 264*0Sstevel@tonic-gate 265*0Sstevel@tonic-gate /* Procedure symbols */ 266*0Sstevel@tonic-gate 267*0Sstevel@tonic-gate #define YPBINDPROC_NULL ((u_long)0) 268*0Sstevel@tonic-gate #define YPBINDPROC_DOMAIN ((u_long)1) 269*0Sstevel@tonic-gate #define YPBINDPROC_SETDOM ((u_long)2) 270*0Sstevel@tonic-gate /* 271*0Sstevel@tonic-gate * Response structure and overall result status codes. Success and failure 272*0Sstevel@tonic-gate * represent two separate response message types. 273*0Sstevel@tonic-gate */ 274*0Sstevel@tonic-gate 275*0Sstevel@tonic-gate enum ypbind_resptype {YPBIND_SUCC_VAL = 1, YPBIND_FAIL_VAL = 2}; 276*0Sstevel@tonic-gate 277*0Sstevel@tonic-gate struct ypbind_binding { 278*0Sstevel@tonic-gate struct in_addr ypbind_binding_addr; /* In network order */ 279*0Sstevel@tonic-gate unsigned short int ypbind_binding_port; /* In network order */ 280*0Sstevel@tonic-gate }; 281*0Sstevel@tonic-gate struct ypbind_resp { 282*0Sstevel@tonic-gate enum ypbind_resptype ypbind_status; 283*0Sstevel@tonic-gate union { 284*0Sstevel@tonic-gate unsigned long ypbind_error; 285*0Sstevel@tonic-gate struct ypbind_binding ypbind_bindinfo; 286*0Sstevel@tonic-gate } ypbind_respbody; 287*0Sstevel@tonic-gate }; 288*0Sstevel@tonic-gate 289*0Sstevel@tonic-gate 290*0Sstevel@tonic-gate /* Detailed failure reason codes for response field ypbind_error*/ 291*0Sstevel@tonic-gate 292*0Sstevel@tonic-gate #define YPBIND_ERR_ERR 1 /* Internal error */ 293*0Sstevel@tonic-gate #define YPBIND_ERR_NOSERV 2 /* No bound server for passed domain */ 294*0Sstevel@tonic-gate #define YPBIND_ERR_RESC 3 /* System resource allocation failure */ 295*0Sstevel@tonic-gate 296*0Sstevel@tonic-gate /* 297*0Sstevel@tonic-gate * Request data structure for ypbind "Set domain" procedure. 298*0Sstevel@tonic-gate */ 299*0Sstevel@tonic-gate struct ypbind_setdom { 300*0Sstevel@tonic-gate char ypsetdom_domain[YPMAXDOMAIN + 1]; 301*0Sstevel@tonic-gate struct ypbind_binding ypsetdom_binding; 302*0Sstevel@tonic-gate unsigned short ypsetdom_vers; 303*0Sstevel@tonic-gate }; 304*0Sstevel@tonic-gate #define ypsetdom_addr ypsetdom_binding.ypbind_binding_addr 305*0Sstevel@tonic-gate #define ypsetdom_port ypsetdom_binding.ypbind_binding_port 306*0Sstevel@tonic-gate 307*0Sstevel@tonic-gate /* 308*0Sstevel@tonic-gate * Protocol between clients (ypxfr, only) and yppush 309*0Sstevel@tonic-gate * yppush speaks a protocol in the transient range, which 310*0Sstevel@tonic-gate * is supplied to ypxfr as a command-line parameter when it 311*0Sstevel@tonic-gate * is activated by ypserv. 312*0Sstevel@tonic-gate */ 313*0Sstevel@tonic-gate #define YPPUSHVERS ((u_long) 1) 314*0Sstevel@tonic-gate #define YPPUSHVERS_ORIG ((u_long)1) 315*0Sstevel@tonic-gate 316*0Sstevel@tonic-gate /* Procedure symbols */ 317*0Sstevel@tonic-gate 318*0Sstevel@tonic-gate #define YPPUSHPROC_NULL ((u_long)0) 319*0Sstevel@tonic-gate #define YPPUSHPROC_XFRRESP ((u_long)1) 320*0Sstevel@tonic-gate 321*0Sstevel@tonic-gate struct yppushresp_xfr { 322*0Sstevel@tonic-gate unsigned long transid; 323*0Sstevel@tonic-gate unsigned long status; 324*0Sstevel@tonic-gate }; 325*0Sstevel@tonic-gate 326*0Sstevel@tonic-gate /* Status values for yppushresp_xfr.status */ 327*0Sstevel@tonic-gate 328*0Sstevel@tonic-gate #define YPPUSH_SUCC ((long)1) /* Success */ 329*0Sstevel@tonic-gate #define YPPUSH_AGE ((long)2) /* Master's version not newer */ 330*0Sstevel@tonic-gate #define YPPUSH_NOMAP ((long)-1) /* Can't find server for map */ 331*0Sstevel@tonic-gate #define YPPUSH_NODOM ((long)-2) /* Domain not supported */ 332*0Sstevel@tonic-gate #define YPPUSH_RSRC ((long)-3) /* Local resouce alloc failure */ 333*0Sstevel@tonic-gate #define YPPUSH_RPC ((long)-4) /* RPC failure talking to server */ 334*0Sstevel@tonic-gate #define YPPUSH_MADDR ((long)-5) /* Can't get master address */ 335*0Sstevel@tonic-gate #define YPPUSH_YPERR ((long)-6) /* NIS server/map db error */ 336*0Sstevel@tonic-gate #define YPPUSH_BADARGS ((long)-7) /* Request arguments bad */ 337*0Sstevel@tonic-gate #define YPPUSH_DBM ((long)-8) /* Local dbm operation failed */ 338*0Sstevel@tonic-gate #define YPPUSH_FILE ((long)-9) /* Local file I/O operation failed */ 339*0Sstevel@tonic-gate #define YPPUSH_SKEW ((long)-10) /* Map version skew during transfer */ 340*0Sstevel@tonic-gate #define YPPUSH_CLEAR ((long)-11) /* Can't send "Clear" req to local 341*0Sstevel@tonic-gate * ypserv */ 342*0Sstevel@tonic-gate #define YPPUSH_FORCE ((long)-12) /* No local order number in map - 343*0Sstevel@tonic-gate * use -f flag. */ 344*0Sstevel@tonic-gate #define YPPUSH_XFRERR ((long)-13) /* ypxfr error */ 345*0Sstevel@tonic-gate #define YPPUSH_REFUSED ((long)-14) /* Transfer request refused by ypserv */ 346*0Sstevel@tonic-gate 347*0Sstevel@tonic-gate 348