xref: /illumos-gate/usr/src/lib/libnsl/rpc/clnt_bcast.c (revision 1da57d55)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*45916cd2Sjpk  * Common Development and Distribution License (the "License").
6*45916cd2Sjpk  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
2061961e0fSrobinson  */
2161961e0fSrobinson 
2261961e0fSrobinson /*
23e8031f0aSraf  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
26e8031f0aSraf 
277c478bd9Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
287c478bd9Sstevel@tonic-gate /* All Rights Reserved */
297c478bd9Sstevel@tonic-gate /*
307c478bd9Sstevel@tonic-gate  * Portions of this source code were derived from Berkeley
317c478bd9Sstevel@tonic-gate  * 4.3 BSD under license from the Regents of the University of
327c478bd9Sstevel@tonic-gate  * California.
337c478bd9Sstevel@tonic-gate  */
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate /*
367c478bd9Sstevel@tonic-gate  * Client interface to broadcast service.
377c478bd9Sstevel@tonic-gate  *
387c478bd9Sstevel@tonic-gate  * The following is kludged-up support for simple rpc broadcasts.
397c478bd9Sstevel@tonic-gate  * Someday a large, complicated system will replace these routines.
407c478bd9Sstevel@tonic-gate  */
417c478bd9Sstevel@tonic-gate 
42e8031f0aSraf #include "mt.h"
43*45916cd2Sjpk #include "rpc_mt.h"
447c478bd9Sstevel@tonic-gate #include <string.h>
4561961e0fSrobinson #include <strings.h>
467c478bd9Sstevel@tonic-gate #include <rpc/rpc.h>
477c478bd9Sstevel@tonic-gate #include <rpc/nettype.h>
487c478bd9Sstevel@tonic-gate #include <sys/poll.h>
497c478bd9Sstevel@tonic-gate #include <netdir.h>
507c478bd9Sstevel@tonic-gate #ifdef PORTMAP
517c478bd9Sstevel@tonic-gate #include <rpc/pmap_prot.h>
527c478bd9Sstevel@tonic-gate #endif
537c478bd9Sstevel@tonic-gate #ifdef RPC_DEBUG
547c478bd9Sstevel@tonic-gate #include <stdio.h>
557c478bd9Sstevel@tonic-gate #endif
567c478bd9Sstevel@tonic-gate #include <errno.h>
577c478bd9Sstevel@tonic-gate #include <syslog.h>
587c478bd9Sstevel@tonic-gate #include <stdlib.h>
597c478bd9Sstevel@tonic-gate #include <unistd.h>
6061961e0fSrobinson #include <sys/types.h>
6161961e0fSrobinson #include <sys/socket.h>
6261961e0fSrobinson #include <netinet/in.h>
6361961e0fSrobinson #include <arpa/inet.h>
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate #define	MAXBCAST 20	/* Max no of broadcasting transports */
667c478bd9Sstevel@tonic-gate #define	INITTIME 4000	/* Time to wait initially */
677c478bd9Sstevel@tonic-gate #define	WAITTIME 8000	/* Maximum time to wait */
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate int lowvers = 1;	/* by default, broadcast only version 2 over UDP */
707c478bd9Sstevel@tonic-gate #ifndef NETIDLEN
717c478bd9Sstevel@tonic-gate #define	NETIDLEN 32
727c478bd9Sstevel@tonic-gate #endif
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate /*
757c478bd9Sstevel@tonic-gate  * If nettype is NULL, it broadcasts on all the available
767c478bd9Sstevel@tonic-gate  * datagram_n transports. May potentially lead to broadacst storms
777c478bd9Sstevel@tonic-gate  * and hence should be used with caution, care and courage.
787c478bd9Sstevel@tonic-gate  *
797c478bd9Sstevel@tonic-gate  * The current parameter xdr packet size is limited by the max tsdu
807c478bd9Sstevel@tonic-gate  * size of the transport. If the max tsdu size of any transport is
817c478bd9Sstevel@tonic-gate  * smaller than the parameter xdr packet, then broadcast is not
827c478bd9Sstevel@tonic-gate  * sent on that transport.
837c478bd9Sstevel@tonic-gate  *
847c478bd9Sstevel@tonic-gate  * Also, the packet size should be less the packet size of
857c478bd9Sstevel@tonic-gate  * the data link layer (for ethernet it is 1400 bytes).  There is
867c478bd9Sstevel@tonic-gate  * no easy way to find out the max size of the data link layer and
877c478bd9Sstevel@tonic-gate  * we are assuming that the args would be smaller than that.
887c478bd9Sstevel@tonic-gate  *
897c478bd9Sstevel@tonic-gate  * The result size has to be smaller than the transport tsdu size.
907c478bd9Sstevel@tonic-gate  *
917c478bd9Sstevel@tonic-gate  * If PORTMAP has been defined, we send two packets for UDP, one for
927c478bd9Sstevel@tonic-gate  * rpcbind and one for portmap. For those machines which support
937c478bd9Sstevel@tonic-gate  * both rpcbind and portmap, it will cause them to reply twice, and
947c478bd9Sstevel@tonic-gate  * also here it will get two responses ... inefficient and clumsy.
957c478bd9Sstevel@tonic-gate  */
967c478bd9Sstevel@tonic-gate 
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate enum clnt_stat
rpc_broadcast_exp(const rpcprog_t prog,const rpcvers_t vers,const rpcproc_t proc,const xdrproc_t xargs,caddr_t argsp,const xdrproc_t xresults,caddr_t resultsp,const resultproc_t eachresult,const int inittime,const int waittime,const char * netclass)9961961e0fSrobinson rpc_broadcast_exp(const rpcprog_t prog, const rpcvers_t vers,
10061961e0fSrobinson     const rpcproc_t proc, const xdrproc_t xargs, caddr_t argsp,
10161961e0fSrobinson     const xdrproc_t xresults, caddr_t resultsp, const resultproc_t eachresult,
10261961e0fSrobinson     const int inittime, const int waittime, const char *netclass)
1037c478bd9Sstevel@tonic-gate {
1047c478bd9Sstevel@tonic-gate 	enum clnt_stat	stat = RPC_SUCCESS; /* Return status */
10561961e0fSrobinson 	XDR		xdr_stream; /* XDR stream */
10661961e0fSrobinson 	XDR		*xdrs = &xdr_stream;
1077c478bd9Sstevel@tonic-gate 	struct rpc_msg	msg;	/* RPC message */
1087c478bd9Sstevel@tonic-gate 	struct timeval	t;
10961961e0fSrobinson 	char		*outbuf = NULL;	/* Broadcast msg buffer */
1107c478bd9Sstevel@tonic-gate 	char		*inbuf = NULL; /* Reply buf */
1117c478bd9Sstevel@tonic-gate 	uint_t		maxbufsize = 0;
11261961e0fSrobinson 	AUTH		*sys_auth = authsys_create_default();
11361961e0fSrobinson 	int		i, j;
1147c478bd9Sstevel@tonic-gate 	void		*handle;
1157c478bd9Sstevel@tonic-gate 	char		uaddress[1024];	/* A self imposed limit */
1167c478bd9Sstevel@tonic-gate 	char		*uaddrp = uaddress;
11761961e0fSrobinson 	int		pmap_reply_flag; /* reply recvd from PORTMAP */
1187c478bd9Sstevel@tonic-gate 	/* An array of all the suitable broadcast transports */
1197c478bd9Sstevel@tonic-gate 	struct {
1207c478bd9Sstevel@tonic-gate 		int fd;		/* File descriptor */
1217c478bd9Sstevel@tonic-gate 		bool_t udp_flag;	/* this is udp */
1227c478bd9Sstevel@tonic-gate 		struct netconfig *nconf; /* Netconfig structure */
1237c478bd9Sstevel@tonic-gate 		uint_t asize;	/* Size of the addr buf */
1247c478bd9Sstevel@tonic-gate 		uint_t dsize;	/* Size of the data buf */
1257c478bd9Sstevel@tonic-gate 		struct netbuf raddr; /* Remote address */
1267c478bd9Sstevel@tonic-gate 		struct nd_addrlist *nal; /* Broadcast addrs */
1277c478bd9Sstevel@tonic-gate 	} fdlist[MAXBCAST];
1287c478bd9Sstevel@tonic-gate 	struct pollfd pfd[MAXBCAST];
12961961e0fSrobinson 	int		fdlistno = 0;
1307c478bd9Sstevel@tonic-gate 	struct r_rpcb_rmtcallargs barg;	/* Remote arguments */
1317c478bd9Sstevel@tonic-gate 	struct r_rpcb_rmtcallres bres; /* Remote results */
1327c478bd9Sstevel@tonic-gate 	struct t_unitdata t_udata, t_rdata;
1337c478bd9Sstevel@tonic-gate 	struct netconfig *nconf;
1347c478bd9Sstevel@tonic-gate 	struct nd_hostserv hs;
1357c478bd9Sstevel@tonic-gate 	int msec;
1367c478bd9Sstevel@tonic-gate 	int pollretval;
1377c478bd9Sstevel@tonic-gate 	int fds_found;
1387c478bd9Sstevel@tonic-gate 	char nettype_array[NETIDLEN];
1397c478bd9Sstevel@tonic-gate 	char *nettype = &nettype_array[0];
1407c478bd9Sstevel@tonic-gate 
1417c478bd9Sstevel@tonic-gate #ifdef PORTMAP
1427c478bd9Sstevel@tonic-gate 	rpcport_t *port;	/* Remote port number */
1437c478bd9Sstevel@tonic-gate 	int pmap_flag = 0;	/* UDP exists ? */
1447c478bd9Sstevel@tonic-gate 	char *outbuf_pmap = NULL;
1457c478bd9Sstevel@tonic-gate 	struct p_rmtcallargs barg_pmap;	/* Remote arguments */
1467c478bd9Sstevel@tonic-gate 	struct p_rmtcallres bres_pmap; /* Remote results */
1477c478bd9Sstevel@tonic-gate 	struct t_unitdata t_udata_pmap;
1487c478bd9Sstevel@tonic-gate 	int udpbufsz = 0;
1497c478bd9Sstevel@tonic-gate #endif				/* PORTMAP */
1507c478bd9Sstevel@tonic-gate 
15161961e0fSrobinson 	if (sys_auth == NULL)
1527c478bd9Sstevel@tonic-gate 		return (RPC_SYSTEMERROR);
1537c478bd9Sstevel@tonic-gate 	/*
1547c478bd9Sstevel@tonic-gate 	 * initialization: create a fd, a broadcast address, and send the
1557c478bd9Sstevel@tonic-gate 	 * request on the broadcast transport.
1567c478bd9Sstevel@tonic-gate 	 * Listen on all of them and on replies, call the user supplied
1577c478bd9Sstevel@tonic-gate 	 * function.
1587c478bd9Sstevel@tonic-gate 	 */
1597c478bd9Sstevel@tonic-gate 
1607c478bd9Sstevel@tonic-gate 	if (netclass == NULL)
1617c478bd9Sstevel@tonic-gate 		nettype = NULL;
1627c478bd9Sstevel@tonic-gate 	else {
1637c478bd9Sstevel@tonic-gate 		size_t len = strlen(netclass);
16461961e0fSrobinson 		if (len >= sizeof (nettype_array))
1657c478bd9Sstevel@tonic-gate 			return (RPC_UNKNOWNPROTO);
16661961e0fSrobinson 		(void) strcpy(nettype, netclass);
1677c478bd9Sstevel@tonic-gate 	}
1687c478bd9Sstevel@tonic-gate 
1697c478bd9Sstevel@tonic-gate 	if (nettype == NULL)
1707c478bd9Sstevel@tonic-gate 		nettype = "datagram_n";
17161961e0fSrobinson 	if ((handle = __rpc_setconf((char *)nettype)) == NULL)
1727c478bd9Sstevel@tonic-gate 		return (RPC_UNKNOWNPROTO);
1737c478bd9Sstevel@tonic-gate 	while (nconf = __rpc_getconf(handle)) {
1747c478bd9Sstevel@tonic-gate 		struct t_info tinfo;
1757c478bd9Sstevel@tonic-gate 		int fd;
1767c478bd9Sstevel@tonic-gate 		uint_t addrlen;
1777c478bd9Sstevel@tonic-gate 
1787c478bd9Sstevel@tonic-gate 		if (nconf->nc_semantics != NC_TPI_CLTS)
1797c478bd9Sstevel@tonic-gate 			continue;
1807c478bd9Sstevel@tonic-gate 		if (fdlistno >= MAXBCAST)
1817c478bd9Sstevel@tonic-gate 			break;	/* No more slots available */
1827c478bd9Sstevel@tonic-gate 		if ((fd = t_open(nconf->nc_device, O_RDWR, &tinfo)) == -1) {
1837c478bd9Sstevel@tonic-gate 			stat = RPC_CANTSEND;
1847c478bd9Sstevel@tonic-gate 			continue;
1857c478bd9Sstevel@tonic-gate 		}
186*45916cd2Sjpk 		__rpc_set_mac_options(fd, nconf, prog);
18761961e0fSrobinson 		if (t_bind(fd, NULL, NULL) == -1) {
1887c478bd9Sstevel@tonic-gate 			(void) t_close(fd);
1897c478bd9Sstevel@tonic-gate 			stat = RPC_CANTSEND;
1907c478bd9Sstevel@tonic-gate 			continue;
1917c478bd9Sstevel@tonic-gate 		}
192*45916cd2Sjpk 
1937c478bd9Sstevel@tonic-gate 		/* Do protocol specific negotiating for broadcast */
1947c478bd9Sstevel@tonic-gate 		if (netdir_options(nconf, ND_SET_BROADCAST, fd, NULL)) {
1957c478bd9Sstevel@tonic-gate 			(void) t_close(fd);
1967c478bd9Sstevel@tonic-gate 			stat = RPC_NOBROADCAST;
1977c478bd9Sstevel@tonic-gate 			continue;
1987c478bd9Sstevel@tonic-gate 		}
1997c478bd9Sstevel@tonic-gate 		fdlist[fdlistno].fd = fd;
2007c478bd9Sstevel@tonic-gate 		fdlist[fdlistno].nconf = nconf;
2017c478bd9Sstevel@tonic-gate 		fdlist[fdlistno].udp_flag = FALSE;
2027c478bd9Sstevel@tonic-gate 		if (((addrlen = __rpc_get_a_size(tinfo.addr)) == 0) ||
2037c478bd9Sstevel@tonic-gate 		    ((fdlist[fdlistno].raddr.buf = malloc(addrlen)) == NULL)) {
20461961e0fSrobinson 			(void) t_close(fd);
2057c478bd9Sstevel@tonic-gate 			stat = RPC_SYSTEMERROR;
2067c478bd9Sstevel@tonic-gate 			goto done_broad;
2077c478bd9Sstevel@tonic-gate 		}
2087c478bd9Sstevel@tonic-gate 		fdlist[fdlistno].raddr.maxlen = addrlen;
2097c478bd9Sstevel@tonic-gate 		fdlist[fdlistno].raddr.len = addrlen;
2107c478bd9Sstevel@tonic-gate 		pfd[fdlistno].events = POLLIN | POLLPRI |
2117c478bd9Sstevel@tonic-gate 			POLLRDNORM | POLLRDBAND;
2127c478bd9Sstevel@tonic-gate 		pfd[fdlistno].fd = fdlist[fdlistno].fd = fd;
2137c478bd9Sstevel@tonic-gate 		fdlist[fdlistno].asize = addrlen;
2147c478bd9Sstevel@tonic-gate 
2157c478bd9Sstevel@tonic-gate 		if ((fdlist[fdlistno].dsize = __rpc_get_t_size(0,
2167c478bd9Sstevel@tonic-gate 				tinfo.tsdu)) == 0) {
21761961e0fSrobinson 			(void) t_close(fd);
2187c478bd9Sstevel@tonic-gate 			free(fdlist[fdlistno].raddr.buf);
2197c478bd9Sstevel@tonic-gate 			stat = RPC_SYSTEMERROR; /* XXX */
2207c478bd9Sstevel@tonic-gate 			goto done_broad;
2217c478bd9Sstevel@tonic-gate 		}
2227c478bd9Sstevel@tonic-gate 
2237c478bd9Sstevel@tonic-gate 		if (maxbufsize <= fdlist[fdlistno].dsize)
2247c478bd9Sstevel@tonic-gate 			maxbufsize = fdlist[fdlistno].dsize;
2257c478bd9Sstevel@tonic-gate #ifdef PORTMAP
2267c478bd9Sstevel@tonic-gate 		if (strcmp(nconf->nc_protofmly, NC_INET) == 0 &&
2277c478bd9Sstevel@tonic-gate 		    strcmp(nconf->nc_proto, NC_UDP) == 0) {
2287c478bd9Sstevel@tonic-gate 			udpbufsz = fdlist[fdlistno].dsize;
2297c478bd9Sstevel@tonic-gate 			if ((outbuf_pmap = malloc(udpbufsz)) == NULL) {
23061961e0fSrobinson 				(void) t_close(fd);
2317c478bd9Sstevel@tonic-gate 				free(fdlist[fdlistno].raddr.buf);
2327c478bd9Sstevel@tonic-gate 				stat = RPC_SYSTEMERROR;
2337c478bd9Sstevel@tonic-gate 				goto done_broad;
2347c478bd9Sstevel@tonic-gate 			}
2357c478bd9Sstevel@tonic-gate 			pmap_flag = 1;
2367c478bd9Sstevel@tonic-gate 			fdlist[fdlistno].udp_flag = TRUE;
2377c478bd9Sstevel@tonic-gate 		}
2387c478bd9Sstevel@tonic-gate #endif
2397c478bd9Sstevel@tonic-gate 		fdlistno++;
2407c478bd9Sstevel@tonic-gate 	}
2417c478bd9Sstevel@tonic-gate 
2427c478bd9Sstevel@tonic-gate 	if (fdlistno == 0) {
2437c478bd9Sstevel@tonic-gate 		if (stat == RPC_SUCCESS)
2447c478bd9Sstevel@tonic-gate 			stat = RPC_UNKNOWNPROTO;
2457c478bd9Sstevel@tonic-gate 		goto done_broad;
2467c478bd9Sstevel@tonic-gate 	}
2477c478bd9Sstevel@tonic-gate 	if (maxbufsize == 0) {
2487c478bd9Sstevel@tonic-gate 		if (stat == RPC_SUCCESS)
2497c478bd9Sstevel@tonic-gate 			stat = RPC_CANTSEND;
2507c478bd9Sstevel@tonic-gate 		goto done_broad;
2517c478bd9Sstevel@tonic-gate 	}
2527c478bd9Sstevel@tonic-gate 	inbuf = malloc((size_t)maxbufsize);
2537c478bd9Sstevel@tonic-gate 	outbuf = malloc((size_t)maxbufsize);
2547c478bd9Sstevel@tonic-gate 	if ((inbuf == NULL) || (outbuf == NULL)) {
2557c478bd9Sstevel@tonic-gate 		stat = RPC_SYSTEMERROR;
2567c478bd9Sstevel@tonic-gate 		goto done_broad;
2577c478bd9Sstevel@tonic-gate 	}
2587c478bd9Sstevel@tonic-gate 
2597c478bd9Sstevel@tonic-gate 	/* Serialize all the arguments which have to be sent */
2607c478bd9Sstevel@tonic-gate 	(void) gettimeofday(&t, (struct timezone *)0);
2617c478bd9Sstevel@tonic-gate 	msg.rm_xid = getpid() ^ t.tv_sec ^ t.tv_usec;
2627c478bd9Sstevel@tonic-gate 	msg.rm_direction = CALL;
2637c478bd9Sstevel@tonic-gate 	msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
2647c478bd9Sstevel@tonic-gate 	msg.rm_call.cb_prog = RPCBPROG;
2657c478bd9Sstevel@tonic-gate 	msg.rm_call.cb_vers = RPCBVERS;
2667c478bd9Sstevel@tonic-gate 	msg.rm_call.cb_proc = RPCBPROC_CALLIT;
2677c478bd9Sstevel@tonic-gate 	barg.prog = prog;
2687c478bd9Sstevel@tonic-gate 	barg.vers = vers;
2697c478bd9Sstevel@tonic-gate 	barg.proc = proc;
2707c478bd9Sstevel@tonic-gate 	barg.args.args_val = argsp;
2717c478bd9Sstevel@tonic-gate 	barg.xdr_args = xargs;
2727c478bd9Sstevel@tonic-gate 	bres.addr = uaddrp;
2737c478bd9Sstevel@tonic-gate 	bres.results.results_val = resultsp;
2747c478bd9Sstevel@tonic-gate 	bres.xdr_res = xresults;
2757c478bd9Sstevel@tonic-gate 	msg.rm_call.cb_cred = sys_auth->ah_cred;
2767c478bd9Sstevel@tonic-gate 	msg.rm_call.cb_verf = sys_auth->ah_verf;
2777c478bd9Sstevel@tonic-gate 	xdrmem_create(xdrs, outbuf, maxbufsize, XDR_ENCODE);
27861961e0fSrobinson 	if ((!xdr_callmsg(xdrs, &msg)) ||
27961961e0fSrobinson 	    (!xdr_rpcb_rmtcallargs(xdrs, &barg))) {
2807c478bd9Sstevel@tonic-gate 		stat = RPC_CANTENCODEARGS;
2817c478bd9Sstevel@tonic-gate 		goto done_broad;
2827c478bd9Sstevel@tonic-gate 	}
2837c478bd9Sstevel@tonic-gate 	t_udata.opt.len = 0;
2847c478bd9Sstevel@tonic-gate 	t_udata.udata.buf = outbuf;
2857c478bd9Sstevel@tonic-gate 	t_udata.udata.len = xdr_getpos(xdrs);
2867c478bd9Sstevel@tonic-gate 	t_udata.udata.maxlen = t_udata.udata.len;
2877c478bd9Sstevel@tonic-gate 	/* XXX Should have set opt to its legal maxlen. */
2887c478bd9Sstevel@tonic-gate 	t_rdata.opt.len = t_rdata.opt.maxlen = 0;
2897c478bd9Sstevel@tonic-gate 	xdr_destroy(xdrs);
2907c478bd9Sstevel@tonic-gate 
2917c478bd9Sstevel@tonic-gate #ifdef PORTMAP
2927c478bd9Sstevel@tonic-gate 	/* Prepare the packet for version 2 PORTMAP */
2937c478bd9Sstevel@tonic-gate 	if (pmap_flag) {
2947c478bd9Sstevel@tonic-gate 		msg.rm_xid++;	/* One way to distinguish */
2957c478bd9Sstevel@tonic-gate 		msg.rm_call.cb_prog = PMAPPROG;
2967c478bd9Sstevel@tonic-gate 		msg.rm_call.cb_vers = PMAPVERS;
2977c478bd9Sstevel@tonic-gate 		msg.rm_call.cb_proc = PMAPPROC_CALLIT;
2987c478bd9Sstevel@tonic-gate 		barg_pmap.prog = prog;
2997c478bd9Sstevel@tonic-gate 		barg_pmap.vers = vers;
3007c478bd9Sstevel@tonic-gate 		barg_pmap.proc = proc;
3017c478bd9Sstevel@tonic-gate 		barg_pmap.args.args_val = argsp;
3027c478bd9Sstevel@tonic-gate 		barg_pmap.xdr_args = xargs;
3037c478bd9Sstevel@tonic-gate 		port = &bres_pmap.port;	/* for use later on */
3047c478bd9Sstevel@tonic-gate 		bres_pmap.xdr_res = xresults;
3057c478bd9Sstevel@tonic-gate 		bres_pmap.res.res_val = resultsp;
3067c478bd9Sstevel@tonic-gate 		xdrmem_create(xdrs, outbuf_pmap, udpbufsz, XDR_ENCODE);
30761961e0fSrobinson 		if ((!xdr_callmsg(xdrs, &msg)) ||
30861961e0fSrobinson 		    (!xdr_rmtcallargs(xdrs, &barg_pmap))) {
3097c478bd9Sstevel@tonic-gate 			stat = RPC_CANTENCODEARGS;
3107c478bd9Sstevel@tonic-gate 			goto done_broad;
3117c478bd9Sstevel@tonic-gate 		}
3127c478bd9Sstevel@tonic-gate 		t_udata_pmap.opt.len = 0;
3137c478bd9Sstevel@tonic-gate 		t_udata_pmap.udata.buf = outbuf_pmap;
3147c478bd9Sstevel@tonic-gate 		t_udata_pmap.udata.len = xdr_getpos(xdrs);
3157c478bd9Sstevel@tonic-gate 		xdr_destroy(xdrs);
3167c478bd9Sstevel@tonic-gate 	}
3177c478bd9Sstevel@tonic-gate #endif				/* PORTMAP */
3187c478bd9Sstevel@tonic-gate 
3197c478bd9Sstevel@tonic-gate 	/*
3207c478bd9Sstevel@tonic-gate 	 * Basic loop: broadcast the packets to transports which
3217c478bd9Sstevel@tonic-gate 	 * support data packets of size such that one can encode
3227c478bd9Sstevel@tonic-gate 	 * all the arguments.
3237c478bd9Sstevel@tonic-gate 	 * Wait a while for response(s).
3247c478bd9Sstevel@tonic-gate 	 * The response timeout grows larger per iteration.
3257c478bd9Sstevel@tonic-gate 	 */
3267c478bd9Sstevel@tonic-gate 	hs.h_host = HOST_BROADCAST;
3277c478bd9Sstevel@tonic-gate 	hs.h_serv = "rpcbind";
3287c478bd9Sstevel@tonic-gate 
3297c478bd9Sstevel@tonic-gate 	for (msec = inittime; msec <= waittime; msec += msec) {
3307c478bd9Sstevel@tonic-gate 		/* Broadcast all the packets now */
3317c478bd9Sstevel@tonic-gate 		for (i = 0; i < fdlistno; i++) {
3327c478bd9Sstevel@tonic-gate 			if (strcmp(fdlist[i].nconf->nc_protofmly,
3337c478bd9Sstevel@tonic-gate 			    NC_INET6) == 0) {
3347c478bd9Sstevel@tonic-gate 				/* if it's IPv6 */
3357c478bd9Sstevel@tonic-gate 
3367c478bd9Sstevel@tonic-gate 				struct netbuf addr;
3377c478bd9Sstevel@tonic-gate 				struct sockaddr_in6 sa6;
3387c478bd9Sstevel@tonic-gate 
3397c478bd9Sstevel@tonic-gate 				/* fill in the multicast address */
3407c478bd9Sstevel@tonic-gate 				bzero((char *)&sa6, sizeof (sa6));
3417c478bd9Sstevel@tonic-gate 				sa6.sin6_family = AF_INET6;
3427c478bd9Sstevel@tonic-gate 				sa6.sin6_port = htons(PMAPPORT);
3437c478bd9Sstevel@tonic-gate 				(void) inet_pton(AF_INET6, RPCB_MULTICAST_ADDR,
3447c478bd9Sstevel@tonic-gate 					&sa6.sin6_addr);
3457c478bd9Sstevel@tonic-gate 				addr.maxlen = sizeof (struct sockaddr_in6);
3467c478bd9Sstevel@tonic-gate 				addr.len = addr.maxlen;
3477c478bd9Sstevel@tonic-gate 				addr.buf = (char *)&sa6;
3487c478bd9Sstevel@tonic-gate 
3497c478bd9Sstevel@tonic-gate 				/* now send rpcbind message */
3507c478bd9Sstevel@tonic-gate 				t_udata.addr = addr;
3517c478bd9Sstevel@tonic-gate 
3527c478bd9Sstevel@tonic-gate 
3537c478bd9Sstevel@tonic-gate 				if (t_sndudata(fdlist[i].fd,
3547c478bd9Sstevel@tonic-gate 					&t_udata)) {
3557c478bd9Sstevel@tonic-gate 					(void) syslog(LOG_ERR,
3567c478bd9Sstevel@tonic-gate 					"Cannot send broadcast\
3577c478bd9Sstevel@tonic-gate packet: %m");
35861961e0fSrobinson #ifdef	RPC_DEBUG
3597c478bd9Sstevel@tonic-gate 				t_error("rpc_broadcast: t_sndudata");
3607c478bd9Sstevel@tonic-gate #endif
3617c478bd9Sstevel@tonic-gate 					stat = RPC_CANTSEND;
3627c478bd9Sstevel@tonic-gate 					continue;
3637c478bd9Sstevel@tonic-gate 				}
3647c478bd9Sstevel@tonic-gate 
3657c478bd9Sstevel@tonic-gate 			} else {
3667c478bd9Sstevel@tonic-gate 
3677c478bd9Sstevel@tonic-gate 				struct nd_addrlist *addrlist;
3687c478bd9Sstevel@tonic-gate 
3697c478bd9Sstevel@tonic-gate 				if (fdlist[i].dsize < t_udata.udata.len) {
3707c478bd9Sstevel@tonic-gate 					stat = RPC_CANTSEND;
3717c478bd9Sstevel@tonic-gate 					continue;
3727c478bd9Sstevel@tonic-gate 				}
3737c478bd9Sstevel@tonic-gate 				if (netdir_getbyname(fdlist[i].nconf, &hs,
3747c478bd9Sstevel@tonic-gate 					&addrlist) || (addrlist->n_cnt == 0)) {
3757c478bd9Sstevel@tonic-gate 					stat = RPC_N2AXLATEFAILURE;
3767c478bd9Sstevel@tonic-gate 					continue;
3777c478bd9Sstevel@tonic-gate 				}
3787c478bd9Sstevel@tonic-gate 
3797c478bd9Sstevel@tonic-gate 				for (j = 0; j < addrlist->n_cnt; j++) {
38061961e0fSrobinson #ifdef	RPC_DEBUG
3817c478bd9Sstevel@tonic-gate 					struct netconfig *nconf =
3827c478bd9Sstevel@tonic-gate 						fdlist[i].nconf;
38361961e0fSrobinson #endif
3847c478bd9Sstevel@tonic-gate 
3857c478bd9Sstevel@tonic-gate 					t_udata.addr = addrlist->n_addrs[j];
3867c478bd9Sstevel@tonic-gate 
3877c478bd9Sstevel@tonic-gate 					/*
3887c478bd9Sstevel@tonic-gate 					 * Only use version 3 if lowvers
3897c478bd9Sstevel@tonic-gate 					 * is not set or transport is not UDP.
3907c478bd9Sstevel@tonic-gate 					 */
3917c478bd9Sstevel@tonic-gate 
3927c478bd9Sstevel@tonic-gate 					if (!lowvers || !fdlist[i].udp_flag)
3937c478bd9Sstevel@tonic-gate 					if (t_sndudata(fdlist[i].fd,
3947c478bd9Sstevel@tonic-gate 						&t_udata)) {
3957c478bd9Sstevel@tonic-gate 						(void) syslog(LOG_ERR,
3967c478bd9Sstevel@tonic-gate 						"Cannot send broadcast\
3977c478bd9Sstevel@tonic-gate packet: %m");
39861961e0fSrobinson #ifdef	RPC_DEBUG
3997c478bd9Sstevel@tonic-gate 					t_error("rpc_broadcast: t_sndudata");
4007c478bd9Sstevel@tonic-gate #endif
4017c478bd9Sstevel@tonic-gate 							stat = RPC_CANTSEND;
4027c478bd9Sstevel@tonic-gate 							continue;
4037c478bd9Sstevel@tonic-gate 						};
40461961e0fSrobinson #ifdef	RPC_DEBUG
4057c478bd9Sstevel@tonic-gate 					if (!lowvers || !fdlist[i].udp_flag)
4067c478bd9Sstevel@tonic-gate 						fprintf(stderr, "Broadcast\
4077c478bd9Sstevel@tonic-gate packet sent for %s\n", nconf->nc_netid);
4087c478bd9Sstevel@tonic-gate #endif
4097c478bd9Sstevel@tonic-gate #ifdef	PORTMAP
4107c478bd9Sstevel@tonic-gate 					/*
4117c478bd9Sstevel@tonic-gate 					 * Send the version 2 packet also
4127c478bd9Sstevel@tonic-gate 					 * for UDP/IP
4137c478bd9Sstevel@tonic-gate 					 */
4147c478bd9Sstevel@tonic-gate 					if (fdlist[i].udp_flag) {
4157c478bd9Sstevel@tonic-gate 						t_udata_pmap.addr =
4167c478bd9Sstevel@tonic-gate 							t_udata.addr;
4177c478bd9Sstevel@tonic-gate 						if (t_sndudata(fdlist[i].fd,
4187c478bd9Sstevel@tonic-gate 							&t_udata_pmap)) {
4197c478bd9Sstevel@tonic-gate 							(void) syslog(LOG_ERR,\
4207c478bd9Sstevel@tonic-gate "Cannot send broadcast packet: %m");
4217c478bd9Sstevel@tonic-gate #ifdef RPC_DEBUG
4227c478bd9Sstevel@tonic-gate 						t_error("rpc_broadcast:\
4237c478bd9Sstevel@tonic-gate t_sndudata");
4247c478bd9Sstevel@tonic-gate #endif
4257c478bd9Sstevel@tonic-gate 						stat = RPC_CANTSEND;
4267c478bd9Sstevel@tonic-gate 						continue;
4277c478bd9Sstevel@tonic-gate 						}
4287c478bd9Sstevel@tonic-gate 					}
4297c478bd9Sstevel@tonic-gate #ifdef RPC_DEBUG
4307c478bd9Sstevel@tonic-gate 					fprintf(stderr, "PMAP Broadcast packet\
4317c478bd9Sstevel@tonic-gate sent for %s\n", nconf->nc_netid);
4327c478bd9Sstevel@tonic-gate #endif
4337c478bd9Sstevel@tonic-gate #endif				/* PORTMAP */
4347c478bd9Sstevel@tonic-gate 				}
4357c478bd9Sstevel@tonic-gate 			/* End for sending all packets on this transport */
4367c478bd9Sstevel@tonic-gate 			(void) netdir_free((char *)addrlist, ND_ADDRLIST);
4377c478bd9Sstevel@tonic-gate 			} /* end non-IPv6 */
4387c478bd9Sstevel@tonic-gate 
4397c478bd9Sstevel@tonic-gate 		}		/* End for sending on all transports */
4407c478bd9Sstevel@tonic-gate 
4417c478bd9Sstevel@tonic-gate 		if (eachresult == NULL) {
4427c478bd9Sstevel@tonic-gate 			stat = RPC_SUCCESS;
4437c478bd9Sstevel@tonic-gate 			goto done_broad;
4447c478bd9Sstevel@tonic-gate 		}
4457c478bd9Sstevel@tonic-gate 
4467c478bd9Sstevel@tonic-gate 		/*
4477c478bd9Sstevel@tonic-gate 		 * Get all the replies from these broadcast requests
4487c478bd9Sstevel@tonic-gate 		 */
4497c478bd9Sstevel@tonic-gate 	recv_again:
4507c478bd9Sstevel@tonic-gate 
4517c478bd9Sstevel@tonic-gate 		switch (pollretval = poll(pfd, fdlistno, msec)) {
4527c478bd9Sstevel@tonic-gate 		case 0:		/* timed out */
4537c478bd9Sstevel@tonic-gate 			stat = RPC_TIMEDOUT;
4547c478bd9Sstevel@tonic-gate 			continue;
4557c478bd9Sstevel@tonic-gate 		case -1:	/* some kind of error - we ignore it */
4567c478bd9Sstevel@tonic-gate 			goto recv_again;
4577c478bd9Sstevel@tonic-gate 		}		/* end of poll results switch */
4587c478bd9Sstevel@tonic-gate 
4597c478bd9Sstevel@tonic-gate 		t_rdata.udata.buf = inbuf;
4607c478bd9Sstevel@tonic-gate 
4617c478bd9Sstevel@tonic-gate 		for (i = fds_found = 0;
4627c478bd9Sstevel@tonic-gate 			i < fdlistno && fds_found < pollretval; i++) {
4637c478bd9Sstevel@tonic-gate 
4647c478bd9Sstevel@tonic-gate 			int flag;
4657c478bd9Sstevel@tonic-gate 			bool_t	done = FALSE;
4667c478bd9Sstevel@tonic-gate 
4677c478bd9Sstevel@tonic-gate 			if (pfd[i].revents == 0)
4687c478bd9Sstevel@tonic-gate 				continue;
4697c478bd9Sstevel@tonic-gate 			else if (pfd[i].revents & POLLNVAL) {
4707c478bd9Sstevel@tonic-gate 				/*
4717c478bd9Sstevel@tonic-gate 				 * Something bad has happened to this descri-
4727c478bd9Sstevel@tonic-gate 				 * ptor. We can cause poll() to ignore
4737c478bd9Sstevel@tonic-gate 				 * it simply by using a negative fd.  We do that
4747c478bd9Sstevel@tonic-gate 				 * rather than compacting the pfd[] and fdlist[]
4757c478bd9Sstevel@tonic-gate 				 * arrays.
4767c478bd9Sstevel@tonic-gate 				 */
4777c478bd9Sstevel@tonic-gate 				pfd[i].fd = -1;
4787c478bd9Sstevel@tonic-gate 				fds_found++;
4797c478bd9Sstevel@tonic-gate 				continue;
4807c478bd9Sstevel@tonic-gate 			} else
4817c478bd9Sstevel@tonic-gate 				fds_found++;
4827c478bd9Sstevel@tonic-gate #ifdef RPC_DEBUG
4837c478bd9Sstevel@tonic-gate 			fprintf(stderr, "response for %s\n",
4847c478bd9Sstevel@tonic-gate 				fdlist[i].nconf->nc_netid);
4857c478bd9Sstevel@tonic-gate #endif
4867c478bd9Sstevel@tonic-gate 		try_again:
4877c478bd9Sstevel@tonic-gate 			t_rdata.udata.maxlen = fdlist[i].dsize;
4887c478bd9Sstevel@tonic-gate 			t_rdata.udata.len = 0;
4897c478bd9Sstevel@tonic-gate 			t_rdata.addr = fdlist[i].raddr;
4907c478bd9Sstevel@tonic-gate 			if (t_rcvudata(fdlist[i].fd, &t_rdata, &flag) == -1) {
4917c478bd9Sstevel@tonic-gate 				if (t_errno == TSYSERR && errno == EINTR)
4927c478bd9Sstevel@tonic-gate 					goto try_again;
4937c478bd9Sstevel@tonic-gate 
4947c478bd9Sstevel@tonic-gate 				/*
4957c478bd9Sstevel@tonic-gate 				 * Ignore any T_UDERR look errors.
4967c478bd9Sstevel@tonic-gate 				 * We should never see any ICMP port
4977c478bd9Sstevel@tonic-gate 				 * unreachables when broadcasting but it has
4987c478bd9Sstevel@tonic-gate 				 * been observed with broken IP
4997c478bd9Sstevel@tonic-gate 				 * implementations.
5007c478bd9Sstevel@tonic-gate 				 */
5017c478bd9Sstevel@tonic-gate 				if (t_errno == TLOOK &&
5027c478bd9Sstevel@tonic-gate 				    t_look(fdlist[i].fd) == T_UDERR &&
5037c478bd9Sstevel@tonic-gate 				    t_rcvuderr(fdlist[i].fd, NULL) == 0)
5047c478bd9Sstevel@tonic-gate 					goto recv_again;
5057c478bd9Sstevel@tonic-gate 
5067c478bd9Sstevel@tonic-gate 				(void) syslog(LOG_ERR,
5077c478bd9Sstevel@tonic-gate 					"Cannot receive reply to \
5087c478bd9Sstevel@tonic-gate 					broadcast: %m");
5097c478bd9Sstevel@tonic-gate 				stat = RPC_CANTRECV;
5107c478bd9Sstevel@tonic-gate 				continue;
5117c478bd9Sstevel@tonic-gate 			}
5127c478bd9Sstevel@tonic-gate 			/*
5137c478bd9Sstevel@tonic-gate 			 * Not taking care of flag for T_MORE.
5147c478bd9Sstevel@tonic-gate 			 * We are assuming that
5157c478bd9Sstevel@tonic-gate 			 * such calls should not take more than one
5167c478bd9Sstevel@tonic-gate 			 * transport packet.
5177c478bd9Sstevel@tonic-gate 			 */
5187c478bd9Sstevel@tonic-gate 			if (flag & T_MORE)
5197c478bd9Sstevel@tonic-gate 				continue; /* Drop that and go ahead */
5207c478bd9Sstevel@tonic-gate 			if (t_rdata.udata.len < (uint_t)sizeof (uint32_t))
5217c478bd9Sstevel@tonic-gate 				continue; /* Drop that and go ahead */
5227c478bd9Sstevel@tonic-gate 			/*
5237c478bd9Sstevel@tonic-gate 			 * see if reply transaction id matches sent id.
5247c478bd9Sstevel@tonic-gate 			 * If so, decode the results. If return id is xid + 1
5257c478bd9Sstevel@tonic-gate 			 * it was a PORTMAP reply
5267c478bd9Sstevel@tonic-gate 			 */
52761961e0fSrobinson 			/* LINTED pointer cast */
5287c478bd9Sstevel@tonic-gate 			if (*((uint32_t *)(inbuf)) == *((uint32_t *)(outbuf))) {
5297c478bd9Sstevel@tonic-gate 				pmap_reply_flag = 0;
5307c478bd9Sstevel@tonic-gate 				msg.acpted_rply.ar_verf = _null_auth;
5317c478bd9Sstevel@tonic-gate 				msg.acpted_rply.ar_results.where =
5327c478bd9Sstevel@tonic-gate 					(caddr_t)&bres;
5337c478bd9Sstevel@tonic-gate 				msg.acpted_rply.ar_results.proc =
5347c478bd9Sstevel@tonic-gate 					(xdrproc_t)xdr_rpcb_rmtcallres;
5357c478bd9Sstevel@tonic-gate #ifdef PORTMAP
5367c478bd9Sstevel@tonic-gate 			} else if (pmap_flag &&
53761961e0fSrobinson 				/* LINTED pointer cast */
5387c478bd9Sstevel@tonic-gate 				*((uint32_t *)(inbuf)) ==
53961961e0fSrobinson 					/* LINTED pointer cast */
54061961e0fSrobinson 					*((uint32_t *)(outbuf_pmap))) {
5417c478bd9Sstevel@tonic-gate 				pmap_reply_flag = 1;
5427c478bd9Sstevel@tonic-gate 				msg.acpted_rply.ar_verf = _null_auth;
5437c478bd9Sstevel@tonic-gate 				msg.acpted_rply.ar_results.where =
5447c478bd9Sstevel@tonic-gate 					(caddr_t)&bres_pmap;
5457c478bd9Sstevel@tonic-gate 				msg.acpted_rply.ar_results.proc =
5467c478bd9Sstevel@tonic-gate 					(xdrproc_t)xdr_rmtcallres;
5477c478bd9Sstevel@tonic-gate #endif				/* PORTMAP */
5487c478bd9Sstevel@tonic-gate 			} else
5497c478bd9Sstevel@tonic-gate 				continue;
5507c478bd9Sstevel@tonic-gate 			xdrmem_create(xdrs, inbuf,
5517c478bd9Sstevel@tonic-gate 				(uint_t)t_rdata.udata.len, XDR_DECODE);
5527c478bd9Sstevel@tonic-gate 			if (xdr_replymsg(xdrs, &msg)) {
5537c478bd9Sstevel@tonic-gate 				if ((msg.rm_reply.rp_stat == MSG_ACCEPTED) &&
5547c478bd9Sstevel@tonic-gate 				    (msg.acpted_rply.ar_stat == SUCCESS)) {
5557c478bd9Sstevel@tonic-gate 					struct netbuf *taddr;
5567c478bd9Sstevel@tonic-gate #ifdef PORTMAP
5577c478bd9Sstevel@tonic-gate 					if (pmap_flag && pmap_reply_flag) {
5587c478bd9Sstevel@tonic-gate 						/* convert port to taddr */
55961961e0fSrobinson 						/* LINTED pointer cast */
5607c478bd9Sstevel@tonic-gate 						((struct sockaddr_in *)
5617c478bd9Sstevel@tonic-gate 						t_rdata.addr.buf)->sin_port =
5627c478bd9Sstevel@tonic-gate 						htons((ushort_t)*port);
5637c478bd9Sstevel@tonic-gate 						taddr = &t_rdata.addr;
5647c478bd9Sstevel@tonic-gate 					} else /* Convert the uaddr to taddr */
5657c478bd9Sstevel@tonic-gate #endif
5667c478bd9Sstevel@tonic-gate 						taddr = uaddr2taddr(
5677c478bd9Sstevel@tonic-gate 						    fdlist[i].nconf,
5687c478bd9Sstevel@tonic-gate 						    uaddrp);
5697c478bd9Sstevel@tonic-gate 					done = (*eachresult)(resultsp, taddr,
5707c478bd9Sstevel@tonic-gate 						fdlist[i].nconf);
5717c478bd9Sstevel@tonic-gate #ifdef RPC_DEBUG
5727c478bd9Sstevel@tonic-gate 				{
5737c478bd9Sstevel@tonic-gate 					int k;
5747c478bd9Sstevel@tonic-gate 
5757c478bd9Sstevel@tonic-gate 					printf("rmt addr = ");
5767c478bd9Sstevel@tonic-gate 					for (k = 0; k < taddr->len; k++)
5777c478bd9Sstevel@tonic-gate 						printf("%d ", taddr->buf[k]);
5787c478bd9Sstevel@tonic-gate 					printf("\n");
5797c478bd9Sstevel@tonic-gate 				}
5807c478bd9Sstevel@tonic-gate #endif
5817c478bd9Sstevel@tonic-gate 					if (taddr && !pmap_reply_flag)
5827c478bd9Sstevel@tonic-gate 						netdir_free((char *)taddr,
5837c478bd9Sstevel@tonic-gate 							    ND_ADDR);
5847c478bd9Sstevel@tonic-gate 				}
5857c478bd9Sstevel@tonic-gate 				/* otherwise, we just ignore the errors ... */
5867c478bd9Sstevel@tonic-gate 			}
5877c478bd9Sstevel@tonic-gate 			/* else some kind of deserialization problem ... */
5887c478bd9Sstevel@tonic-gate 
5897c478bd9Sstevel@tonic-gate 			xdrs->x_op = XDR_FREE;
5907c478bd9Sstevel@tonic-gate 			msg.acpted_rply.ar_results.proc = (xdrproc_t)xdr_void;
5917c478bd9Sstevel@tonic-gate 			(void) xdr_replymsg(xdrs, &msg);
5927c478bd9Sstevel@tonic-gate 			(void) (*xresults)(xdrs, resultsp);
5937c478bd9Sstevel@tonic-gate 			XDR_DESTROY(xdrs);
5947c478bd9Sstevel@tonic-gate 			if (done) {
5957c478bd9Sstevel@tonic-gate 				stat = RPC_SUCCESS;
5967c478bd9Sstevel@tonic-gate 				goto done_broad;
5977c478bd9Sstevel@tonic-gate 			} else {
5987c478bd9Sstevel@tonic-gate 				if (rpc_callerr.re_status == RPC_SYSTEMERROR) {
5997c478bd9Sstevel@tonic-gate 					stat = RPC_SYSTEMERROR;
6007c478bd9Sstevel@tonic-gate 					goto done_broad;
6017c478bd9Sstevel@tonic-gate 				}
6027c478bd9Sstevel@tonic-gate 				goto recv_again;
6037c478bd9Sstevel@tonic-gate 			}
6047c478bd9Sstevel@tonic-gate 		}		/* The recv for loop */
6057c478bd9Sstevel@tonic-gate 	}			/* The giant for loop */
6067c478bd9Sstevel@tonic-gate 
6077c478bd9Sstevel@tonic-gate done_broad:
6087c478bd9Sstevel@tonic-gate 	if (inbuf)
60961961e0fSrobinson 		free(inbuf);
6107c478bd9Sstevel@tonic-gate 	if (outbuf)
61161961e0fSrobinson 		free(outbuf);
6127c478bd9Sstevel@tonic-gate #ifdef PORTMAP
6137c478bd9Sstevel@tonic-gate 	if (outbuf_pmap)
61461961e0fSrobinson 		free(outbuf_pmap);
6157c478bd9Sstevel@tonic-gate #endif
6167c478bd9Sstevel@tonic-gate 	for (i = 0; i < fdlistno; i++) {
6177c478bd9Sstevel@tonic-gate 		(void) t_close(fdlist[i].fd);
61861961e0fSrobinson 		free(fdlist[i].raddr.buf);
6197c478bd9Sstevel@tonic-gate 	}
6207c478bd9Sstevel@tonic-gate 	AUTH_DESTROY(sys_auth);
6217c478bd9Sstevel@tonic-gate 	(void) __rpc_endconf(handle);
6227c478bd9Sstevel@tonic-gate 
6237c478bd9Sstevel@tonic-gate 	return (stat);
6247c478bd9Sstevel@tonic-gate }
6257c478bd9Sstevel@tonic-gate 
6267c478bd9Sstevel@tonic-gate enum clnt_stat
rpc_broadcast(const rpcprog_t prog,const rpcvers_t vers,const rpcproc_t proc,const xdrproc_t xargs,caddr_t argsp,xdrproc_t const xresults,caddr_t resultsp,const resultproc_t eachresult,const char * nettype)62761961e0fSrobinson rpc_broadcast(const rpcprog_t prog, const rpcvers_t vers, const rpcproc_t proc,
62861961e0fSrobinson 	const xdrproc_t xargs, caddr_t argsp, xdrproc_t const xresults,
62961961e0fSrobinson 	caddr_t resultsp, const resultproc_t eachresult, const char *nettype)
6307c478bd9Sstevel@tonic-gate {
63161961e0fSrobinson 	return (rpc_broadcast_exp(prog, vers, proc, xargs, argsp,
6327c478bd9Sstevel@tonic-gate 		xresults, resultsp, eachresult,
63361961e0fSrobinson 		INITTIME, WAITTIME, nettype));
6347c478bd9Sstevel@tonic-gate }
635