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