rpc_soc.c revision 1.13.8.1 1 1.13.8.1 riz /* $NetBSD: rpc_soc.c,v 1.13.8.1 2013/03/14 22:03:15 riz Exp $ */
2 1.1 fvdl
3 1.1 fvdl /*
4 1.13.8.1 riz * Copyright (c) 2010, Oracle America, Inc.
5 1.13.8.1 riz *
6 1.13.8.1 riz * Redistribution and use in source and binary forms, with or without
7 1.13.8.1 riz * modification, are permitted provided that the following conditions are
8 1.13.8.1 riz * met:
9 1.13.8.1 riz *
10 1.13.8.1 riz * * Redistributions of source code must retain the above copyright
11 1.13.8.1 riz * notice, this list of conditions and the following disclaimer.
12 1.13.8.1 riz * * Redistributions in binary form must reproduce the above
13 1.13.8.1 riz * copyright notice, this list of conditions and the following
14 1.13.8.1 riz * disclaimer in the documentation and/or other materials
15 1.13.8.1 riz * provided with the distribution.
16 1.13.8.1 riz * * Neither the name of the "Oracle America, Inc." nor the names of its
17 1.13.8.1 riz * contributors may be used to endorse or promote products derived
18 1.13.8.1 riz * from this software without specific prior written permission.
19 1.13.8.1 riz *
20 1.13.8.1 riz * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 1.13.8.1 riz * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 1.13.8.1 riz * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 1.13.8.1 riz * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 1.13.8.1 riz * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
25 1.13.8.1 riz * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 1.13.8.1 riz * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
27 1.13.8.1 riz * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 1.13.8.1 riz * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 1.13.8.1 riz * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 1.13.8.1 riz * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 1.13.8.1 riz * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 1.1 fvdl */
33 1.1 fvdl
34 1.1 fvdl /* #ident "@(#)rpc_soc.c 1.17 94/04/24 SMI" */
35 1.1 fvdl
36 1.1 fvdl /*
37 1.1 fvdl * Copyright (c) 1986-1991 by Sun Microsystems Inc.
38 1.1 fvdl * In addition, portions of such source code were derived from Berkeley
39 1.1 fvdl * 4.3 BSD under license from the Regents of the University of
40 1.1 fvdl * California.
41 1.1 fvdl */
42 1.1 fvdl
43 1.11 itojun #include <sys/cdefs.h>
44 1.11 itojun #if defined(LIBC_SCCS) && !defined(lint)
45 1.1 fvdl #if 0
46 1.1 fvdl static char sccsid[] = "@(#)rpc_soc.c 1.41 89/05/02 Copyr 1988 Sun Micro";
47 1.11 itojun #else
48 1.13.8.1 riz __RCSID("$NetBSD: rpc_soc.c,v 1.13.8.1 2013/03/14 22:03:15 riz Exp $");
49 1.1 fvdl #endif
50 1.1 fvdl #endif
51 1.1 fvdl
52 1.1 fvdl #ifdef PORTMAP
53 1.1 fvdl /*
54 1.1 fvdl * rpc_soc.c
55 1.1 fvdl *
56 1.1 fvdl * The backward compatibility routines for the earlier implementation
57 1.1 fvdl * of RPC, where the only transports supported were tcp/ip and udp/ip.
58 1.1 fvdl * Based on berkeley socket abstraction, now implemented on the top
59 1.1 fvdl * of TLI/Streams
60 1.1 fvdl */
61 1.1 fvdl
62 1.1 fvdl #include "namespace.h"
63 1.1 fvdl #include "reentrant.h"
64 1.1 fvdl #include <sys/types.h>
65 1.1 fvdl #include <sys/socket.h>
66 1.1 fvdl #include <stdio.h>
67 1.1 fvdl #include <rpc/rpc.h>
68 1.1 fvdl #include <rpc/pmap_clnt.h>
69 1.1 fvdl #include <rpc/pmap_prot.h>
70 1.6 christos #include <rpc/nettype.h>
71 1.1 fvdl #include <netinet/in.h>
72 1.7 lukem #include <assert.h>
73 1.7 lukem #include <errno.h>
74 1.1 fvdl #include <netdb.h>
75 1.1 fvdl #include <stdlib.h>
76 1.4 thorpej #include <string.h>
77 1.7 lukem #include <syslog.h>
78 1.1 fvdl #include <unistd.h>
79 1.1 fvdl
80 1.9 fvdl #include "rpc_internal.h"
81 1.1 fvdl
82 1.1 fvdl #ifdef __weak_alias
83 1.1 fvdl __weak_alias(clntudp_bufcreate,_clntudp_bufcreate)
84 1.1 fvdl __weak_alias(clntudp_create,_clntudp_create)
85 1.1 fvdl __weak_alias(clnttcp_create,_clnttcp_create)
86 1.1 fvdl __weak_alias(clntraw_create,_clntraw_create)
87 1.1 fvdl __weak_alias(get_myaddress,_get_myaddress)
88 1.3 fvdl __weak_alias(svcfd_create,_svcfd_create)
89 1.2 fvdl __weak_alias(svcudp_bufcreate,_svcudp_bufcreate)
90 1.1 fvdl __weak_alias(svcudp_create,_svcudp_create)
91 1.1 fvdl __weak_alias(svctcp_create,_svctcp_create)
92 1.1 fvdl __weak_alias(svcraw_create,_svcraw_create)
93 1.1 fvdl __weak_alias(callrpc,_callrpc)
94 1.1 fvdl __weak_alias(registerrpc,_registerrpc)
95 1.1 fvdl __weak_alias(clnt_broadcast,_clnt_broadcast)
96 1.1 fvdl #endif
97 1.1 fvdl
98 1.10 thorpej #ifdef _REENTRANT
99 1.1 fvdl extern mutex_t rpcsoc_lock;
100 1.1 fvdl #endif
101 1.1 fvdl
102 1.1 fvdl static CLIENT *clnt_com_create __P((struct sockaddr_in *, rpcprog_t, rpcvers_t,
103 1.12 christos int *, u_int, u_int, const char *));
104 1.12 christos static SVCXPRT *svc_com_create __P((int, u_int, u_int, const char *));
105 1.1 fvdl static bool_t rpc_wrap_bcast __P((char *, struct netbuf *, struct netconfig *));
106 1.1 fvdl
107 1.1 fvdl /*
108 1.1 fvdl * A common clnt create routine
109 1.1 fvdl */
110 1.1 fvdl static CLIENT *
111 1.1 fvdl clnt_com_create(raddr, prog, vers, sockp, sendsz, recvsz, tp)
112 1.1 fvdl struct sockaddr_in *raddr;
113 1.1 fvdl rpcprog_t prog;
114 1.1 fvdl rpcvers_t vers;
115 1.1 fvdl int *sockp;
116 1.1 fvdl u_int sendsz;
117 1.1 fvdl u_int recvsz;
118 1.12 christos const char *tp;
119 1.1 fvdl {
120 1.1 fvdl CLIENT *cl;
121 1.1 fvdl int madefd = FALSE;
122 1.7 lukem int fd;
123 1.1 fvdl struct netconfig *nconf;
124 1.1 fvdl struct netbuf bindaddr;
125 1.1 fvdl
126 1.7 lukem _DIAGASSERT(raddr != NULL);
127 1.7 lukem _DIAGASSERT(sockp != NULL);
128 1.7 lukem _DIAGASSERT(tp != NULL);
129 1.7 lukem
130 1.7 lukem fd = *sockp;
131 1.7 lukem
132 1.1 fvdl mutex_lock(&rpcsoc_lock);
133 1.1 fvdl if ((nconf = __rpc_getconfip(tp)) == NULL) {
134 1.1 fvdl rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
135 1.1 fvdl mutex_unlock(&rpcsoc_lock);
136 1.6 christos return (NULL);
137 1.1 fvdl }
138 1.1 fvdl if (fd == RPC_ANYSOCK) {
139 1.1 fvdl fd = __rpc_nconf2fd(nconf);
140 1.1 fvdl if (fd == -1)
141 1.1 fvdl goto syserror;
142 1.1 fvdl madefd = TRUE;
143 1.1 fvdl }
144 1.1 fvdl
145 1.1 fvdl if (raddr->sin_port == 0) {
146 1.1 fvdl u_int proto;
147 1.1 fvdl u_short sport;
148 1.1 fvdl
149 1.1 fvdl mutex_unlock(&rpcsoc_lock); /* pmap_getport is recursive */
150 1.1 fvdl proto = strcmp(tp, "udp") == 0 ? IPPROTO_UDP : IPPROTO_TCP;
151 1.6 christos sport = pmap_getport(raddr, (u_long)prog, (u_long)vers,
152 1.6 christos proto);
153 1.1 fvdl if (sport == 0) {
154 1.1 fvdl goto err;
155 1.1 fvdl }
156 1.1 fvdl raddr->sin_port = htons(sport);
157 1.1 fvdl mutex_lock(&rpcsoc_lock); /* pmap_getport is recursive */
158 1.1 fvdl }
159 1.1 fvdl
160 1.1 fvdl /* Transform sockaddr_in to netbuf */
161 1.1 fvdl bindaddr.maxlen = bindaddr.len = sizeof (struct sockaddr_in);
162 1.1 fvdl bindaddr.buf = raddr;
163 1.1 fvdl
164 1.1 fvdl bindresvport(fd, NULL);
165 1.1 fvdl cl = clnt_tli_create(fd, nconf, &bindaddr, prog, vers,
166 1.1 fvdl sendsz, recvsz);
167 1.1 fvdl if (cl) {
168 1.1 fvdl if (madefd == TRUE) {
169 1.1 fvdl /*
170 1.1 fvdl * The fd should be closed while destroying the handle.
171 1.1 fvdl */
172 1.6 christos (void) CLNT_CONTROL(cl, CLSET_FD_CLOSE, NULL);
173 1.1 fvdl *sockp = fd;
174 1.1 fvdl }
175 1.1 fvdl (void) freenetconfigent(nconf);
176 1.1 fvdl mutex_unlock(&rpcsoc_lock);
177 1.1 fvdl return (cl);
178 1.1 fvdl }
179 1.1 fvdl goto err;
180 1.1 fvdl
181 1.1 fvdl syserror:
182 1.1 fvdl rpc_createerr.cf_stat = RPC_SYSTEMERROR;
183 1.1 fvdl rpc_createerr.cf_error.re_errno = errno;
184 1.1 fvdl
185 1.1 fvdl err: if (madefd == TRUE)
186 1.1 fvdl (void) close(fd);
187 1.1 fvdl (void) freenetconfigent(nconf);
188 1.1 fvdl mutex_unlock(&rpcsoc_lock);
189 1.6 christos return (NULL);
190 1.1 fvdl }
191 1.1 fvdl
192 1.1 fvdl CLIENT *
193 1.1 fvdl clntudp_bufcreate(raddr, prog, vers, wait, sockp, sendsz, recvsz)
194 1.6 christos struct sockaddr_in *raddr;
195 1.1 fvdl u_long prog;
196 1.1 fvdl u_long vers;
197 1.1 fvdl struct timeval wait;
198 1.1 fvdl int *sockp;
199 1.1 fvdl u_int sendsz;
200 1.1 fvdl u_int recvsz;
201 1.1 fvdl {
202 1.1 fvdl CLIENT *cl;
203 1.1 fvdl
204 1.7 lukem _DIAGASSERT(raddr != NULL);
205 1.7 lukem _DIAGASSERT(sockp != NULL);
206 1.7 lukem
207 1.6 christos cl = clnt_com_create(raddr, (rpcprog_t)prog, (rpcvers_t)vers, sockp,
208 1.6 christos sendsz, recvsz, "udp");
209 1.6 christos if (cl == NULL) {
210 1.6 christos return (NULL);
211 1.1 fvdl }
212 1.6 christos (void) CLNT_CONTROL(cl, CLSET_RETRY_TIMEOUT, (char *)(void *)&wait);
213 1.1 fvdl return (cl);
214 1.1 fvdl }
215 1.1 fvdl
216 1.1 fvdl CLIENT *
217 1.1 fvdl clntudp_create(raddr, program, version, wait, sockp)
218 1.1 fvdl struct sockaddr_in *raddr;
219 1.1 fvdl u_long program;
220 1.1 fvdl u_long version;
221 1.1 fvdl struct timeval wait;
222 1.1 fvdl int *sockp;
223 1.1 fvdl {
224 1.1 fvdl return clntudp_bufcreate(raddr, program, version, wait, sockp,
225 1.1 fvdl UDPMSGSIZE, UDPMSGSIZE);
226 1.1 fvdl }
227 1.1 fvdl
228 1.1 fvdl CLIENT *
229 1.1 fvdl clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
230 1.1 fvdl struct sockaddr_in *raddr;
231 1.1 fvdl u_long prog;
232 1.1 fvdl u_long vers;
233 1.6 christos int *sockp;
234 1.1 fvdl u_int sendsz;
235 1.1 fvdl u_int recvsz;
236 1.1 fvdl {
237 1.6 christos return clnt_com_create(raddr, (rpcprog_t)prog, (rpcvers_t)vers, sockp,
238 1.6 christos sendsz, recvsz, "tcp");
239 1.1 fvdl }
240 1.1 fvdl
241 1.1 fvdl CLIENT *
242 1.1 fvdl clntraw_create(prog, vers)
243 1.1 fvdl u_long prog;
244 1.1 fvdl u_long vers;
245 1.1 fvdl {
246 1.6 christos return clnt_raw_create((rpcprog_t)prog, (rpcvers_t)vers);
247 1.1 fvdl }
248 1.1 fvdl
249 1.1 fvdl /*
250 1.1 fvdl * A common server create routine
251 1.1 fvdl */
252 1.1 fvdl static SVCXPRT *
253 1.1 fvdl svc_com_create(fd, sendsize, recvsize, netid)
254 1.6 christos int fd;
255 1.1 fvdl u_int sendsize;
256 1.1 fvdl u_int recvsize;
257 1.12 christos const char *netid;
258 1.1 fvdl {
259 1.1 fvdl struct netconfig *nconf;
260 1.1 fvdl SVCXPRT *svc;
261 1.1 fvdl int madefd = FALSE;
262 1.1 fvdl int port;
263 1.8 lukem struct sockaddr_in sccsin;
264 1.1 fvdl
265 1.7 lukem _DIAGASSERT(netid != NULL);
266 1.7 lukem
267 1.1 fvdl if ((nconf = __rpc_getconfip(netid)) == NULL) {
268 1.1 fvdl (void) syslog(LOG_ERR, "Could not get %s transport", netid);
269 1.6 christos return (NULL);
270 1.1 fvdl }
271 1.1 fvdl if (fd == RPC_ANYSOCK) {
272 1.1 fvdl fd = __rpc_nconf2fd(nconf);
273 1.1 fvdl if (fd == -1) {
274 1.1 fvdl (void) freenetconfigent(nconf);
275 1.1 fvdl (void) syslog(LOG_ERR,
276 1.1 fvdl "svc%s_create: could not open connection", netid);
277 1.6 christos return (NULL);
278 1.1 fvdl }
279 1.1 fvdl madefd = TRUE;
280 1.1 fvdl }
281 1.1 fvdl
282 1.8 lukem memset(&sccsin, 0, sizeof sccsin);
283 1.8 lukem sccsin.sin_family = AF_INET;
284 1.8 lukem bindresvport(fd, &sccsin);
285 1.5 fvdl listen(fd, SOMAXCONN);
286 1.6 christos svc = svc_tli_create(fd, nconf, NULL, sendsize, recvsize);
287 1.1 fvdl (void) freenetconfigent(nconf);
288 1.6 christos if (svc == NULL) {
289 1.1 fvdl if (madefd)
290 1.1 fvdl (void) close(fd);
291 1.6 christos return (NULL);
292 1.1 fvdl }
293 1.1 fvdl port = (((struct sockaddr_in *)svc->xp_ltaddr.buf)->sin_port);
294 1.1 fvdl svc->xp_port = ntohs(port);
295 1.1 fvdl return (svc);
296 1.1 fvdl }
297 1.1 fvdl
298 1.1 fvdl SVCXPRT *
299 1.1 fvdl svctcp_create(fd, sendsize, recvsize)
300 1.6 christos int fd;
301 1.1 fvdl u_int sendsize;
302 1.1 fvdl u_int recvsize;
303 1.1 fvdl {
304 1.1 fvdl return svc_com_create(fd, sendsize, recvsize, "tcp");
305 1.1 fvdl }
306 1.1 fvdl
307 1.1 fvdl SVCXPRT *
308 1.1 fvdl svcudp_bufcreate(fd, sendsz, recvsz)
309 1.6 christos int fd;
310 1.1 fvdl u_int sendsz, recvsz;
311 1.1 fvdl {
312 1.1 fvdl return svc_com_create(fd, sendsz, recvsz, "udp");
313 1.1 fvdl }
314 1.1 fvdl
315 1.1 fvdl SVCXPRT *
316 1.1 fvdl svcfd_create(fd, sendsize, recvsize)
317 1.1 fvdl int fd;
318 1.1 fvdl u_int sendsize;
319 1.1 fvdl u_int recvsize;
320 1.1 fvdl {
321 1.1 fvdl return svc_fd_create(fd, sendsize, recvsize);
322 1.1 fvdl }
323 1.1 fvdl
324 1.1 fvdl
325 1.1 fvdl SVCXPRT *
326 1.1 fvdl svcudp_create(fd)
327 1.6 christos int fd;
328 1.1 fvdl {
329 1.1 fvdl return svc_com_create(fd, UDPMSGSIZE, UDPMSGSIZE, "udp");
330 1.1 fvdl }
331 1.1 fvdl
332 1.1 fvdl SVCXPRT *
333 1.1 fvdl svcraw_create()
334 1.1 fvdl {
335 1.1 fvdl return svc_raw_create();
336 1.1 fvdl }
337 1.1 fvdl
338 1.1 fvdl int
339 1.1 fvdl get_myaddress(addr)
340 1.1 fvdl struct sockaddr_in *addr;
341 1.1 fvdl {
342 1.7 lukem
343 1.7 lukem _DIAGASSERT(addr != NULL);
344 1.7 lukem
345 1.1 fvdl memset((void *) addr, 0, sizeof(*addr));
346 1.1 fvdl addr->sin_family = AF_INET;
347 1.1 fvdl addr->sin_port = htons(PMAPPORT);
348 1.1 fvdl addr->sin_addr.s_addr = htonl(INADDR_LOOPBACK);
349 1.1 fvdl return (0);
350 1.1 fvdl }
351 1.1 fvdl
352 1.1 fvdl /*
353 1.1 fvdl * For connectionless "udp" transport. Obsoleted by rpc_call().
354 1.1 fvdl */
355 1.1 fvdl int
356 1.1 fvdl callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out)
357 1.1 fvdl char *host;
358 1.1 fvdl int prognum, versnum, procnum;
359 1.1 fvdl xdrproc_t inproc, outproc;
360 1.1 fvdl char *in, *out;
361 1.1 fvdl {
362 1.6 christos return (int)rpc_call(host, (rpcprog_t)prognum, (rpcvers_t)versnum,
363 1.6 christos (rpcproc_t)procnum, inproc, in, outproc, out, "udp");
364 1.1 fvdl }
365 1.1 fvdl
366 1.1 fvdl /*
367 1.1 fvdl * For connectionless kind of transport. Obsoleted by rpc_reg()
368 1.1 fvdl */
369 1.1 fvdl int
370 1.1 fvdl registerrpc(prognum, versnum, procnum, progname, inproc, outproc)
371 1.1 fvdl int prognum, versnum, procnum;
372 1.1 fvdl char *(*progname) __P((char [UDPMSGSIZE]));
373 1.1 fvdl xdrproc_t inproc, outproc;
374 1.1 fvdl {
375 1.6 christos return rpc_reg((rpcprog_t)prognum, (rpcvers_t)versnum,
376 1.12 christos (rpcproc_t)procnum, progname, inproc, outproc, __UNCONST("udp"));
377 1.1 fvdl }
378 1.1 fvdl
379 1.1 fvdl /*
380 1.1 fvdl * All the following clnt_broadcast stuff is convulated; it supports
381 1.1 fvdl * the earlier calling style of the callback function
382 1.1 fvdl */
383 1.10 thorpej #ifdef _REENTRANT
384 1.1 fvdl static thread_key_t clnt_broadcast_key;
385 1.1 fvdl #endif
386 1.1 fvdl static resultproc_t clnt_broadcast_result_main;
387 1.1 fvdl
388 1.1 fvdl /*
389 1.1 fvdl * Need to translate the netbuf address into sockaddr_in address.
390 1.1 fvdl * Dont care about netid here.
391 1.1 fvdl */
392 1.1 fvdl /* ARGSUSED */
393 1.1 fvdl static bool_t
394 1.1 fvdl rpc_wrap_bcast(resultp, addr, nconf)
395 1.1 fvdl char *resultp; /* results of the call */
396 1.1 fvdl struct netbuf *addr; /* address of the guy who responded */
397 1.1 fvdl struct netconfig *nconf; /* Netconf of the transport */
398 1.1 fvdl {
399 1.1 fvdl resultproc_t clnt_broadcast_result;
400 1.7 lukem
401 1.7 lukem _DIAGASSERT(resultp != NULL);
402 1.7 lukem _DIAGASSERT(addr != NULL);
403 1.7 lukem _DIAGASSERT(nconf != NULL);
404 1.1 fvdl
405 1.1 fvdl if (strcmp(nconf->nc_netid, "udp"))
406 1.1 fvdl return (FALSE);
407 1.10 thorpej #ifdef _REENTRANT
408 1.10 thorpej if (__isthreaded == 0)
409 1.1 fvdl clnt_broadcast_result = clnt_broadcast_result_main;
410 1.1 fvdl else
411 1.10 thorpej clnt_broadcast_result = thr_getspecific(clnt_broadcast_key);
412 1.1 fvdl #else
413 1.1 fvdl clnt_broadcast_result = clnt_broadcast_result_main;
414 1.1 fvdl #endif
415 1.1 fvdl return (*clnt_broadcast_result)(resultp,
416 1.1 fvdl (struct sockaddr_in *)addr->buf);
417 1.1 fvdl }
418 1.1 fvdl
419 1.10 thorpej #ifdef _REENTRANT
420 1.10 thorpej static once_t clnt_broadcast_once = ONCE_INITIALIZER;
421 1.10 thorpej
422 1.10 thorpej static void
423 1.10 thorpej clnt_broadcast_setup(void)
424 1.10 thorpej {
425 1.10 thorpej
426 1.10 thorpej thr_keycreate(&clnt_broadcast_key, free);
427 1.10 thorpej }
428 1.10 thorpej #endif
429 1.10 thorpej
430 1.1 fvdl /*
431 1.1 fvdl * Broadcasts on UDP transport. Obsoleted by rpc_broadcast().
432 1.1 fvdl */
433 1.1 fvdl enum clnt_stat
434 1.1 fvdl clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
435 1.1 fvdl u_long prog; /* program number */
436 1.1 fvdl u_long vers; /* version number */
437 1.1 fvdl u_long proc; /* procedure number */
438 1.1 fvdl xdrproc_t xargs; /* xdr routine for args */
439 1.1 fvdl caddr_t argsp; /* pointer to args */
440 1.1 fvdl xdrproc_t xresults; /* xdr routine for results */
441 1.1 fvdl caddr_t resultsp; /* pointer to results */
442 1.1 fvdl resultproc_t eachresult; /* call with each result obtained */
443 1.1 fvdl {
444 1.10 thorpej #ifdef _REENTRANT
445 1.10 thorpej if (__isthreaded == 0)
446 1.1 fvdl clnt_broadcast_result_main = eachresult;
447 1.1 fvdl else {
448 1.10 thorpej thr_once(&clnt_broadcast_once, clnt_broadcast_setup);
449 1.1 fvdl thr_setspecific(clnt_broadcast_key, (void *) eachresult);
450 1.1 fvdl }
451 1.1 fvdl #else
452 1.1 fvdl clnt_broadcast_result_main = eachresult;
453 1.1 fvdl #endif
454 1.6 christos return rpc_broadcast((rpcprog_t)prog, (rpcvers_t)vers,
455 1.6 christos (rpcproc_t)proc, xargs, argsp, xresults, resultsp,
456 1.6 christos (resultproc_t) rpc_wrap_bcast, "udp");
457 1.1 fvdl }
458 1.1 fvdl
459 1.1 fvdl #endif /* PORTMAP */
460