xref: /titanic_52/usr/src/head/rpcsvc/nis.x (revision c7158ae983f5a04c4a998f468ecefba6d23ba721)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * RPC Language Protocol description file for NIS Plus
24  *
25  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
26  * Use is subject to license terms.
27  *
28  * ident	"%Z%%M%	%I%	%E% SMI"
29  *
30  * From 4.1 : @(#)nis.x	1.61 Copyright 1989 Sun Microsystems
31  */
32 #ifdef RPC_HDR
33 %/*
34 % *	nis.h
35 % *
36 % *	This file is the main include file for NIS clients. It contains
37 % *	both the client library function defines and the various data
38 % * 	structures used by the NIS service. It includes the file nis_tags.h
39 % *	which defines the tag values. This allows the tags to change without
40 % *	having to change the nis.x file.
41 % *
42 % *	NOTE : DO NOT EDIT THIS FILE! It is automatically generated when
43 % *	       rpcgen is run on the nis.x file. Note that there is a
44 % *	       simple sed script to remove some unneeded lines. (See the
45 % *	       Makefile target nis.h)
46 % *
47 % */
48 %#include <rpcsvc/nis_tags.h>
49 #endif
50 
51 /* This gets stuffed into the source files. */
52 #if RPC_HDR
53 %#include <rpc/xdr.h>
54 #endif
55 #if defined(RPC_XDR) || defined(RPC_CLNT) || defined(RPC_SVC)
56 %#ifndef xdr_uint32_t
57 %#define xdr_uint32_t	xdr_u_int
58 %#endif
59 %#ifndef xdr_uint_t
60 %#define xdr_uint_t	xdr_u_int
61 %#endif
62 #endif
63 #if RPC_SVC
64 %#include "nis_svc.h"
65 #endif
66 
67 /* Include the RPC Language description of NIS objects */
68 #include "nis_object.x"
69 
70 /* Errors  that can be returned by the service */
71 enum nis_error {
72 	NIS_SUCCESS = 0,	/* A-ok, let's rock n roll 	*/
73 	NIS_S_SUCCESS = 1,	/* Name found (maybe)	   	*/
74 	NIS_NOTFOUND = 2,	/* Name definitely not found 	*/
75 	NIS_S_NOTFOUND = 3,	/* Name maybe not found 	*/
76 	NIS_CACHEEXPIRED = 4,	/* Name exists but cache out of date */
77 	NIS_NAMEUNREACHABLE = 5, /* Can't get there from here */
78 	NIS_UNKNOWNOBJ = 6,	/* Object type is bogus */
79 	NIS_TRYAGAIN = 7,	/* I'm busy, call back */
80 	NIS_SYSTEMERROR = 8,	/* Generic system error */
81 	NIS_CHAINBROKEN = 9,	/* First/Next warning */
82 	NIS_PERMISSION = 10,	/* Not enough permission to access */
83 	NIS_NOTOWNER = 11,	/* You don't own it, sorry */
84 	NIS_NOT_ME = 12,	/* I don't serve this name */
85 	NIS_NOMEMORY = 13,	/* Outta VM! Help! */
86 	NIS_NAMEEXISTS = 14,	/* Can't create over another name */
87 	NIS_NOTMASTER = 15,	/* I'm justa secondaray, don't ask me */
88 	NIS_INVALIDOBJ = 16,	/* Object is broken somehow */
89 	NIS_BADNAME = 17,	/* Unparsable name */
90 	NIS_NOCALLBACK = 18,	/* Couldn't talk to call back proc */
91 	NIS_CBRESULTS = 19,	/* Results being called back to you */
92 	NIS_NOSUCHNAME = 20,	/* Name unknown */
93 	NIS_NOTUNIQUE = 21,	/* Value is not uniques (entry) */
94 	NIS_IBMODERROR = 22,	/* Inf. Base. Modify error. */
95 	NIS_NOSUCHTABLE = 23,	/* Name for table was wrong */
96 	NIS_TYPEMISMATCH = 24, 	/* Entry and table type mismatch */
97 	NIS_LINKNAMEERROR = 25,	/* Link points to bogus name */
98 	NIS_PARTIAL = 26,	/* Partial success, found table */
99 	NIS_TOOMANYATTRS = 27,	/* Too many attributes */
100 	NIS_RPCERROR = 28,	/* RPC error encountered */
101 	NIS_BADATTRIBUTE = 29,	/* Bad or invalid attribute */
102 	NIS_NOTSEARCHABLE = 30,	/* Non-searchable object searched */
103 	NIS_CBERROR = 31,	/* Error during callback (svc crash) */
104 	NIS_FOREIGNNS = 32,	/* Foreign Namespace */
105 	NIS_BADOBJECT = 33,	/* Malformed object structure */
106 	NIS_NOTSAMEOBJ = 34,	/* Object swapped during deletion */
107 	NIS_MODFAIL = 35,	/* Failure during a Modify. */
108 	NIS_BADREQUEST = 36,	/* Illegal query for table */
109 	NIS_NOTEMPTY = 37,	/* Attempt to remove a non-empty tbl */
110 	NIS_COLDSTART_ERR = 38, /* Error accesing the cold start file */
111 	NIS_RESYNC = 39,	/* Transaction log too far out of date */
112 	NIS_FAIL = 40,		/* NIS operation failed. */
113 	NIS_UNAVAIL = 41,	/* NIS+ service is unavailable (client) */
114 	NIS_RES2BIG = 42,	/* NIS+ result too big for datagram */
115 	NIS_SRVAUTH = 43,	/* NIS+ server wasn't authenticated. */
116 	NIS_CLNTAUTH = 44,	/* NIS+ Client wasn't authenticated. */
117 	NIS_NOFILESPACE = 45,	/* NIS+ server ran out of disk space */
118 	NIS_NOPROC = 46,	/* NIS+ server couldn't create new proc */
119 	NIS_DUMPLATER = 47	/* NIS+ server already has dump child */
120 };
121 
122 
123 /*
124  * Structure definitions for the parameters and results of the actual
125  * NIS RPC calls.
126  *
127  * This is the standard result (in the protocol) of most of the nis
128  * requests.
129  */
130 
131 struct nis_result {
132 	nis_error	status;		/* Status of the response */
133 	nis_object	objects<>;	/* objects found 	  */
134 	netobj		cookie;		/* Cookie Data 		  */
135 	uint32_t	zticks;		/* server ticks	 	  */
136 	uint32_t	dticks;		/* DBM ticks.		  */
137 	uint32_t	aticks;		/* Cache (accel) ticks	  */
138 	uint32_t	cticks;		/* Client ticks		  */
139 };
140 
141 /*
142  * A Name Service request
143  * This request is used to access the name space, ns_name is the name
144  * of the object within the namespace and the object is it's value, for
145  * add/modify, a copy of the original for remove.
146  */
147 
148 struct ns_request {
149 	nis_name	ns_name;	/* Name in the NIS name space	*/
150 	nis_object	ns_object<1>;	/* Optional Object (add/remove)	*/
151 };
152 
153 /*
154  * An information base request
155  * This request includes the NIS name of the table we wish to search, the
156  * search criteria in the form of attribute/value pairs and an optional
157  * callback program number. If the callback program number is provided
158  * the server will send back objects one at a time, otherwise it will
159  * return them all in the response.
160  */
161 
162 struct ib_request {
163 	nis_name  	ibr_name;	/* The name of the Table 	*/
164 	nis_attr  	ibr_srch<>; 	/* The search critereia 	*/
165 	u_int		ibr_flags;	/* Optional flags 		*/
166 	nis_object	ibr_obj<1>;	/* optional object (add/modify) */
167 	nis_server	ibr_cbhost<1>;	/* Optional callback info	*/
168 	u_int		ibr_bufsize;	/* Optional first/next bufsize	*/
169 	netobj		ibr_cookie;	/* The first/next cookie	*/
170 };
171 
172 /*
173  * This argument to the PING call notifies the replicas that something in
174  * a directory has changed and this is it's timestamp. The replica will use
175  * the timestamp to determine if its resync operation was successful.
176  */
177 struct ping_args {
178 	nis_name	dir;	/* Directory that had the change */
179 	uint32_t	stamp;	/* timestamp of the transaction  */
180 };
181 
182 /*
183  * These are the type of entries that are stored in the transaction log,
184  * note that modifications will appear as two entries, for names, they have
185  * a "OLD" entry followed by a "NEW" entry. For entries in tables, there
186  * is a remove followed by an add. It is done this way so that we can read
187  * the log backwards to back out transactions and forwards to propogate
188  * updated.
189  */
190 enum log_entry_t {
191 	LOG_NOP = 0,
192 	ADD_NAME = 1,		/* Name Added to name space 		  */
193 	REM_NAME = 2,		/* Name removed from name space 	  */
194 	MOD_NAME_OLD = 3,	/* Name was modified in the name space 	  */
195 	MOD_NAME_NEW = 4,	/* Name was modified in the name space 	  */
196 	ADD_IBASE = 5,		/* Entry added to information base 	  */
197 	REM_IBASE = 6,		/* Entry removed from information base    */
198 	MOD_IBASE = 7,		/* Entry was modified in information base */
199 	UPD_STAMP = 8		/* Update timestamp (used as fenceposts)  */
200 };
201 
202 /*
203  * This result is returned from the name service when it is requested to
204  * dump logged entries from its transaction log. Information base updates
205  * will have the name of the information base in the le_name field and
206  * a canonical set of attribute/value pairs to fully specify the entry's
207  * 'name'.
208  */
209 struct log_entry {
210 	uint32_t	le_time;	/* Time in seconds 		*/
211 	log_entry_t	le_type;	/* Type of log entry 		*/
212 	nis_name	le_princp;	/* Principal making the change	*/
213 	nis_name	le_name;	/* Name of table/dir involved 	*/
214 	nis_attr	le_attrs<>;	/* List of AV pairs.		*/
215 	nis_object	le_object;	/* Actual object value 		*/
216 };
217 
218 struct log_result {
219 	nis_error 	lr_status;	/* The status itself 	 	*/
220 	netobj		lr_cookie;	/* Used by the dump callback	*/
221 	log_entry	lr_entries<>;	/* zero or more entries 	*/
222 };
223 
224 struct cp_result {
225 	nis_error	cp_status;	/* Status of the checkpoint 	*/
226 	uint32_t	cp_zticks;	/* Service 'ticks' 	    	*/
227 	uint32_t	cp_dticks;	/* Database 'ticks'	    	*/
228 };
229 
230 /*
231  * This structure defines a generic NIS tag list. The taglist contains
232  * zero or tags, each of which is a type and a value. (u_int).
233  * These are used to report statistics (see tag definitions below)
234  * and to set or reset state variables.
235  */
236 struct nis_tag {
237 	u_int	tag_type;	/* Statistic tag (may vary) 	 */
238 	string	tag_val<>;	/* Statistic value may also vary */
239 };
240 
241 struct nis_taglist {
242 	nis_tag tags<>;		/* List of tags */
243 };
244 
245 struct dump_args {
246 	nis_name	da_dir;		/* Directory to dump 	*/
247 	uint32_t	da_time;	/* From this timestamp	*/
248 	nis_server	da_cbhost<1>;	/* Callback to use.	*/
249 };
250 
251 struct fd_args {
252 	nis_name	dir_name;  /* The directory we're looking for */
253 	nis_name	requester; /* Host principal name for signature */
254 };
255 
256 struct fd_result {
257 	nis_error	status;		/* Status returned by function	*/
258 	nis_name	source;		/* Source of this answer   	*/
259 	opaque		dir_data<>;	/* Directory Data (XDR'ed) 	*/
260 	opaque		signature<>;	/* Signature of the source 	*/
261 };
262 
263 %/*
264 % * Structures used for server binding.
265 % */
266 struct nis_bound_endpoint {
267 	endpoint ep;
268 	int generation;
269 	int rank;
270 	u_int flags;
271 	int hostnum;
272 	int epnum;
273 	nis_name uaddr;
274 	endpoint cbep;
275 };
276 typedef struct nis_bound_endpoint nis_bound_endpoint;
277 
278 struct nis_bound_directory {
279 	int generation;
280 	int min_rank;           /* minimum rank of bound endpoints */
281 	int optimal_rank;       /* best possible rank of all endpoints */
282 	directory_obj dobj;
283 	nis_bound_endpoint BEP<>;
284 };
285 typedef struct nis_bound_directory nis_bound_directory;
286 %#define bep_len BEP.BEP_len
287 %#define bep_val BEP.BEP_val
288 
289 struct nis_active_endpoint {
290 	endpoint ep;
291 	nis_name hostname;
292 	int rank;
293 	int uaddr_generation;
294 	nis_name uaddr;
295 	int cbep_generation;
296 	endpoint cbep;
297 };
298 typedef struct nis_active_endpoint nis_active_endpoint;
299 
300 %/* defines for nis_bound_endpoint.flags */
301 %#define NIS_BOUND 0x1
302 %#define NIS_TRANSIENT_ERRORS 0x2
303 
304 
305 
306 /*
307  * What's going on here? Well, it's like this. When the service
308  * is being compiled it wants to have the service definition specific
309  * info included, and when the client is being compiled it wants that
310  * info. This includes the appropriate file which was generated by
311  * make in the protocols directory (probably /usr/include/rpcsvc).
312  */
313 #ifdef RPC_SVC
314 %#include "nis_svc.h"
315 #endif
316 #ifdef RPC_CLNT
317 %#include "nis_clnt.h"
318 #endif
319 
320 program  NIS_PROG {
321 
322 	/* RPC Language description of the NIS+ protocol */
323 	version NIS_VERSION {
324 		/* The name service functions */
325 		nis_result  NIS_LOOKUP(ns_request) = 1;
326 		nis_result  NIS_ADD(ns_request) = 2;
327 		nis_result  NIS_MODIFY(ns_request) = 3;
328 		nis_result  NIS_REMOVE(ns_request) = 4;
329 
330 		/* The information base functions */
331 		nis_result  NIS_IBLIST(ib_request) = 5;
332 		nis_result  NIS_IBADD(ib_request) = 6;
333 		nis_result  NIS_IBMODIFY(ib_request) = 7;
334 		nis_result  NIS_IBREMOVE(ib_request) = 8;
335 		nis_result  NIS_IBFIRST(ib_request) = 9;
336 		nis_result  NIS_IBNEXT(ib_request) = 10;
337 
338 		/* NIS Administrative functions */
339 		fd_result   NIS_FINDDIRECTORY(fd_args) = 12;
340 
341 		/* If fetch and optionally reset statistics */
342 		nis_taglist  NIS_STATUS(nis_taglist) = 14;
343 
344 		/* Dump changes to directory since time in da_time */
345 		log_result  NIS_DUMPLOG(dump_args) = 15;
346 
347 		/* Dump contents of directory named */
348 		log_result  NIS_DUMP(dump_args) = 16;
349 
350 		/* Check status of callback thread */
351 		bool	    NIS_CALLBACK(netobj) = 17;
352 
353 		/* Return last update time for named dir */
354 		uint32_t    NIS_CPTIME(nis_name) = 18;
355 
356 		/* Checkpoint directory or table named */
357 		cp_result   NIS_CHECKPOINT(nis_name) = 19;
358 
359 		/* Send 'status changed' ping to replicates */
360 		void	    NIS_PING(ping_args) = 20;
361 
362 		/* Modify server behaviour (such as debugging) */
363 		nis_taglist NIS_SERVSTATE(nis_taglist) = 21;
364 
365 		/* Create a Directory */
366 		nis_error   NIS_MKDIR(nis_name) = 22;
367 
368 		/* Remove a Directory */
369 		nis_error   NIS_RMDIR(nis_name) = 23;
370 
371 		/* Update public keys of a directory object */
372 		nis_error   NIS_UPDKEYS(nis_name) = 24;
373 	} = 3;
374 } = 100300;
375 
376 /*
377  * Included below are the defines that become part of nis.h,
378  * they are technically not part of the protocol, but do define
379  * key aspects of the implementation and are therefore useful
380  * in building a conforming server or client.
381  */
382 #if RPC_HDR
383 %/*
384 % * Generic "hash" datastructures, used by all types of hashed data.
385 % */
386 %struct nis_hash_data {
387 %	nis_name		name;	   /* NIS name of hashed item      */
388 %	int			keychain;  /* It's hash key (for pop)      */
389 %	struct nis_hash_data	*next;	   /* Hash collision pointer       */
390 %	struct nis_hash_data	*prv_item; /* A serial, doubly linked list */
391 %	struct nis_hash_data	*nxt_item; /* of items in the hash table   */
392 %};
393 %typedef struct nis_hash_data NIS_HASH_ITEM;
394 %
395 %struct nis_hash_table {
396 %	NIS_HASH_ITEM	*keys[64];	/* A hash table of items           */
397 %	NIS_HASH_ITEM	*first;		/* The first "item" in serial list */
398 %};
399 %typedef struct nis_hash_table NIS_HASH_TABLE;
400 %
401 %/* Structure for storing dynamically allocated static data */
402 %struct nis_sdata {
403 %	void	*buf;	/* Memory allocation pointer 	*/
404 %	u_int	size;	/* Buffer size			*/
405 %};
406 %
407 %/* Generic client creating flags */
408 %#define ZMH_VC		1
409 %#define ZMH_DG		2
410 %#define ZMH_AUTH	4
411 %#define ZMH_NOFALLBACK 8
412 %
413 %/* Testing Access rights for objects */
414 %
415 %#define NIS_READ_ACC		1
416 %#define NIS_MODIFY_ACC		2
417 %#define NIS_CREATE_ACC		4
418 %#define NIS_DESTROY_ACC	8
419 %/* Test macros. a == access rights, m == desired rights. */
420 %#define NIS_WORLD(a, m)	(((a) & (m)) != 0)
421 %#define NIS_GROUP(a, m)	(((a) & ((m) << 8)) != 0)
422 %#define NIS_OWNER(a, m)	(((a) & ((m) << 16)) != 0)
423 %#define NIS_NOBODY(a, m)	(((a) & ((m) << 24)) != 0)
424 %/*
425 % * EOL Alert - The following non-prefixed test macros are
426 % * here for backward compatability, and will be not be present
427 % * in future releases - use the NIS_*() macros above.
428 % */
429 %#define WORLD(a, m)	(((a) & (m)) != 0)
430 %#define GROUP(a, m)	(((a) & ((m) << 8)) != 0)
431 %#define OWNER(a, m)	(((a) & ((m) << 16)) != 0)
432 %#define NOBODY(a, m)	(((a) & ((m) << 24)) != 0)
433 %
434 %#define OATYPE(d, n) (((d)->do_armask.do_armask_val+n)->oa_otype)
435 %#define OARIGHTS(d, n) (((d)->do_armask.do_armask_val+n)->oa_rights)
436 %#define WORLD_DEFAULT (NIS_READ_ACC)
437 %#define GROUP_DEFAULT (NIS_READ_ACC << 8)
438 %#define OWNER_DEFAULT ((NIS_READ_ACC +\
439 %			 NIS_MODIFY_ACC +\
440 %			 NIS_CREATE_ACC +\
441 %			 NIS_DESTROY_ACC) << 16)
442 %#define DEFAULT_RIGHTS (WORLD_DEFAULT | GROUP_DEFAULT | OWNER_DEFAULT)
443 %
444 %/* Result manipulation defines ... */
445 %#define NIS_RES_NUMOBJ(x)	((x)->objects.objects_len)
446 %#define NIS_RES_OBJECT(x)	((x)->objects.objects_val)
447 %#define NIS_RES_COOKIE(x)	((x)->cookie)
448 %#define NIS_RES_STATUS(x)	((x)->status)
449 %
450 %/* These defines make getting at the variant part of the object easier. */
451 %#define TA_data zo_data.objdata_u.ta_data
452 %#define EN_data zo_data.objdata_u.en_data
453 %#define DI_data zo_data.objdata_u.di_data
454 %#define LI_data zo_data.objdata_u.li_data
455 %#define GR_data zo_data.objdata_u.gr_data
456 %
457 %#define __type_of(o) ((o)->zo_data.zo_type)
458 %
459 %/* Declarations for the internal subroutines in nislib.c */
460 %enum name_pos {SAME_NAME, HIGHER_NAME, LOWER_NAME, NOT_SEQUENTIAL, BAD_NAME};
461 %typedef enum name_pos name_pos;
462 %
463 %/*
464 % * Defines for getting at column data in entry objects. Because RPCGEN
465 % * generates some rather wordy structures, we create some defines that
466 % * collapse the needed keystrokes to access a particular value using
467 % * these definitions they take an nis_object *, and an int and return
468 % * a u_char * for Value, and an int for length.
469 % */
470 %#define ENTRY_VAL(obj, col) \
471 %	(obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_val
472 %#define ENTRY_LEN(obj, col) \
473 %	(obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len
474 %
475 %
476 %
477 %#ifdef __cplusplus
478 %}
479 %#endif
480 %
481 %/* Prototypes, and extern declarations for the NIS library functions. */
482 %#include <rpcsvc/nislib.h>
483 %#endif /* __NIS_RPCGEN_H */
484 %/* EDIT_START */
485 %
486 %/*
487 % * nis_3.h
488 % *
489 % * This file contains definitions that are only of interest to the actual
490 % * service daemon and client stubs. Normal users of NIS will not include
491 % * this file.
492 % *
493 % * NOTE : This include file is automatically created by a combination
494 % * of rpcgen and sed. DO NOT EDIT IT, change the nis.x file instead
495 % * and then remake this file.
496 % */
497 %#ifndef __nis_3_h
498 %#define __nis_3_h
499 %#ifdef __cplusplus
500 %extern "C" {
501 %#endif
502 #endif
503