]> git.saurik.com Git - apple/libinfo.git/blob - netinfo.subproj/ni_prot.x
Libinfo-173.tar.gz
[apple/libinfo.git] / netinfo.subproj / ni_prot.x
1 /*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /*
26 * NetInfo protocol specification
27 * Copyright (C) 1989 by NeXT, Inc.
28 */
29
30 /* Preamble appearing on all generated output */
31 #ifndef NOPREAMBLE
32 %/*
33 % * Output of the RPC protocol compiler: DO NOT EDIT
34 % * Copyright (C) 1989 by NeXT, Inc.
35 % */
36 #endif
37
38 #ifndef RPC_HDR
39 %#include <string.h>
40 #endif
41
42 const NI_NAME_MAXLEN = 65535;
43 const NI_NAMELIST_MAXLEN = 65535;
44 const NI_PROPLIST_MAXLEN = 65535;
45 const NI_IDLIST_MAXLEN = 1048576;
46
47 /*
48 * Every object has a unique ID. One part of the ID identifies the object
49 * itself. The other identifies the instance of the object. Every time
50 * an object is written or an object is destroyed and then reallocated,
51 * its instance is incremented.
52 *
53 * All read operations ignore the instance field. All write operations
54 * refuse to operate on the object if there is an instance mismatch.
55 */
56
57 /*
58 * Don't go through unnecessary overhead for xdr_ni_index using typedef
59 * rpcgen needs an optimizer so we don't have to do this!
60 */
61 #ifdef RPC_HDR
62 %typedef unsigned long ni_index;
63 #endif
64 #define ni_index unsigned long
65
66 struct ni_id {
67 ni_index nii_object;
68 ni_index nii_instance;
69 };
70
71
72 /*
73 * Names are assumed to contain human-readable ASCII characters.
74 */
75 typedef string ni_name<NI_NAME_MAXLEN>;
76
77
78 typedef ni_name ni_namelist<NI_NAMELIST_MAXLEN>;
79
80 /*
81 * A property
82 */
83 struct ni_property {
84 ni_name nip_name;
85 ni_namelist nip_val;
86 };
87
88 /*
89 * A list of properties
90 */
91 typedef ni_property ni_proplist<NI_PROPLIST_MAXLEN>;
92
93 /*
94 * A list of IDs (yet another variable-length array)
95 */
96 typedef ni_index ni_idlist<NI_IDLIST_MAXLEN>;
97
98
99 /*
100 * A name object
101 */
102 struct ni_object {
103 ni_id nio_id;
104 ni_proplist nio_props;
105 ni_index nio_parent;
106 ni_idlist nio_children;
107 };
108
109
110 /*
111 * All operations return a status indicating either that the requested
112 * operation succeeded or why it failed.
113 */
114 enum ni_status {
115 NI_OK, /* Operation succeeded */
116 NI_BADID, /* ID is invalid */
117 NI_STALE, /* Write attempted on stale version of object */
118 NI_NOSPACE, /* No space available for write operation */
119 NI_PERM, /* Permission denied */
120 NI_NODIR, /* No such directory */
121 NI_NOPROP, /* No such property */
122 NI_NONAME, /* No such name */
123 NI_NOTEMPTY, /* Cannot delete name object with children */
124 NI_UNRELATED, /* Object is not child of parent: cannot destroy */
125 NI_SERIAL, /* Serialization error */
126 NI_NETROOT, /* Hit network root domain */
127 NI_NORESPONSE, /* No response from remote parent */
128 NI_RDONLY, /* No writes allowed: all objects are read-only */
129 NI_SYSTEMERR, /* generic remote error */
130 NI_ALIVE, /* Can't regenerate: already in use */
131 NI_NOTMASTER, /* Operation makes no sense on clone */
132 NI_CANTFINDADDRESS, /* Can't find address of server */
133 NI_DUPTAG, /* Duplicate domain tag: can't serve it */
134 NI_NOTAG, /* No such tag */
135 NI_AUTHERROR, /* Authentication error */
136 NI_NOUSER, /* No such user */
137 NI_MASTERBUSY, /* Master server is busy */
138 NI_INVALIDDOMAIN, /* Invalid Domain */
139 NI_BADOP, /* Invalid operation on master */
140 NI_FAILED = 9999 /* generic local error */
141 };
142
143 /*
144 * Wrappers needed to handle arguments and results
145 */
146 union ni_id_res switch (ni_status status) {
147 case NI_OK:
148 ni_id id;
149 default:
150 void;
151 };
152
153 struct ni_parent_stuff {
154 ni_index object_id;
155 ni_id self_id;
156 };
157
158 union ni_parent_res switch (ni_status status) {
159 case NI_OK:
160 struct ni_parent_stuff stuff;
161 default:
162 void;
163 };
164
165 struct ni_children_stuff {
166 ni_idlist children;
167 ni_id self_id;
168 };
169
170 union ni_children_res switch (ni_status status) {
171 case NI_OK:
172 ni_children_stuff stuff;
173 default:
174 void;
175 };
176
177 struct ni_entry {
178 ni_index id;
179 ni_namelist *names;
180 };
181
182 typedef ni_entry ni_entrylist<NI_IDLIST_MAXLEN>;
183
184 struct ni_list_stuff {
185 ni_entrylist entries;
186 ni_id self_id;
187 };
188
189 union ni_list_res switch (ni_status status) {
190 case NI_OK:
191 ni_list_stuff stuff;
192 default:
193 void;
194 };
195
196 struct ni_proplist_stuff {
197 ni_id id;
198 ni_proplist props;
199 };
200
201 struct ni_create_args {
202 ni_id id;
203 ni_proplist props;
204 ni_index where;
205 ni_id *target_id;
206 };
207
208 union ni_proplist_res switch (ni_status status) {
209 case NI_OK:
210 ni_proplist_stuff stuff;
211 default:
212 void;
213 };
214
215 struct ni_create_stuff {
216 ni_id id;
217 ni_id self_id;
218 };
219
220 union ni_create_res switch (ni_status status) {
221 case NI_OK:
222 ni_create_stuff stuff;
223 default:
224 void;
225 };
226
227 struct ni_destroy_args {
228 ni_id parent_id;
229 ni_id self_id;
230 };
231
232 struct ni_lookup_args {
233 ni_id id;
234 ni_name key;
235 ni_name value;
236 };
237
238 struct ni_lookup_stuff {
239 ni_idlist idlist;
240 ni_id self_id;
241 };
242
243 union ni_lookup_res switch (ni_status status) {
244 case NI_OK:
245 ni_lookup_stuff stuff;
246 default:
247 void;
248 };
249
250
251 struct ni_name_args {
252 ni_id id;
253 ni_name name;
254 };
255
256 struct ni_createprop_args {
257 ni_id id;
258 ni_property prop;
259 ni_index where;
260 };
261
262 struct ni_writeprop_args {
263 ni_id id;
264 ni_index prop_index;
265 ni_namelist values;
266 };
267
268 struct ni_prop_args {
269 ni_id id;
270 ni_index prop_index;
271 };
272
273 struct ni_namelist_stuff {
274 ni_namelist values;
275 ni_id self_id;
276 };
277
278 union ni_namelist_res switch (ni_status status) {
279 case NI_OK:
280 ni_namelist_stuff stuff;
281 default:
282 void;
283 };
284
285 struct ni_propname_args {
286 ni_id id;
287 ni_index prop_index;
288 ni_name name;
289 };
290
291 struct ni_createname_args {
292 ni_id id;
293 ni_index prop_index;
294 ni_name name;
295 ni_index where;
296 };
297
298 struct ni_nameindex_args {
299 ni_id id;
300 ni_index prop_index;
301 ni_index name_index;
302 };
303
304 struct ni_writename_args {
305 ni_id id;
306 ni_index prop_index;
307 ni_index name_index;
308 ni_name name;
309 };
310
311 struct ni_readname_stuff {
312 ni_id id;
313 ni_name name;
314 };
315
316 union ni_readname_res switch (ni_status status) {
317 case NI_OK:
318 ni_readname_stuff stuff;
319 default:
320 void;
321 };
322
323 struct ni_binding {
324 ni_name tag;
325 unsigned addr;
326 };
327
328 union ni_rparent_res switch (ni_status status) {
329 case NI_OK:
330 ni_binding binding;
331 default:
332 void;
333 };
334
335 typedef struct ni_object_node *ni_object_list;
336 struct ni_object_node {
337 ni_object object;
338 ni_object_list next;
339 };
340
341 struct ni_readall_stuff {
342 unsigned checksum;
343 ni_index highestid;
344 ni_object_list list;
345 };
346
347 union ni_readall_res switch (ni_status status) {
348 case NI_OK:
349 ni_readall_stuff stuff;
350 default:
351 void;
352 };
353
354 typedef ni_proplist ni_proplist_list<NI_IDLIST_MAXLEN>;
355
356 struct ni_listall_stuff {
357 ni_id self_id;
358 ni_proplist_list entries;
359 };
360
361 union ni_listall_res switch (ni_status status) {
362 case NI_OK:
363 ni_listall_stuff stuff;
364 default:
365 void;
366 };
367
368
369 program NI_PROG {
370 version NI_VERS {
371 void
372 _NI_PING(void) = 0;
373 /*
374 * Get various server statistics
375 */
376 ni_proplist
377 _NI_STATISTICS(void) = 1;
378
379 /*
380 * Procedures dealing with nodes
381 */
382 ni_id_res
383 _NI_ROOT(void) = 2;
384
385 ni_id_res
386 _NI_SELF(ni_id) = 3;
387
388 ni_parent_res
389 _NI_PARENT(ni_id) = 4;
390
391 ni_create_res
392 _NI_CREATE(ni_create_args) = 5;
393
394 ni_id_res
395 _NI_DESTROY(ni_destroy_args) = 6;
396
397 ni_proplist_res
398 _NI_READ(ni_id) = 7;
399
400 ni_id_res
401 _NI_WRITE(ni_proplist_stuff) = 8;
402
403 ni_children_res
404 _NI_CHILDREN(ni_id) = 9;
405
406 ni_lookup_res
407 _NI_LOOKUP(ni_lookup_args) = 10;
408
409 ni_list_res
410 _NI_LIST(ni_name_args) = 11;
411
412 /*
413 * Procedures dealing with properties
414 */
415 ni_id_res
416 _NI_CREATEPROP(ni_createprop_args) = 12;
417
418 ni_id_res
419 _NI_DESTROYPROP(ni_prop_args) = 13;
420
421 ni_namelist_res
422 _NI_READPROP(ni_prop_args) = 14;
423
424 ni_id_res
425 _NI_WRITEPROP(ni_writeprop_args) = 15;
426
427 ni_id_res
428 _NI_RENAMEPROP(ni_propname_args) = 16;
429
430 ni_namelist_res
431 _NI_LISTPROPS(ni_id) = 17;
432
433 /*
434 * Procedures dealing with names
435 */
436 ni_id_res
437 _NI_CREATENAME(ni_createname_args) = 18;
438
439 ni_id_res
440 _NI_DESTROYNAME(ni_nameindex_args) = 19;
441
442 ni_readname_res
443 _NI_READNAME(ni_nameindex_args) = 20;
444
445 ni_id_res
446 _NI_WRITENAME(ni_writename_args) = 21;
447
448 /*
449 * Returns the address of this domain's remote parent
450 */
451 ni_rparent_res
452 _NI_RPARENT(void) = 22;
453
454 /*
455 * List all properties of each subdirectory, not just
456 * just a single named property.
457 *
458 * WARNING: this routine is dangerous and may be
459 * removed from future implementations of the protocol.
460 * While it is good the the network in that there is
461 * less data on it because a lot is done in a single call,
462 * it is bad for the server because it ties it up and locks
463 * others out.
464 */
465 ni_listall_res
466 _NI_LISTALL(ni_id) = 23;
467
468 /*
469 * Answers only if the given binding is served
470 */
471 void
472 _NI_BIND(ni_binding) = 24;
473
474 /*
475 * Read the entire database if the checksum is different
476 * Implemented by master only.
477 */
478 ni_readall_res
479 _NI_READALL(unsigned) = 25;
480
481 /*
482 * Informs server that master has crashed. Hands out
483 * latest checksum.
484 */
485 void
486 _NI_CRASHED(unsigned) = 26;
487
488 /*
489 * If master, force clones to resync.
490 * If clone, resync with master.
491 */
492 ni_status
493 _NI_RESYNC(void) = 27;
494
495
496 /*
497 * Extra procedure added for performance
498 * Terminates on first hit, returns proplist
499 */
500 ni_proplist_res
501 _NI_LOOKUPREAD(ni_lookup_args) = 28;
502 } = 2;
503 } = 200100000;