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