nis.x 16 KB

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