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