1 /* $NetBSD: clnt_bcast.c,v 1.3 2000/07/06 03:05:20 christos Exp $ */ 2 3 /*- 4 * SPDX-License-Identifier: BSD-3-Clause 5 * 6 * Copyright (c) 2009, Sun Microsystems, Inc. 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions are met: 11 * - Redistributions of source code must retain the above copyright notice, 12 * this list of conditions and the following disclaimer. 13 * - Redistributions in binary form must reproduce the above copyright notice, 14 * this list of conditions and the following disclaimer in the documentation 15 * and/or other materials provided with the distribution. 16 * - Neither the name of Sun Microsystems, Inc. nor the names of its 17 * contributors may be used to endorse or promote products derived 18 * from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 */ 32 /* 33 * Copyright (c) 1986-1991 by Sun Microsystems Inc. 34 */ 35 36 #if defined(LIBC_SCCS) && !defined(lint) 37 #ident "@(#)clnt_bcast.c 1.18 94/05/03 SMI" 38 static char sccsid[] = "@(#)clnt_bcast.c 1.15 89/04/21 Copyr 1988 Sun Micro"; 39 #endif 40 /* 41 * clnt_bcast.c 42 * Client interface to broadcast service. 43 * 44 * Copyright (C) 1988, Sun Microsystems, Inc. 45 * 46 * The following is kludged-up support for simple rpc broadcasts. 47 * Someday a large, complicated system will replace these routines. 48 */ 49 50 #include "namespace.h" 51 #include <sys/types.h> 52 #include <sys/socket.h> 53 #include <sys/queue.h> 54 #include <net/if.h> 55 #include <netinet/in.h> 56 #include <ifaddrs.h> 57 #include <sys/poll.h> 58 #include <rpc/rpc.h> 59 #ifdef PORTMAP 60 #include <rpc/pmap_prot.h> 61 #include <rpc/pmap_clnt.h> 62 #include <rpc/pmap_rmt.h> 63 #endif /* PORTMAP */ 64 #include <rpc/nettype.h> 65 #include <arpa/inet.h> 66 #ifdef RPC_DEBUG 67 #include <stdio.h> 68 #endif 69 #include <errno.h> 70 #include <stdlib.h> 71 #include <unistd.h> 72 #include <netdb.h> 73 #include <err.h> 74 #include <string.h> 75 #include "un-namespace.h" 76 77 #include "rpc_com.h" 78 79 #define MAXBCAST 20 /* Max no of broadcasting transports */ 80 #define INITTIME 4000 /* Time to wait initially */ 81 #define WAITTIME 8000 /* Maximum time to wait */ 82 83 /* 84 * If nettype is NULL, it broadcasts on all the available 85 * datagram_n transports. May potentially lead to broadacst storms 86 * and hence should be used with caution, care and courage. 87 * 88 * The current parameter xdr packet size is limited by the max tsdu 89 * size of the transport. If the max tsdu size of any transport is 90 * smaller than the parameter xdr packet, then broadcast is not 91 * sent on that transport. 92 * 93 * Also, the packet size should be less the packet size of 94 * the data link layer (for ethernet it is 1400 bytes). There is 95 * no easy way to find out the max size of the data link layer and 96 * we are assuming that the args would be smaller than that. 97 * 98 * The result size has to be smaller than the transport tsdu size. 99 * 100 * If PORTMAP has been defined, we send two packets for UDP, one for 101 * rpcbind and one for portmap. For those machines which support 102 * both rpcbind and portmap, it will cause them to reply twice, and 103 * also here it will get two responses ... inefficient and clumsy. 104 */ 105 106 struct broadif { 107 int index; 108 struct sockaddr_storage broadaddr; 109 TAILQ_ENTRY(broadif) link; 110 }; 111 112 typedef TAILQ_HEAD(, broadif) broadlist_t; 113 114 int __rpc_getbroadifs(int, int, int, broadlist_t *); 115 void __rpc_freebroadifs(broadlist_t *); 116 int __rpc_broadenable(int, int, struct broadif *); 117 118 int __rpc_lowvers = 0; 119 120 int 121 __rpc_getbroadifs(int af, int proto, int socktype, broadlist_t *list) 122 { 123 int count = 0; 124 struct broadif *bip; 125 struct ifaddrs *ifap, *ifp; 126 #ifdef INET6 127 struct sockaddr_in6 *sin6; 128 #endif 129 struct sockaddr_in *sin; 130 struct addrinfo hints, *res; 131 132 if (getifaddrs(&ifp) < 0) 133 return 0; 134 135 memset(&hints, 0, sizeof hints); 136 137 hints.ai_family = af; 138 hints.ai_protocol = proto; 139 hints.ai_socktype = socktype; 140 141 if (getaddrinfo(NULL, "sunrpc", &hints, &res) != 0) { 142 freeifaddrs(ifp); 143 return 0; 144 } 145 146 for (ifap = ifp; ifap != NULL; ifap = ifap->ifa_next) { 147 if (ifap->ifa_addr->sa_family != af || 148 !(ifap->ifa_flags & IFF_UP)) 149 continue; 150 bip = (struct broadif *)malloc(sizeof *bip); 151 if (bip == NULL) 152 break; 153 bip->index = if_nametoindex(ifap->ifa_name); 154 if ( 155 #ifdef INET6 156 af != AF_INET6 && 157 #endif 158 (ifap->ifa_flags & IFF_BROADCAST) && 159 ifap->ifa_broadaddr) { 160 memcpy(&bip->broadaddr, ifap->ifa_broadaddr, 161 (size_t)ifap->ifa_broadaddr->sa_len); 162 sin = (struct sockaddr_in *)(void *)&bip->broadaddr; 163 sin->sin_port = 164 ((struct sockaddr_in *) 165 (void *)res->ai_addr)->sin_port; 166 } else 167 #ifdef INET6 168 if (af == AF_INET6 && (ifap->ifa_flags & IFF_MULTICAST)) { 169 sin6 = (struct sockaddr_in6 *)(void *)&bip->broadaddr; 170 inet_pton(af, RPCB_MULTICAST_ADDR, &sin6->sin6_addr); 171 sin6->sin6_family = af; 172 sin6->sin6_len = sizeof *sin6; 173 sin6->sin6_port = 174 ((struct sockaddr_in6 *) 175 (void *)res->ai_addr)->sin6_port; 176 sin6->sin6_scope_id = bip->index; 177 } else 178 #endif 179 { 180 free(bip); 181 continue; 182 } 183 TAILQ_INSERT_TAIL(list, bip, link); 184 count++; 185 } 186 freeifaddrs(ifp); 187 freeaddrinfo(res); 188 189 return count; 190 } 191 192 void 193 __rpc_freebroadifs(broadlist_t *list) 194 { 195 struct broadif *bip, *next; 196 197 bip = TAILQ_FIRST(list); 198 199 while (bip != NULL) { 200 next = TAILQ_NEXT(bip, link); 201 free(bip); 202 bip = next; 203 } 204 } 205 206 int 207 /*ARGSUSED*/ 208 __rpc_broadenable(int af, int s, struct broadif *bip) 209 { 210 int o = 1; 211 212 #if 0 213 if (af == AF_INET6) { 214 fprintf(stderr, "set v6 multicast if to %d\n", bip->index); 215 if (_setsockopt(s, IPPROTO_IPV6, IPV6_MULTICAST_IF, &bip->index, 216 sizeof bip->index) < 0) 217 return -1; 218 } else 219 #endif 220 if (_setsockopt(s, SOL_SOCKET, SO_BROADCAST, &o, sizeof o) < 0) 221 return -1; 222 223 return 0; 224 } 225 226 /* 227 * rpc_broadcast_exp() 228 * 229 * prog - program number 230 * vers - version number 231 * proc - procedure number 232 * xargs - xdr routine for args 233 * argsp - pointer to args 234 * xresults - xdr routine for results 235 * resultsp - pointer to results 236 * eachresult - call with each result obtained 237 * inittime - how long to wait initially 238 * waittime - maximum time to wait 239 * nettype - transport type 240 */ 241 enum clnt_stat 242 rpc_broadcast_exp(rpcprog_t prog, rpcvers_t vers, rpcproc_t proc, 243 xdrproc_t xargs, caddr_t argsp, xdrproc_t xresults, caddr_t resultsp, 244 resultproc_t eachresult, int inittime, int waittime, 245 const char *nettype) 246 { 247 enum clnt_stat stat = RPC_SUCCESS; /* Return status */ 248 XDR xdr_stream; /* XDR stream */ 249 XDR *xdrs = &xdr_stream; 250 struct rpc_msg msg; /* RPC message */ 251 struct timeval t; 252 char *outbuf = NULL; /* Broadcast msg buffer */ 253 char *inbuf = NULL; /* Reply buf */ 254 int inlen; 255 u_int maxbufsize = 0; 256 AUTH *sys_auth = authunix_create_default(); 257 u_int i; 258 void *handle; 259 char uaddress[1024]; /* A self imposed limit */ 260 char *uaddrp = uaddress; 261 int pmap_reply_flag; /* reply recvd from PORTMAP */ 262 /* An array of all the suitable broadcast transports */ 263 struct { 264 int fd; /* File descriptor */ 265 int af; 266 int proto; 267 struct netconfig *nconf; /* Netconfig structure */ 268 u_int asize; /* Size of the addr buf */ 269 u_int dsize; /* Size of the data buf */ 270 struct sockaddr_storage raddr; /* Remote address */ 271 broadlist_t nal; 272 } fdlist[MAXBCAST]; 273 struct pollfd pfd[MAXBCAST]; 274 size_t fdlistno = 0; 275 struct r_rpcb_rmtcallargs barg; /* Remote arguments */ 276 struct r_rpcb_rmtcallres bres; /* Remote results */ 277 size_t outlen; 278 struct netconfig *nconf; 279 int msec; 280 int pollretval; 281 int fds_found; 282 283 #ifdef PORTMAP 284 size_t outlen_pmap = 0; 285 u_long port; /* Remote port number */ 286 int pmap_flag = 0; /* UDP exists ? */ 287 char *outbuf_pmap = NULL; 288 struct rmtcallargs barg_pmap; /* Remote arguments */ 289 struct rmtcallres bres_pmap; /* Remote results */ 290 u_int udpbufsz = 0; 291 #endif /* PORTMAP */ 292 293 if (sys_auth == NULL) { 294 return (RPC_SYSTEMERROR); 295 } 296 /* 297 * initialization: create a fd, a broadcast address, and send the 298 * request on the broadcast transport. 299 * Listen on all of them and on replies, call the user supplied 300 * function. 301 */ 302 303 if (nettype == NULL) 304 nettype = "datagram_n"; 305 if ((handle = __rpc_setconf(nettype)) == NULL) { 306 AUTH_DESTROY(sys_auth); 307 return (RPC_UNKNOWNPROTO); 308 } 309 while ((nconf = __rpc_getconf(handle)) != NULL) { 310 int fd; 311 struct __rpc_sockinfo si; 312 313 if (nconf->nc_semantics != NC_TPI_CLTS) 314 continue; 315 if (fdlistno >= MAXBCAST) 316 break; /* No more slots available */ 317 if (!__rpc_nconf2sockinfo(nconf, &si)) 318 continue; 319 320 TAILQ_INIT(&fdlist[fdlistno].nal); 321 if (__rpc_getbroadifs(si.si_af, si.si_proto, si.si_socktype, 322 &fdlist[fdlistno].nal) == 0) 323 continue; 324 325 fd = _socket(si.si_af, si.si_socktype, si.si_proto); 326 if (fd < 0) { 327 stat = RPC_CANTSEND; 328 continue; 329 } 330 fdlist[fdlistno].af = si.si_af; 331 fdlist[fdlistno].proto = si.si_proto; 332 fdlist[fdlistno].fd = fd; 333 fdlist[fdlistno].nconf = nconf; 334 fdlist[fdlistno].asize = __rpc_get_a_size(si.si_af); 335 pfd[fdlistno].events = POLLIN | POLLPRI | 336 POLLRDNORM | POLLRDBAND; 337 pfd[fdlistno].fd = fdlist[fdlistno].fd = fd; 338 fdlist[fdlistno].dsize = __rpc_get_t_size(si.si_af, si.si_proto, 339 0); 340 341 if (maxbufsize <= fdlist[fdlistno].dsize) 342 maxbufsize = fdlist[fdlistno].dsize; 343 344 #ifdef PORTMAP 345 if (si.si_af == AF_INET && si.si_proto == IPPROTO_UDP) { 346 udpbufsz = fdlist[fdlistno].dsize; 347 outbuf_pmap = reallocf(outbuf_pmap, udpbufsz); 348 if (outbuf_pmap == NULL) { 349 _close(fd); 350 stat = RPC_SYSTEMERROR; 351 goto done_broad; 352 } 353 pmap_flag = 1; 354 } 355 #endif /* PORTMAP */ 356 fdlistno++; 357 } 358 359 if (fdlistno == 0) { 360 if (stat == RPC_SUCCESS) 361 stat = RPC_UNKNOWNPROTO; 362 goto done_broad; 363 } 364 if (maxbufsize == 0) { 365 if (stat == RPC_SUCCESS) 366 stat = RPC_CANTSEND; 367 goto done_broad; 368 } 369 inbuf = malloc(maxbufsize); 370 outbuf = malloc(maxbufsize); 371 if ((inbuf == NULL) || (outbuf == NULL)) { 372 stat = RPC_SYSTEMERROR; 373 goto done_broad; 374 } 375 376 /* Serialize all the arguments which have to be sent */ 377 (void) gettimeofday(&t, NULL); 378 msg.rm_xid = __RPC_GETXID(&t); 379 msg.rm_direction = CALL; 380 msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; 381 msg.rm_call.cb_prog = RPCBPROG; 382 msg.rm_call.cb_vers = RPCBVERS; 383 msg.rm_call.cb_proc = RPCBPROC_CALLIT; 384 barg.prog = prog; 385 barg.vers = vers; 386 barg.proc = proc; 387 barg.args.args_val = argsp; 388 barg.xdr_args = xargs; 389 bres.addr = uaddrp; 390 bres.results.results_val = resultsp; 391 bres.xdr_res = xresults; 392 msg.rm_call.cb_cred = sys_auth->ah_cred; 393 msg.rm_call.cb_verf = sys_auth->ah_verf; 394 xdrmem_create(xdrs, outbuf, maxbufsize, XDR_ENCODE); 395 if ((!xdr_callmsg(xdrs, &msg)) || 396 (!xdr_rpcb_rmtcallargs(xdrs, 397 (struct rpcb_rmtcallargs *)(void *)&barg))) { 398 stat = RPC_CANTENCODEARGS; 399 goto done_broad; 400 } 401 outlen = xdr_getpos(xdrs); 402 xdr_destroy(xdrs); 403 404 #ifdef PORTMAP 405 /* Prepare the packet for version 2 PORTMAP */ 406 if (pmap_flag) { 407 msg.rm_xid++; /* One way to distinguish */ 408 msg.rm_call.cb_prog = PMAPPROG; 409 msg.rm_call.cb_vers = PMAPVERS; 410 msg.rm_call.cb_proc = PMAPPROC_CALLIT; 411 barg_pmap.prog = prog; 412 barg_pmap.vers = vers; 413 barg_pmap.proc = proc; 414 barg_pmap.args_ptr = argsp; 415 barg_pmap.xdr_args = xargs; 416 bres_pmap.port_ptr = &port; 417 bres_pmap.xdr_results = xresults; 418 bres_pmap.results_ptr = resultsp; 419 xdrmem_create(xdrs, outbuf_pmap, udpbufsz, XDR_ENCODE); 420 if ((! xdr_callmsg(xdrs, &msg)) || 421 (! xdr_rmtcall_args(xdrs, &barg_pmap))) { 422 stat = RPC_CANTENCODEARGS; 423 goto done_broad; 424 } 425 outlen_pmap = xdr_getpos(xdrs); 426 xdr_destroy(xdrs); 427 } 428 #endif /* PORTMAP */ 429 430 /* 431 * Basic loop: broadcast the packets to transports which 432 * support data packets of size such that one can encode 433 * all the arguments. 434 * Wait a while for response(s). 435 * The response timeout grows larger per iteration. 436 */ 437 for (msec = inittime; msec <= waittime; msec += msec) { 438 struct broadif *bip; 439 440 /* Broadcast all the packets now */ 441 for (i = 0; i < fdlistno; i++) { 442 if (fdlist[i].dsize < outlen) { 443 stat = RPC_CANTSEND; 444 continue; 445 } 446 for (bip = TAILQ_FIRST(&fdlist[i].nal); bip != NULL; 447 bip = TAILQ_NEXT(bip, link)) { 448 void *addr; 449 450 addr = &bip->broadaddr; 451 452 __rpc_broadenable(fdlist[i].af, fdlist[i].fd, 453 bip); 454 455 /* 456 * Only use version 3 if lowvers is not set 457 */ 458 459 if (!__rpc_lowvers) 460 if (_sendto(fdlist[i].fd, outbuf, 461 outlen, 0, (struct sockaddr*)addr, 462 (size_t)fdlist[i].asize) != 463 outlen) { 464 #ifdef RPC_DEBUG 465 perror("sendto"); 466 #endif 467 warnx("clnt_bcast: cannot send " 468 "broadcast packet"); 469 stat = RPC_CANTSEND; 470 continue; 471 } 472 #ifdef RPC_DEBUG 473 if (!__rpc_lowvers) 474 fprintf(stderr, "Broadcast packet sent " 475 "for %s\n", 476 fdlist[i].nconf->nc_netid); 477 #endif 478 #ifdef PORTMAP 479 /* 480 * Send the version 2 packet also 481 * for UDP/IP 482 */ 483 if (pmap_flag && 484 fdlist[i].proto == IPPROTO_UDP) { 485 if (_sendto(fdlist[i].fd, outbuf_pmap, 486 outlen_pmap, 0, addr, 487 (size_t)fdlist[i].asize) != 488 outlen_pmap) { 489 warnx("clnt_bcast: " 490 "Cannot send broadcast packet"); 491 stat = RPC_CANTSEND; 492 continue; 493 } 494 } 495 #ifdef RPC_DEBUG 496 fprintf(stderr, "PMAP Broadcast packet " 497 "sent for %s\n", 498 fdlist[i].nconf->nc_netid); 499 #endif 500 #endif /* PORTMAP */ 501 } 502 /* End for sending all packets on this transport */ 503 } /* End for sending on all transports */ 504 505 if (eachresult == NULL) { 506 stat = RPC_SUCCESS; 507 goto done_broad; 508 } 509 510 /* 511 * Get all the replies from these broadcast requests 512 */ 513 recv_again: 514 515 switch (pollretval = _poll(pfd, fdlistno, msec)) { 516 case 0: /* timed out */ 517 stat = RPC_TIMEDOUT; 518 continue; 519 case -1: /* some kind of error - we ignore it */ 520 goto recv_again; 521 } /* end of poll results switch */ 522 523 for (i = fds_found = 0; 524 i < fdlistno && fds_found < pollretval; i++) { 525 bool_t done = FALSE; 526 527 if (pfd[i].revents == 0) 528 continue; 529 else if (pfd[i].revents & POLLNVAL) { 530 /* 531 * Something bad has happened to this descri- 532 * ptor. We can cause _poll() to ignore 533 * it simply by using a negative fd. We do that 534 * rather than compacting the pfd[] and fdlist[] 535 * arrays. 536 */ 537 pfd[i].fd = -1; 538 fds_found++; 539 continue; 540 } else 541 fds_found++; 542 #ifdef RPC_DEBUG 543 fprintf(stderr, "response for %s\n", 544 fdlist[i].nconf->nc_netid); 545 #endif 546 try_again: 547 inlen = _recvfrom(fdlist[i].fd, inbuf, fdlist[i].dsize, 548 0, (struct sockaddr *)(void *)&fdlist[i].raddr, 549 &fdlist[i].asize); 550 if (inlen < 0) { 551 if (errno == EINTR) 552 goto try_again; 553 warnx("clnt_bcast: Cannot receive reply to " 554 "broadcast"); 555 stat = RPC_CANTRECV; 556 continue; 557 } 558 if (inlen < sizeof (u_int32_t)) 559 continue; /* Drop that and go ahead */ 560 /* 561 * see if reply transaction id matches sent id. 562 * If so, decode the results. If return id is xid + 1 563 * it was a PORTMAP reply 564 */ 565 if (*((u_int32_t *)(void *)(inbuf)) == 566 *((u_int32_t *)(void *)(outbuf))) { 567 pmap_reply_flag = 0; 568 msg.acpted_rply.ar_verf = _null_auth; 569 msg.acpted_rply.ar_results.where = 570 (caddr_t)(void *)&bres; 571 msg.acpted_rply.ar_results.proc = 572 (xdrproc_t)xdr_rpcb_rmtcallres; 573 #ifdef PORTMAP 574 } else if (pmap_flag && 575 *((u_int32_t *)(void *)(inbuf)) == 576 *((u_int32_t *)(void *)(outbuf_pmap))) { 577 pmap_reply_flag = 1; 578 msg.acpted_rply.ar_verf = _null_auth; 579 msg.acpted_rply.ar_results.where = 580 (caddr_t)(void *)&bres_pmap; 581 msg.acpted_rply.ar_results.proc = 582 (xdrproc_t)xdr_rmtcallres; 583 #endif /* PORTMAP */ 584 } else 585 continue; 586 xdrmem_create(xdrs, inbuf, (u_int)inlen, XDR_DECODE); 587 if (xdr_replymsg(xdrs, &msg)) { 588 if ((msg.rm_reply.rp_stat == MSG_ACCEPTED) && 589 (msg.acpted_rply.ar_stat == SUCCESS)) { 590 struct netbuf taddr, *np; 591 struct sockaddr_in *sin; 592 593 #ifdef PORTMAP 594 if (pmap_flag && pmap_reply_flag) { 595 sin = (struct sockaddr_in *) 596 (void *)&fdlist[i].raddr; 597 sin->sin_port = 598 htons((u_short)port); 599 taddr.len = taddr.maxlen = 600 fdlist[i].raddr.ss_len; 601 taddr.buf = &fdlist[i].raddr; 602 done = (*eachresult)(resultsp, 603 &taddr, fdlist[i].nconf); 604 } else { 605 #endif /* PORTMAP */ 606 #ifdef RPC_DEBUG 607 fprintf(stderr, "uaddr %s\n", 608 uaddrp); 609 #endif 610 np = uaddr2taddr( 611 fdlist[i].nconf, uaddrp); 612 done = (*eachresult)(resultsp, 613 np, fdlist[i].nconf); 614 free(np); 615 #ifdef PORTMAP 616 } 617 #endif /* PORTMAP */ 618 } 619 /* otherwise, we just ignore the errors ... */ 620 } 621 /* else some kind of deserialization problem ... */ 622 623 xdrs->x_op = XDR_FREE; 624 msg.acpted_rply.ar_results.proc = (xdrproc_t) xdr_void; 625 (void) xdr_replymsg(xdrs, &msg); 626 (void) (*xresults)(xdrs, resultsp); 627 XDR_DESTROY(xdrs); 628 if (done) { 629 stat = RPC_SUCCESS; 630 goto done_broad; 631 } else { 632 goto recv_again; 633 } 634 } /* The recv for loop */ 635 } /* The giant for loop */ 636 637 done_broad: 638 free(inbuf); 639 free(outbuf); 640 #ifdef PORTMAP 641 free(outbuf_pmap); 642 #endif /* PORTMAP */ 643 for (i = 0; i < fdlistno; i++) { 644 (void)_close(fdlist[i].fd); 645 __rpc_freebroadifs(&fdlist[i].nal); 646 } 647 AUTH_DESTROY(sys_auth); 648 (void) __rpc_endconf(handle); 649 650 return (stat); 651 } 652 653 /* 654 * rpc_broadcast() 655 * 656 * prog - program number 657 * vers - version number 658 * proc - procedure number 659 * xargs - xdr routine for args 660 * argsp - pointer to args 661 * xresults - xdr routine for results 662 * resultsp - pointer to results 663 * eachresult - call with each result obtained 664 * nettype - transport type 665 */ 666 enum clnt_stat 667 rpc_broadcast(rpcprog_t prog, rpcvers_t vers, rpcproc_t proc, xdrproc_t xargs, 668 caddr_t argsp, xdrproc_t xresults, caddr_t resultsp, 669 resultproc_t eachresult, const char *nettype) 670 { 671 enum clnt_stat dummy; 672 673 dummy = rpc_broadcast_exp(prog, vers, proc, xargs, argsp, 674 xresults, resultsp, eachresult, 675 INITTIME, WAITTIME, nettype); 676 return (dummy); 677 } 678