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