xref: /illumos-gate/usr/src/uts/common/rpc/rpcb_prot.x (revision 2d6eb4a5e0a47d30189497241345dc5466bb68ab)
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 %#ifndef _KERNEL
32 %
33 #endif
34 
35 /*
36  * rpcb_prot.x
37  * rpcbind protocol, versions 3 and 4, in RPC Language
38  */
39 %
40 %/*
41 % * The following procedures are supported by the protocol in version 3:
42 % *
43 % * RPCBPROC_NULL() returns ()
44 % * 	takes nothing, returns nothing
45 % *
46 % * RPCBPROC_SET(rpcb) returns (bool_t)
47 % * 	TRUE is success, FALSE is failure.  Registers the tuple
48 % *	[prog, vers, address, owner, netid].
49 % *	Finds out owner and netid information on its own.
50 % *
51 % * RPCBPROC_UNSET(rpcb) returns (bool_t)
52 % *	TRUE is success, FALSE is failure.  Un-registers tuple
53 % *	[prog, vers, netid].  addresses is ignored.
54 % *	If netid is NULL, unregister all.
55 % *
56 % * RPCBPROC_GETADDR(rpcb) returns (string).
57 % *	0 is failure.  Otherwise returns the universal address where the
58 % *	triple [prog, vers, netid] is registered.  Ignore address and owner.
59 % *
60 % * RPCBPROC_DUMP() RETURNS (rpcblist_ptr)
61 % *	used to dump the entire rpcbind maps
62 % *
63 % * RPCBPROC_CALLIT(rpcb_rmtcallargs)
64 % * 	RETURNS (rpcb_rmtcallres);
65 % * 	Calls the procedure on the remote machine.  If it is not registered,
66 % *	this procedure is quiet; i.e. it does not return error information!!!
67 % *	This routine only passes null authentication parameters.
68 % *	It has no interface to xdr routines for RPCBPROC_CALLIT.
69 % *
70 % * RPCBPROC_GETTIME() returns (int).
71 % *	Gets the remote machines time
72 % *
73 % * RPCBPROC_UADDR2TADDR(strint) RETURNS (struct netbuf)
74 % *	Returns the netbuf address from universal address.
75 % *
76 % * RPCBPROC_TADDR2UADDR(struct netbuf) RETURNS (string)
77 % *	Returns the universal address from netbuf address.
78 % *
79 % * END OF RPCBIND VERSION 3 PROCEDURES
80 % */
81 %/*
82 % * Except for RPCBPROC_CALLIT, the procedures above are carried over to
83 % * rpcbind version 4.  Those below are added or modified for version 4.
84 % * NOTE: RPCBPROC_BCAST HAS THE SAME FUNCTIONALITY AND PROCEDURE NUMBER
85 % * AS RPCBPROC_CALLIT.
86 % *
87 % * RPCBPROC_BCAST(rpcb_rmtcallargs)
88 % * 	RETURNS (rpcb_rmtcallres);
89 % * 	Calls the procedure on the remote machine.  If it is not registered,
90 % *	this procedure IS quiet; i.e. it DOES NOT return error information!!!
91 % *	This routine should be used for broadcasting and nothing else.
92 % *
93 % * RPCBPROC_GETVERSADDR(rpcb) returns (string).
94 % *	0 is failure.  Otherwise returns the universal address where the
95 % *	triple [prog, vers, netid] is registered.  Ignore address and owner.
96 % *	Same as RPCBPROC_GETADDR except that if the given version number
97 % *	is not available, the address is not returned.
98 % *
99 % * RPCBPROC_INDIRECT(rpcb_rmtcallargs)
100 % * 	RETURNS (rpcb_rmtcallres);
101 % * 	Calls the procedure on the remote machine.  If it is not registered,
102 % *	this procedure is NOT quiet; i.e. it DOES return error information!!!
103 % * 	as any normal application would expect.
104 % *
105 % * RPCBPROC_GETADDRLIST(rpcb) returns (rpcb_entry_list_ptr).
106 % *	Same as RPCBPROC_GETADDR except that it returns a list of all the
107 % *	addresses registered for the combination (prog, vers) (for all
108 % *	transports).
109 % *
110 % * RPCBPROC_GETSTAT(void) returns (rpcb_stat_byvers)
111 % *	Returns the statistics about the kind of requests received by rpcbind.
112 % */
113 %
114 %/*
115 % * A mapping of (program, version, network ID) to address
116 % */
117 struct rpcb {
118 	rpcprog_t r_prog;		/* program number */
119 	rpcvers_t r_vers;		/* version number */
120 	string r_netid<>;		/* network id */
121 	string r_addr<>;		/* universal address */
122 	string r_owner<>;		/* owner of this service */
123 };
124 #ifdef RPC_HDR
125 %
126 %typedef rpcb RPCB;
127 %
128 #endif
129 %
130 %/*
131 % * A list of mappings
132 % *
133 % * Below are two definitions for the rpcblist structure.  This is done because
134 % * xdr_rpcblist() is specified to take a struct rpcblist **, rather than a
135 % * struct rpcblist * that rpcgen would produce.  One version of the rpcblist
136 % * structure (actually called rp__list) is used with rpcgen, and the other is
137 % * defined only in the header file for compatibility with the specified
138 % * interface.
139 % */
140 
141 struct rp__list {
142 	rpcb rpcb_map;
143 	struct rp__list *rpcb_next;
144 };
145 
146 typedef rp__list *rpcblist_ptr;		/* results of RPCBPROC_DUMP */
147 
148 #ifdef RPC_HDR
149 %
150 %typedef struct rp__list rpcblist;
151 %typedef struct rp__list RPCBLIST;
152 %
153 %#ifndef __cplusplus
154 %struct rpcblist {
155 %	RPCB rpcb_map;
156 %	struct rpcblist *rpcb_next;
157 %};
158 %#endif
159 %
160 %#ifdef __cplusplus
161 %extern "C" {
162 %#endif
163 %#ifdef __STDC__
164 %extern  bool_t xdr_rpcblist(XDR *, rpcblist**);
165 %#else /* K&R C */
166 %bool_t xdr_rpcblist();
167 %#endif
168 %#ifdef	__cplusplus
169 %}
170 %#endif
171 %
172 #endif
173 
174 %
175 %/*
176 % * Arguments of remote calls
177 % */
178 struct rpcb_rmtcallargs {
179 	rpcprog_t prog;			/* program number */
180 	rpcvers_t vers;			/* version number */
181 	rpcproc_t proc;			/* procedure number */
182 	opaque args<>;			/* argument */
183 };
184 #ifdef RPC_HDR
185 %
186 %/*
187 % * Client-side only representation of rpcb_rmtcallargs structure.
188 % *
189 % * The routine that XDRs the rpcb_rmtcallargs structure must deal with the
190 % * opaque arguments in the "args" structure.  xdr_rpcb_rmtcallargs() needs to
191 % * be passed the XDR routine that knows the args' structure.  This routine
192 % * doesn't need to go over-the-wire (and it wouldn't make sense anyway) since
193 % * the application being called already knows the args structure.  So we use a
194 % * different "XDR" structure on the client side, r_rpcb_rmtcallargs, which
195 % * includes the args' XDR routine.
196 % */
197 %struct r_rpcb_rmtcallargs {
198 %	rpcprog_t prog;
199 %	rpcvers_t vers;
200 %	rpcproc_t proc;
201 %	struct {
202 %		uint32_t args_len;
203 %		char *args_val;
204 %	} args;
205 %	xdrproc_t	xdr_args;	/* encodes args */
206 %};
207 %
208 #endif	/* def RPC_HDR */
209 %
210 %/*
211 % * Results of the remote call
212 % */
213 struct rpcb_rmtcallres {
214 	string addr<>;			/* remote universal address */
215 	opaque results<>;		/* result */
216 };
217 #ifdef RPC_HDR
218 %
219 %/*
220 % * Client-side only representation of rpcb_rmtcallres structure.
221 % */
222 %struct r_rpcb_rmtcallres {
223 %	char *addr;
224 %	struct {
225 %		uint32_t results_len;
226 %		char *results_val;
227 %	} results;
228 %	xdrproc_t	xdr_res;	/* decodes results */
229 %};
230 #endif RPC_HDR
231 %
232 %/*
233 % * rpcb_entry contains a merged address of a service on a particular
234 % * transport, plus associated netconfig information.  A list of rpcb_entrys
235 % * is returned by RPCBPROC_GETADDRLIST.  See netconfig.h for values used
236 % * in r_nc_* fields.
237 % */
238 struct rpcb_entry {
239 	string		r_maddr<>;	/* merged address of service */
240 	string		r_nc_netid<>;	/* netid field */
241 	unsigned int	r_nc_semantics;	/* semantics of transport */
242 	string		r_nc_protofmly<>; /* protocol family */
243 	string		r_nc_proto<>;	/* protocol name */
244 };
245 %
246 %/*
247 % * A list of addresses supported by a service.
248 % */
249 struct rpcb_entry_list {
250 	rpcb_entry rpcb_entry_map;
251 	struct rpcb_entry_list *rpcb_entry_next;
252 };
253 
254 typedef rpcb_entry_list *rpcb_entry_list_ptr;
255 
256 %
257 %/*
258 % * rpcbind statistics
259 % */
260 %
261 const rpcb_highproc_2 = RPCBPROC_CALLIT;
262 const rpcb_highproc_3 = RPCBPROC_TADDR2UADDR;
263 const rpcb_highproc_4 = RPCBPROC_GETSTAT;
264 
265 const RPCBSTAT_HIGHPROC = 13;	/* # of procs in rpcbind V4 plus one */
266 const RPCBVERS_STAT = 3;	/* provide only for rpcbind V2, V3 and V4 */
267 const RPCBVERS_4_STAT = 2;
268 const RPCBVERS_3_STAT = 1;
269 const RPCBVERS_2_STAT = 0;
270 %
271 %/* Link list of all the stats about getport and getaddr */
272 struct rpcbs_addrlist {
273 	rpcprog_t prog;
274 	rpcvers_t vers;
275 	int success;
276 	int failure;
277 	string netid<>;
278 	struct rpcbs_addrlist *next;
279 };
280 %
281 %/* Link list of all the stats about rmtcall */
282 struct rpcbs_rmtcalllist {
283 	rpcprog_t prog;
284 	rpcvers_t vers;
285 	rpcproc_t proc;
286 	int success;
287 	int failure;
288 	int indirect;	/* whether callit or indirect */
289 	string netid<>;
290 	struct rpcbs_rmtcalllist *next;
291 };
292 
293 typedef int rpcbs_proc[RPCBSTAT_HIGHPROC];
294 typedef rpcbs_addrlist *rpcbs_addrlist_ptr;
295 typedef rpcbs_rmtcalllist *rpcbs_rmtcalllist_ptr;
296 
297 struct rpcb_stat {
298 	rpcbs_proc		info;
299 	int			setinfo;
300 	int			unsetinfo;
301 	rpcbs_addrlist_ptr	addrinfo;
302 	rpcbs_rmtcalllist_ptr	rmtinfo;
303 };
304 %
305 %/*
306 % * One rpcb_stat structure is returned for each version of rpcbind
307 % * being monitored.
308 % */
309 
310 typedef rpcb_stat rpcb_stat_byvers[RPCBVERS_STAT];
311 
312 #ifdef RPC_HDR
313 %
314 %/*
315 % * We don't define netbuf in RPCL, since it would contain structure member
316 % * names that would conflict with the definition of struct netbuf in
317 % * <tiuser.h>.  Instead we merely declare the XDR routine xdr_netbuf() here,
318 % * and implement it ourselves in rpc/rpcb_prot.c.
319 % */
320 %#ifdef __cplusplus
321 %extern "C" bool_t xdr_netbuf(XDR *, struct netbuf *);
322 %
323 %#elif __STDC__
324 %extern  bool_t xdr_netbuf(XDR *, struct netbuf *);
325 %
326 %#else /* K&R C */
327 %bool_t xdr_netbuf();
328 %
329 %#endif /* K&R C */
330 #endif /* def RPC_HDR */
331 
332 /*
333  * rpcbind procedures
334  */
335 program RPCBPROG {
336 	version RPCBVERS {
337 		bool
338 		RPCBPROC_SET(rpcb) = 1;
339 
340 		bool
341 		RPCBPROC_UNSET(rpcb) = 2;
342 
343 		string
344 		RPCBPROC_GETADDR(rpcb) = 3;
345 
346 		rpcblist_ptr
347 		RPCBPROC_DUMP(void) = 4;
348 
349 		rpcb_rmtcallres
350 		RPCBPROC_CALLIT(rpcb_rmtcallargs) = 5;
351 
352 		unsigned int
353 		RPCBPROC_GETTIME(void) = 6;
354 
355 		struct netbuf
356 		RPCBPROC_UADDR2TADDR(string) = 7;
357 
358 		string
359 		RPCBPROC_TADDR2UADDR(struct netbuf) = 8;
360 	} = 3;
361 
362 	version RPCBVERS4 {
363 		bool
364 		RPCBPROC_SET(rpcb) = 1;
365 
366 		bool
367 		RPCBPROC_UNSET(rpcb) = 2;
368 
369 		string
370 		RPCBPROC_GETADDR(rpcb) = 3;
371 
372 		rpcblist_ptr
373 		RPCBPROC_DUMP(void) = 4;
374 
375 		/*
376 		 * NOTE: RPCBPROC_BCAST has the same functionality as CALLIT;
377 		 * the new name is intended to indicate that this
378 		 * procedure should be used for broadcast RPC, and
379 		 * RPCBPROC_INDIRECT should be used for indirect calls.
380 		 */
381 		rpcb_rmtcallres
382 		RPCBPROC_BCAST(rpcb_rmtcallargs) = RPCBPROC_CALLIT;
383 
384 		unsigned int
385 		RPCBPROC_GETTIME(void) = 6;
386 
387 		struct netbuf
388 		RPCBPROC_UADDR2TADDR(string) = 7;
389 
390 		string
391 		RPCBPROC_TADDR2UADDR(struct netbuf) = 8;
392 
393 		string
394 		RPCBPROC_GETVERSADDR(rpcb) = 9;
395 
396 		rpcb_rmtcallres
397 		RPCBPROC_INDIRECT(rpcb_rmtcallargs) = 10;
398 
399 		rpcb_entry_list_ptr
400 		RPCBPROC_GETADDRLIST(rpcb) = 11;
401 
402 		rpcb_stat_byvers
403 		RPCBPROC_GETSTAT(void) = 12;
404 	} = 4;
405 } = 100000;
406 #ifdef RPC_HDR
407 %
408 %#define	RPCBVERS_3		RPCBVERS
409 %#define	RPCBVERS_4		RPCBVERS4
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 %	unsigned int  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 %	uint32_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 %extern  bool_t xdr_netbuf(XDR *, struct netbuf *);
545 %
546 %#ifdef __cplusplus
547 %}
548 %#endif
549 %
550 %#endif		/* ndef _KERNEL */
551 #endif		/* RPC_HDR */
552