xref: /illumos-gate/usr/src/uts/common/rpc/pmap_prot.x (revision 16b76d3cb933ff92018a2a75594449010192eacb)
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) 1984,1989 by Sun Microsystems, Inc.
24 % */
25 
26 %/* from pmap_prot.x */
27 
28 #ifdef RPC_HDR
29 %
30 %#ifndef _KERNEL
31 %
32 #endif
33 
34 /*
35  * Port Mapper Protocol Specification (in RPC Language)
36  * derived from RFC 1057
37  */
38 
39 %/*
40 % * Protocol for the local binder service, or pmap.
41 % *
42 % * Copyright (C) 1984, Sun Microsystems, Inc.
43 % *
44 % * The following procedures are supported by the protocol:
45 % *
46 % * PMAPPROC_NULL() returns ()
47 % * 	takes nothing, returns nothing
48 % *
49 % * PMAPPROC_SET(struct pmap) returns (bool_t)
50 % * 	TRUE is success, FALSE is failure.  Registers the tuple
51 % *	[prog, vers, prot, port].
52 % *
53 % * PMAPPROC_UNSET(struct pmap) returns (bool_t)
54 % *	TRUE is success, FALSE is failure.  Un-registers pair
55 % *	[prog, vers].  prot and port are ignored.
56 % *
57 % * PMAPPROC_GETPORT(struct pmap) returns (rpcport_t).
58 % *	0 is failure.  Otherwise returns the port number where the pair
59 % *	[prog, vers] is registered.  It may lie!
60 % *
61 % * PMAPPROC_DUMP() RETURNS (struct pmaplist_ptr)
62 % *
63 % * PMAPPROC_CALLIT(unsigned, unsigned, unsigned, string<>)
64 % * 	RETURNS (port, string<>);
65 % * usage: encapsulatedresults = PMAPPROC_CALLIT(prog, vers, proc,
66 % *						encapsulatedargs);
67 % * 	Calls the procedure on the local machine.  If it is not registered,
68 % *	this procedure is quite; ie it does not return error information!!!
69 % *	This procedure only is supported on rpc/udp and calls via
70 % *	rpc/udp.  This routine only passes null authentication parameters.
71 % *	This file has no interface to xdr routines for PMAPPROC_CALLIT.
72 % *
73 % * The service supports remote procedure calls on udp/ip or tcp/ip socket 111.
74 % */
75 %
76 const PMAPPORT = 111;	/* portmapper port number */
77 %
78 %
79 %/*
80 % * A mapping of (program, version, protocol) to port number
81 % */
82 
83 struct pmap {
84 	rpcprog_t pm_prog;
85 	rpcvers_t pm_vers;
86 	rpcprot_t pm_prot;
87 	rpcport_t pm_port;
88 };
89 #ifdef RPC_HDR
90 %
91 %typedef pmap PMAP;
92 %
93 #endif
94 %
95 %/*
96 % * Supported values for the "prot" field
97 % */
98 %
99 const PMAP_IPPROTO_TCP = 6;	/* protocol number for TCP/IP */
100 const PMAP_IPPROTO_UDP = 17;	/* protocol number for UDP/IP */
101 %
102 %
103 %/*
104 % * A list of mappings
105 % *
106 % * Below are two definitions for the pmaplist structure.  This is done because
107 % * xdr_pmaplist() is specified to take a struct pmaplist **, rather than a
108 % * struct pmaplist * that rpcgen would produce.  One version of the pmaplist
109 % * structure (actually called pm__list) is used with rpcgen, and the other is
110 % * defined only in the header file for compatibility with the specified
111 % * interface.
112 % */
113 
114 struct pm__list {
115 	pmap pml_map;
116 	struct pm__list *pml_next;
117 };
118 
119 typedef pm__list *pmaplist_ptr;		/* results of PMAPPROC_DUMP */
120 
121 #ifdef RPC_HDR
122 %
123 %struct pmaplist {
124 %	PMAP pml_map;
125 %	struct pmaplist *pml_next;
126 %};
127 %
128 %typedef struct pmaplist pmaplist;
129 %typedef struct pmaplist PMAPLIST;
130 %
131 %#ifdef __cplusplus
132 %extern "C" {
133 %#endif
134 %#ifdef __STDC__
135 %extern  bool_t xdr_pmaplist(XDR *, pmaplist**);
136 %#else /* K&R C */
137 %bool_t xdr_pmaplist();
138 %#endif
139 %#ifdef	__cplusplus
140 %}
141 %#endif
142 %
143 #endif
144 
145 %
146 %/*
147 % * Arguments to callit
148 % */
149 
150 struct rmtcallargs {
151 	rpcprog_t prog;
152 	rpcvers_t vers;
153 	rpcproc_t proc;
154 	opaque args<>;
155 };
156 #ifdef RPC_HDR
157 %
158 %/*
159 % * Client-side only representation of rmtcallargs structure.
160 % *
161 % * The routine that XDRs the rmtcallargs structure must deal with the
162 % * opaque arguments in the "args" structure.  xdr_rmtcall_args() needs to be
163 % * passed the XDR routine that knows the args' structure.  This routine
164 % * doesn't need to go over-the-wire (and it wouldn't make sense anyway) since
165 % * the application being called knows the args structure already.  So we use a
166 % * different "XDR" structure on the client side, p_rmtcallargs, which includes
167 % * the args' XDR routine.
168 % */
169 %struct p_rmtcallargs {
170 %	rpcprog_t prog;
171 %	rpcvers_t vers;
172 %	rpcproc_t proc;
173 %	struct {
174 %		u_int args_len;
175 %		char *args_val;
176 %	} args;
177 %	xdrproc_t	xdr_args;	/* encodes args */
178 %};
179 %
180 #endif	/* def RPC_HDR */
181 %
182 %
183 %/*
184 % * Results of callit
185 % */
186 
187 struct rmtcallres {
188 	rpcport_t port;
189 	opaque res<>;
190 };
191 #ifdef RPC_HDR
192 %
193 %/*
194 % * Client-side only representation of rmtcallres structure.
195 % */
196 %struct p_rmtcallres {
197 %	rpcport_t port;
198 %	struct {
199 %		u_int res_len;
200 %		char *res_val;
201 %	} res;
202 %	xdrproc_t	xdr_res;	/* decodes res */
203 %};
204 %
205 #endif	/* def RPC_HDR */
206 
207 /*
208  * Port mapper procedures
209  */
210 
211 program PMAPPROG {
212    version PMAPVERS {
213 	void
214 	PMAPPROC_NULL(void)	= 0;
215 
216 	bool
217 	PMAPPROC_SET(pmap)	= 1;
218 
219 	bool
220 	PMAPPROC_UNSET(pmap)	= 2;
221 
222 	rpcport_t
223 	PMAPPROC_GETPORT(pmap)	= 3;
224 
225 	pmaplist_ptr
226 	PMAPPROC_DUMP(void)	= 4;
227 
228 	rmtcallres
229 	PMAPPROC_CALLIT(rmtcallargs)  = 5;
230    } = 2;
231 } = 100000;
232 %
233 #ifdef RPC_HDR
234 %#define	PMAPVERS_PROTO		((rpcvers_t)2)
235 %#define	PMAPVERS_ORIG		((rpcvers_t)1)
236 %
237 %#else		/* ndef _KERNEL */
238 %
239 %#include <rpc/pmap_rmt.h>
240 %
241 %#ifdef __cplusplus
242 %extern "C" {
243 %#endif
244 %
245 %#define	PMAPPORT 111
246 %
247 %struct pmap {
248 %	rpcprog_t pm_prog;
249 %	rpcvers_t pm_vers;
250 %	rpcprot_t pm_prot;
251 %	rpcport_t pm_port;
252 %};
253 %typedef struct pmap PMAP;
254 %#ifdef __STDC__
255 %extern bool_t xdr_pmap (XDR *, struct pmap *);
256 %#else
257 %extern bool_t xdr_pmap ();
258 %#endif
259 %
260 %struct pmaplist {
261 %	struct pmap pml_map;
262 %	struct pmaplist *pml_next;
263 %};
264 %typedef struct pmaplist PMAPLIST;
265 %typedef struct pmaplist *pmaplist_ptr;
266 %
267 %
268 %#ifdef __cplusplus
269 %}
270 %#endif
271 %
272 %#endif		/* ndef _KERNEL */
273 #endif
274 
275