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