xref: /freebsd/include/rpc/rpcb_prot.x (revision 069ac184)
1 %/*-
2 % * Copyright (c) 2009, Sun Microsystems, Inc.
3 % * All rights reserved.
4 % *
5 % * Redistribution and use in source and binary forms, with or without
6 % * modification, are permitted provided that the following conditions are met:
7 % * - Redistributions of source code must retain the above copyright notice,
8 % *   this list of conditions and the following disclaimer.
9 % * - Redistributions in binary form must reproduce the above copyright notice,
10 % *   this list of conditions and the following disclaimer in the documentation
11 % *   and/or other materials provided with the distribution.
12 % * - Neither the name of Sun Microsystems, Inc. nor the names of its
13 % *   contributors may be used to endorse or promote products derived
14 % *   from this software without specific prior written permission.
15 % *
16 % * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 % * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 % * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 % * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20 % * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 % * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 % * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 % * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 % * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 % * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 % * POSSIBILITY OF SUCH DAMAGE.
27 % */
28 %/*
29 % * Copyright (c) 1988 by Sun Microsystems, Inc.
30 % */
31 
32 %/* from rpcb_prot.x */
33 
34 #ifdef RPC_HDR
35 %
36 %#ifndef _KERNEL
37 %
38 #endif
39 
40 /*
41  * rpcb_prot.x
42  * rpcbind protocol, versions 3 and 4, in RPC Language
43  */
44 %
45 %/*
46 % * The following procedures are supported by the protocol in version 3:
47 % *
48 % * RPCBPROC_NULL() returns ()
49 % * 	takes nothing, returns nothing
50 % *
51 % * RPCBPROC_SET(rpcb) returns (bool_t)
52 % * 	TRUE is success, FALSE is failure.  Registers the tuple
53 % *	[prog, vers, address, owner, netid].
54 % *	Finds out owner and netid information on its own.
55 % *
56 % * RPCBPROC_UNSET(rpcb) returns (bool_t)
57 % *	TRUE is success, FALSE is failure.  Un-registers tuple
58 % *	[prog, vers, netid].  addresses is ignored.
59 % *	If netid is NULL, unregister all.
60 % *
61 % * RPCBPROC_GETADDR(rpcb) returns (string).
62 % *	0 is failure.  Otherwise returns the universal address where the
63 % *	triple [prog, vers, netid] is registered.  Ignore address and owner.
64 % *
65 % * RPCBPROC_DUMP() RETURNS (rpcblist_ptr)
66 % *	used to dump the entire rpcbind maps
67 % *
68 % * RPCBPROC_CALLIT(rpcb_rmtcallargs)
69 % * 	RETURNS (rpcb_rmtcallres);
70 % * 	Calls the procedure on the remote machine.  If it is not registered,
71 % *	this procedure is quiet; i.e. it does not return error information!!!
72 % *	This routine only passes null authentication parameters.
73 % *	It has no interface to xdr routines for RPCBPROC_CALLIT.
74 % *
75 % * RPCBPROC_GETTIME() returns (int).
76 % *	Gets the remote machines time
77 % *
78 % * RPCBPROC_UADDR2TADDR(strint) RETURNS (struct netbuf)
79 % *	Returns the netbuf address from universal address.
80 % *
81 % * RPCBPROC_TADDR2UADDR(struct netbuf) RETURNS (string)
82 % *	Returns the universal address from netbuf address.
83 % *
84 % * END OF RPCBIND VERSION 3 PROCEDURES
85 % */
86 %/*
87 % * Except for RPCBPROC_CALLIT, the procedures above are carried over to
88 % * rpcbind version 4.  Those below are added or modified for version 4.
89 % * NOTE: RPCBPROC_BCAST HAS THE SAME FUNCTIONALITY AND PROCEDURE NUMBER
90 % * AS RPCBPROC_CALLIT.
91 % *
92 % * RPCBPROC_BCAST(rpcb_rmtcallargs)
93 % * 	RETURNS (rpcb_rmtcallres);
94 % * 	Calls the procedure on the remote machine.  If it is not registered,
95 % *	this procedure IS quiet; i.e. it DOES NOT return error information!!!
96 % *	This routine should be used for broadcasting and nothing else.
97 % *
98 % * RPCBPROC_GETVERSADDR(rpcb) returns (string).
99 % *	0 is failure.  Otherwise returns the universal address where the
100 % *	triple [prog, vers, netid] is registered.  Ignore address and owner.
101 % *	Same as RPCBPROC_GETADDR except that if the given version number
102 % *	is not available, the address is not returned.
103 % *
104 % * RPCBPROC_INDIRECT(rpcb_rmtcallargs)
105 % * 	RETURNS (rpcb_rmtcallres);
106 % * 	Calls the procedure on the remote machine.  If it is not registered,
107 % *	this procedure is NOT quiet; i.e. it DOES return error information!!!
108 % * 	as any normal application would expect.
109 % *
110 % * RPCBPROC_GETADDRLIST(rpcb) returns (rpcb_entry_list_ptr).
111 % *	Same as RPCBPROC_GETADDR except that it returns a list of all the
112 % *	addresses registered for the combination (prog, vers) (for all
113 % *	transports).
114 % *
115 % * RPCBPROC_GETSTAT(void) returns (rpcb_stat_byvers)
116 % *	Returns the statistics about the kind of requests received by rpcbind.
117 % */
118 %
119 %/*
120 % * A mapping of (program, version, network ID) to address
121 % */
122 struct rpcb {
123 	rpcprog_t r_prog;		/* program number */
124 	rpcvers_t r_vers;		/* version number */
125 	string r_netid<>;		/* network id */
126 	string r_addr<>;		/* universal address */
127 	string r_owner<>;		/* owner of this service */
128 };
129 #ifdef RPC_HDR
130 %
131 %typedef rpcb RPCB;
132 %
133 #endif
134 %
135 %/*
136 % * A list of mappings
137 % *
138 % * Below are two definitions for the rpcblist structure.  This is done because
139 % * xdr_rpcblist() is specified to take a struct rpcblist **, rather than a
140 % * struct rpcblist * that rpcgen would produce.  One version of the rpcblist
141 % * structure (actually called rp__list) is used with rpcgen, and the other is
142 % * defined only in the header file for compatibility with the specified
143 % * interface.
144 % */
145 
146 struct rp__list {
147 	rpcb rpcb_map;
148 	struct rp__list *rpcb_next;
149 };
150 
151 typedef rp__list *rpcblist_ptr;		/* results of RPCBPROC_DUMP */
152 
153 #ifdef RPC_HDR
154 %
155 %typedef struct rp__list rpcblist;
156 %typedef struct rp__list RPCBLIST;
157 %
158 %#ifndef __cplusplus
159 %struct rpcblist {
160 %	RPCB rpcb_map;
161 %	struct rpcblist *rpcb_next;
162 %};
163 %#endif
164 %
165 %#ifdef __cplusplus
166 %extern "C" {
167 %#endif
168 %extern  bool_t xdr_rpcblist(XDR *, rpcblist**);
169 %#ifdef	__cplusplus
170 %}
171 %#endif
172 %
173 #endif
174 
175 %
176 %/*
177 % * Arguments of remote calls
178 % */
179 struct rpcb_rmtcallargs {
180 	rpcprog_t prog;			/* program number */
181 	rpcvers_t vers;			/* version number */
182 	rpcproc_t proc;			/* procedure number */
183 	opaque args<>;			/* argument */
184 };
185 #ifdef RPC_HDR
186 %
187 %/*
188 % * Client-side only representation of rpcb_rmtcallargs structure.
189 % *
190 % * The routine that XDRs the rpcb_rmtcallargs structure must deal with the
191 % * opaque arguments in the "args" structure.  xdr_rpcb_rmtcallargs() needs to
192 % * be passed the XDR routine that knows the args' structure.  This routine
193 % * doesn't need to go over-the-wire (and it wouldn't make sense anyway) since
194 % * the application being called already knows the args structure.  So we use a
195 % * different "XDR" structure on the client side, r_rpcb_rmtcallargs, which
196 % * includes the args' XDR routine.
197 % */
198 %struct r_rpcb_rmtcallargs {
199 %	rpcprog_t prog;
200 %	rpcvers_t vers;
201 %	rpcproc_t proc;
202 %	struct {
203 %		u_int args_len;
204 %		char *args_val;
205 %	} args;
206 %	xdrproc_t	xdr_args;	/* encodes args */
207 %};
208 %
209 #endif	/* def RPC_HDR */
210 %
211 %/*
212 % * Results of the remote call
213 % */
214 struct rpcb_rmtcallres {
215 	string addr<>;			/* remote universal address */
216 	opaque results<>;		/* result */
217 };
218 #ifdef RPC_HDR
219 %
220 %/*
221 % * Client-side only representation of rpcb_rmtcallres structure.
222 % */
223 %struct r_rpcb_rmtcallres {
224 %	char *addr;
225 %	struct {
226 %		u_int32_t results_len;
227 %		char *results_val;
228 %	} results;
229 %	xdrproc_t	xdr_res;	/* decodes results */
230 %};
231 #endif /* RPC_HDR */
232 %
233 %/*
234 % * rpcb_entry contains a merged address of a service on a particular
235 % * transport, plus associated netconfig information.  A list of rpcb_entrys
236 % * is returned by RPCBPROC_GETADDRLIST.  See netconfig.h for values used
237 % * in r_nc_* fields.
238 % */
239 struct rpcb_entry {
240 	string		r_maddr<>;	/* merged address of service */
241 	string		r_nc_netid<>;	/* netid field */
242 	unsigned int	r_nc_semantics;	/* semantics of transport */
243 	string		r_nc_protofmly<>; /* protocol family */
244 	string		r_nc_proto<>;	/* protocol name */
245 };
246 %
247 %/*
248 % * A list of addresses supported by a service.
249 % */
250 struct rpcb_entry_list {
251 	rpcb_entry rpcb_entry_map;
252 	struct rpcb_entry_list *rpcb_entry_next;
253 };
254 
255 typedef rpcb_entry_list *rpcb_entry_list_ptr;
256 
257 %
258 %/*
259 % * rpcbind statistics
260 % */
261 %
262 const rpcb_highproc_2 = RPCBPROC_CALLIT;
263 const rpcb_highproc_3 = RPCBPROC_TADDR2UADDR;
264 const rpcb_highproc_4 = RPCBPROC_GETSTAT;
265 
266 const RPCBSTAT_HIGHPROC = 13;	/* # of procs in rpcbind V4 plus one */
267 const RPCBVERS_STAT = 3;	/* provide only for rpcbind V2, V3 and V4 */
268 const RPCBVERS_4_STAT = 2;
269 const RPCBVERS_3_STAT = 1;
270 const RPCBVERS_2_STAT = 0;
271 %
272 %/* Link list of all the stats about getport and getaddr */
273 struct rpcbs_addrlist {
274 	rpcprog_t prog;
275 	rpcvers_t vers;
276 	int success;
277 	int failure;
278 	string netid<>;
279 	struct rpcbs_addrlist *next;
280 };
281 %
282 %/* Link list of all the stats about rmtcall */
283 struct rpcbs_rmtcalllist {
284 	rpcprog_t prog;
285 	rpcvers_t vers;
286 	rpcproc_t proc;
287 	int success;
288 	int failure;
289 	int indirect;	/* whether callit or indirect */
290 	string netid<>;
291 	struct rpcbs_rmtcalllist *next;
292 };
293 
294 typedef int rpcbs_proc[RPCBSTAT_HIGHPROC];
295 typedef rpcbs_addrlist *rpcbs_addrlist_ptr;
296 typedef rpcbs_rmtcalllist *rpcbs_rmtcalllist_ptr;
297 
298 struct rpcb_stat {
299 	rpcbs_proc		info;
300 	int			setinfo;
301 	int			unsetinfo;
302 	rpcbs_addrlist_ptr	addrinfo;
303 	rpcbs_rmtcalllist_ptr	rmtinfo;
304 };
305 %
306 %/*
307 % * One rpcb_stat structure is returned for each version of rpcbind
308 % * being monitored.
309 % */
310 
311 typedef rpcb_stat rpcb_stat_byvers[RPCBVERS_STAT];
312 
313 #ifdef RPC_HDR
314 %
315 %/*
316 % * We don't define netbuf in RPCL, since it would contain structure member
317 % * names that would conflict with the definition of struct netbuf in
318 % * <tiuser.h>.  Instead we merely declare the XDR routine xdr_netbuf() here,
319 % * and implement it ourselves in rpc/rpcb_prot.c.
320 % */
321 %#ifdef __cplusplus
322 %extern "C" bool_t xdr_netbuf(XDR *, struct netbuf *);
323 %
324 %#else /* __STDC__ */
325 %extern  bool_t xdr_netbuf(XDR *, struct netbuf *);
326 %
327 %#endif
328 #endif /* def RPC_HDR */
329 
330 /*
331  * rpcbind procedures
332  */
333 program RPCBPROG {
334 	version RPCBVERS {
335 		bool
336 		RPCBPROC_SET(rpcb) = 1;
337 
338 		bool
339 		RPCBPROC_UNSET(rpcb) = 2;
340 
341 		string
342 		RPCBPROC_GETADDR(rpcb) = 3;
343 
344 		rpcblist_ptr
345 		RPCBPROC_DUMP(void) = 4;
346 
347 		rpcb_rmtcallres
348 		RPCBPROC_CALLIT(rpcb_rmtcallargs) = 5;
349 
350 		unsigned int
351 		RPCBPROC_GETTIME(void) = 6;
352 
353 		struct netbuf
354 		RPCBPROC_UADDR2TADDR(string) = 7;
355 
356 		string
357 		RPCBPROC_TADDR2UADDR(struct netbuf) = 8;
358 	} = 3;
359 
360 	version RPCBVERS4 {
361 		bool
362 		RPCBPROC_SET(rpcb) = 1;
363 
364 		bool
365 		RPCBPROC_UNSET(rpcb) = 2;
366 
367 		string
368 		RPCBPROC_GETADDR(rpcb) = 3;
369 
370 		rpcblist_ptr
371 		RPCBPROC_DUMP(void) = 4;
372 
373 		/*
374 		 * NOTE: RPCBPROC_BCAST has the same functionality as CALLIT;
375 		 * the new name is intended to indicate that this
376 		 * procedure should be used for broadcast RPC, and
377 		 * RPCBPROC_INDIRECT should be used for indirect calls.
378 		 */
379 		rpcb_rmtcallres
380 		RPCBPROC_BCAST(rpcb_rmtcallargs) = RPCBPROC_CALLIT;
381 
382 		unsigned int
383 		RPCBPROC_GETTIME(void) = 6;
384 
385 		struct netbuf
386 		RPCBPROC_UADDR2TADDR(string) = 7;
387 
388 		string
389 		RPCBPROC_TADDR2UADDR(struct netbuf) = 8;
390 
391 		string
392 		RPCBPROC_GETVERSADDR(rpcb) = 9;
393 
394 		rpcb_rmtcallres
395 		RPCBPROC_INDIRECT(rpcb_rmtcallargs) = 10;
396 
397 		rpcb_entry_list_ptr
398 		RPCBPROC_GETADDRLIST(rpcb) = 11;
399 
400 		rpcb_stat_byvers
401 		RPCBPROC_GETSTAT(void) = 12;
402 	} = 4;
403 } = 100000;
404 #ifdef RPC_HDR
405 %
406 %#define	RPCBVERS_3		RPCBVERS
407 %#define	RPCBVERS_4		RPCBVERS4
408 %
409 %#define	_PATH_RPCBINDSOCK	"/var/run/rpcbind.sock"
410 %
411 %#else		/* ndef _KERNEL */
412 %#ifdef __cplusplus
413 %extern "C" {
414 %#endif
415 %
416 %/*
417 % * A mapping of (program, version, network ID) to address
418 % */
419 %struct rpcb {
420 %	rpcprog_t r_prog;		/* program number */
421 %	rpcvers_t r_vers;		/* version number */
422 %	char *r_netid;			/* network id */
423 %	char *r_addr;			/* universal address */
424 %	char *r_owner;			/* owner of the mapping */
425 %};
426 %typedef struct rpcb RPCB;
427 %
428 %/*
429 % * A list of mappings
430 % */
431 %struct rpcblist {
432 %	RPCB rpcb_map;
433 %	struct rpcblist *rpcb_next;
434 %};
435 %typedef struct rpcblist RPCBLIST;
436 %typedef struct rpcblist *rpcblist_ptr;
437 %
438 %/*
439 % * Remote calls arguments
440 % */
441 %struct rpcb_rmtcallargs {
442 %	rpcprog_t prog;			/* program number */
443 %	rpcvers_t vers;			/* version number */
444 %	rpcproc_t proc;			/* procedure number */
445 %	u_int32_t arglen;			/* arg len */
446 %	caddr_t args_ptr;		/* argument */
447 %	xdrproc_t xdr_args;		/* XDR routine for argument */
448 %};
449 %typedef struct rpcb_rmtcallargs rpcb_rmtcallargs;
450 %
451 %/*
452 % * Remote calls results
453 % */
454 %struct rpcb_rmtcallres {
455 %	char *addr_ptr;			/* remote universal address */
456 %	u_int32_t resultslen;		/* results length */
457 %	caddr_t results_ptr;		/* results */
458 %	xdrproc_t xdr_results;		/* XDR routine for result */
459 %};
460 %typedef struct rpcb_rmtcallres rpcb_rmtcallres;
461 %
462 %struct rpcb_entry {
463 %	char *r_maddr;
464 %	char *r_nc_netid;
465 %	unsigned int r_nc_semantics;
466 %	char *r_nc_protofmly;
467 %	char *r_nc_proto;
468 %};
469 %typedef struct rpcb_entry rpcb_entry;
470 %
471 %/*
472 % * A list of addresses supported by a service.
473 % */
474 %
475 %struct rpcb_entry_list {
476 %	rpcb_entry rpcb_entry_map;
477 %	struct rpcb_entry_list *rpcb_entry_next;
478 %};
479 %typedef struct rpcb_entry_list rpcb_entry_list;
480 %
481 %typedef rpcb_entry_list *rpcb_entry_list_ptr;
482 %
483 %/*
484 % * rpcbind statistics
485 % */
486 %
487 %#define	rpcb_highproc_2 RPCBPROC_CALLIT
488 %#define	rpcb_highproc_3 RPCBPROC_TADDR2UADDR
489 %#define	rpcb_highproc_4 RPCBPROC_GETSTAT
490 %#define	RPCBSTAT_HIGHPROC 13
491 %#define	RPCBVERS_STAT 3
492 %#define	RPCBVERS_4_STAT 2
493 %#define	RPCBVERS_3_STAT 1
494 %#define	RPCBVERS_2_STAT 0
495 %
496 %/* Link list of all the stats about getport and getaddr */
497 %
498 %struct rpcbs_addrlist {
499 %	rpcprog_t prog;
500 %	rpcvers_t vers;
501 %	int success;
502 %	int failure;
503 %	char *netid;
504 %	struct rpcbs_addrlist *next;
505 %};
506 %typedef struct rpcbs_addrlist rpcbs_addrlist;
507 %
508 %/* Link list of all the stats about rmtcall */
509 %
510 %struct rpcbs_rmtcalllist {
511 %	rpcprog_t prog;
512 %	rpcvers_t vers;
513 %	rpcproc_t proc;
514 %	int success;
515 %	int failure;
516 %	int indirect;
517 %	char *netid;
518 %	struct rpcbs_rmtcalllist *next;
519 %};
520 %typedef struct rpcbs_rmtcalllist rpcbs_rmtcalllist;
521 %
522 %typedef int rpcbs_proc[RPCBSTAT_HIGHPROC];
523 %
524 %typedef rpcbs_addrlist *rpcbs_addrlist_ptr;
525 %
526 %typedef rpcbs_rmtcalllist *rpcbs_rmtcalllist_ptr;
527 %
528 %struct rpcb_stat {
529 %	rpcbs_proc info;
530 %	int setinfo;
531 %	int unsetinfo;
532 %	rpcbs_addrlist_ptr addrinfo;
533 %	rpcbs_rmtcalllist_ptr rmtinfo;
534 %};
535 %typedef struct rpcb_stat rpcb_stat;
536 %
537 %/*
538 % * One rpcb_stat structure is returned for each version of rpcbind
539 % * being monitored.
540 % */
541 %
542 %typedef rpcb_stat rpcb_stat_byvers[RPCBVERS_STAT];
543 %
544 %#ifdef __cplusplus
545 %}
546 %#endif
547 %
548 %#endif		/* ndef _KERNEL */
549 #endif		/* RPC_HDR */
550