xref: /freebsd/include/rpcsvc/pmap_prot.x (revision 9524e274b5484ac8b43bacd90d4029183ccf6476)
1 %/*
2 % * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
3 % * unrestricted use provided that this legend is included on all tape
4 % * media and as a part of the software program in whole or part.  Users
5 % * may copy or modify Sun RPC without charge, but are not authorized
6 % * to license or distribute it to anyone else except as part of a product or
7 % * program developed by the user.
8 % *
9 % * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
10 % * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
11 % * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
12 % *
13 % * Sun RPC is provided with no support and without any obligation on the
14 % * part of Sun Microsystems, Inc. to assist in its use, correction,
15 % * modification or enhancement.
16 % *
17 % * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
18 % * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
19 % * OR ANY PART THEREOF.
20 % *
21 % * In no event will Sun Microsystems, Inc. be liable for any lost revenue
22 % * or profits or other special, indirect and consequential damages, even if
23 % * Sun has been advised of the possibility of such damages.
24 % *
25 % * Sun Microsystems, Inc.
26 % * 2550 Garcia Avenue
27 % * Mountain View, California  94043
28 % */
29 %/*
30 % * Copyright (c) 1984,1989 by Sun Microsystems, Inc.
31 % */
32 
33 %/* from pmap_prot.x */
34 
35 #ifdef RPC_HDR
36 %
37 %#pragma ident	"@(#)pmap_prot.x	1.6	94/04/29 SMI"
38 %#include <sys/cdefs.h>
39 %
40 %#ifndef _KERNEL
41 %
42 #endif
43 
44 /*
45  * Port Mapper Protocol Specification (in RPC Language)
46  * derived from RFC 1057
47  */
48 
49 %/*
50 % * Protocol for the local binder service, or pmap.
51 % *
52 % * Copyright (C) 1984, Sun Microsystems, Inc.
53 % *
54 % * The following procedures are supported by the protocol:
55 % *
56 % * PMAPPROC_NULL() returns ()
57 % * 	takes nothing, returns nothing
58 % *
59 % * PMAPPROC_SET(struct pmap) returns (bool_t)
60 % * 	TRUE is success, FALSE is failure.  Registers the tuple
61 % *	[prog, vers, prot, port].
62 % *
63 % * PMAPPROC_UNSET(struct pmap) returns (bool_t)
64 % *	TRUE is success, FALSE is failure.  Un-registers pair
65 % *	[prog, vers].  prot and port are ignored.
66 % *
67 % * PMAPPROC_GETPORT(struct pmap) returns (long unsigned).
68 % *	0 is failure.  Otherwise returns the port number where the pair
69 % *	[prog, vers] is registered.  It may lie!
70 % *
71 % * PMAPPROC_DUMP() RETURNS (struct pmaplist_ptr)
72 % *
73 % * PMAPPROC_CALLIT(unsigned, unsigned, unsigned, string<>)
74 % * 	RETURNS (port, string<>);
75 % * usage: encapsulatedresults = PMAPPROC_CALLIT(prog, vers, proc,
76 % *						encapsulatedargs);
77 % * 	Calls the procedure on the local machine.  If it is not registered,
78 % *	this procedure is quite; ie it does not return error information!!!
79 % *	This procedure only is supported on rpc/udp and calls via
80 % *	rpc/udp.  This routine only passes null authentication parameters.
81 % *	This file has no interface to xdr routines for PMAPPROC_CALLIT.
82 % *
83 % * The service supports remote procedure calls on udp/ip or tcp/ip socket 111.
84 % */
85 %
86 const PMAPPORT = 111;	/* portmapper port number */
87 %
88 %
89 %/*
90 % * A mapping of (program, version, protocol) to port number
91 % */
92 
93 struct pmap {
94 	unsigned long pm_prog;
95 	unsigned long pm_vers;
96 	unsigned long pm_prot;
97 	unsigned long pm_port;
98 };
99 #ifdef RPC_HDR
100 %
101 %typedef pmap PMAP;
102 %
103 #endif
104 %
105 %/*
106 % * Supported values for the "prot" field
107 % */
108 %
109 const PMAP_IPPROTO_TCP = 6;	/* protocol number for TCP/IP */
110 const PMAP_IPPROTO_UDP = 17;	/* protocol number for UDP/IP */
111 %
112 %
113 %/*
114 % * A list of mappings
115 % *
116 % * Below are two definitions for the pmaplist structure.  This is done because
117 % * xdr_pmaplist() is specified to take a struct pmaplist **, rather than a
118 % * struct pmaplist * that rpcgen would produce.  One version of the pmaplist
119 % * structure (actually called pm__list) is used with rpcgen, and the other is
120 % * defined only in the header file for compatibility with the specified
121 % * interface.
122 % */
123 
124 struct pm__list {
125 	pmap pml_map;
126 	struct pm__list *pml_next;
127 };
128 
129 typedef pm__list *pmaplist_ptr;		/* results of PMAPPROC_DUMP */
130 
131 #ifdef RPC_HDR
132 %
133 %typedef struct pm__list pmaplist;
134 %typedef struct pm__list PMAPLIST;
135 %
136 %#ifndef __cplusplus
137 %struct pmaplist {
138 %	PMAP pml_map;
139 %	struct pmaplist *pml_next;
140 %};
141 %#endif
142 %
143 %#ifdef __cplusplus
144 %extern "C" {
145 %#endif
146 %extern  bool_t xdr_pmaplist(XDR *, pmaplist**);
147 %#ifdef	__cplusplus
148 %}
149 %#endif
150 %
151 #endif
152 
153 %
154 %/*
155 % * Arguments to callit
156 % */
157 
158 struct rmtcallargs {
159 	unsigned long prog;
160 	unsigned long vers;
161 	unsigned long proc;
162 	opaque args<>;
163 };
164 #ifdef RPC_HDR
165 %
166 %/*
167 % * Client-side only representation of rmtcallargs structure.
168 % *
169 % * The routine that XDRs the rmtcallargs structure must deal with the
170 % * opaque arguments in the "args" structure.  xdr_rmtcall_args() needs to be
171 % * passed the XDR routine that knows the args' structure.  This routine
172 % * doesn't need to go over-the-wire (and it wouldn't make sense anyway) since
173 % * the application being called knows the args structure already.  So we use a
174 % * different "XDR" structure on the client side, p_rmtcallargs, which includes
175 % * the args' XDR routine.
176 % */
177 %struct p_rmtcallargs {
178 %	u_long prog;
179 %	u_long vers;
180 %	u_long proc;
181 %	struct {
182 %		u_int args_len;
183 %		char *args_val;
184 %	} args;
185 %	xdrproc_t	xdr_args;	/* encodes args */
186 %};
187 %
188 #endif	/* def RPC_HDR */
189 %
190 %
191 %/*
192 % * Results of callit
193 % */
194 
195 struct rmtcallres {
196 	unsigned long port;
197 	opaque res<>;
198 };
199 #ifdef RPC_HDR
200 %
201 %/*
202 % * Client-side only representation of rmtcallres structure.
203 % */
204 %struct p_rmtcallres {
205 %	u_long port;
206 %	struct {
207 %		u_int res_len;
208 %		char *res_val;
209 %	} res;
210 %	xdrproc_t	xdr_res;	/* decodes res */
211 %};
212 %
213 #endif	/* def RPC_HDR */
214 
215 /*
216  * Port mapper procedures
217  */
218 
219 program PMAPPROG {
220    version PMAPVERS {
221 	void
222 	PMAPPROC_NULL(void)	= 0;
223 
224 	bool
225 	PMAPPROC_SET(pmap)	= 1;
226 
227 	bool
228 	PMAPPROC_UNSET(pmap)	= 2;
229 
230 	unsigned long
231 	PMAPPROC_GETPORT(pmap)	= 3;
232 
233 	pmaplist_ptr
234 	PMAPPROC_DUMP(void)	= 4;
235 
236 	rmtcallres
237 	PMAPPROC_CALLIT(rmtcallargs)  = 5;
238    } = 2;
239 } = 100000;
240 %
241 #ifdef RPC_HDR
242 %#define PMAPVERS_PROTO		((u_long)2)
243 %#define PMAPVERS_ORIG		((u_long)1)
244 %
245 %#else		/* ndef _KERNEL */
246 %
247 %#include <rpc/pmap_rmt.h>
248 %
249 %#ifdef __cplusplus
250 %extern "C" {
251 %#endif
252 %
253 %#define	PMAPPORT 111
254 %
255 %struct pmap {
256 %	long unsigned pm_prog;
257 %	long unsigned pm_vers;
258 %	long unsigned pm_prot;
259 %	long unsigned pm_port;
260 %};
261 %typedef struct pmap PMAP;
262 %extern bool_t xdr_pmap (XDR *, struct pmap *);
263 %
264 %struct pmaplist {
265 %	struct pmap pml_map;
266 %	struct pmaplist *pml_next;
267 %};
268 %typedef struct pmaplist PMAPLIST;
269 %typedef struct pmaplist *pmaplist_ptr;
270 %
271 %
272 %#ifdef __cplusplus
273 %}
274 %#endif
275 %
276 %#endif		/* ndef _KERNEL */
277 #endif
278 
279