mirror of
https://sourceware.org/git/glibc.git
synced 2024-10-02 20:17:45 +00:00
1f205a479b
1997-05-21 02:49 Ulrich Drepper <drepper@cygnus.com> * gnu-versions.h (_GNU_OBSTACK_INTERFACE_VERSION): Set to 2 since interface was changed with addition of _obstack_memory_used. Suggested by Ian Taylor <ian@cygnus.com>. * malloc/obstack.c: Include <config.h>. Include <stdlib.h> only if __GNU_LIBRARY__ or HAVE_STDLIB_H is defined. Reported by Ian Taylor <ian@cygnus.com>. * dirent/Makefile (routines): Add versionsort. * dirent/dirent.h: Add prototype for versionsort. * dirent/versionsort.c: New file. * manual/filesys.texi: Add documentation for versionsort. * manual/string.texi: Add documentation for strverscmp. * string/Makefile (routines): Add strverscmp. (tests): Add tst-svc. * string/string.h: Add prototype for strverscmp. * string/strverscmp.c: New file. * string/tst-svc.c: New file. Test for strverscmp. * string/tst-svc.input: New file. Input data for tst-svc. * string/tst-svc.expect: New file. Expected out from tst-svc. * math/Makefile (calls): Add s_signbit. * po/sv.po: Update. * resolv/nss_dns/dns-host.c: Add casts to prevent warnings. * sunrpc/pmap_rmt.c: Likewise. * string/basename.c: Don't use ISO C definition style. Include <config.h> is HAVE_CONFIG_H is defined. * sunrpc/proto.h: Add `const' wherever possible. * sunrpc/rpc_cout.c: Likewise. * sunrpc/rpc_svcout.c: Likewise. * sunrpc/xdr_mem.c: Likewise. * sunrpc/xdr_rec.c: Likewise. * sunrpc/xdr_stdio.c: Likewise. * sunrpc/rpc_parse.c: Delete comma from end of enum definition. * sunrpc/xdr.c: Little code cleanups. * sunrpc/xdr_flaot.c: Likewise. Patches by Matthew Wilcox <matthew.wilcox@chbs.mhs.ciba.com>. * sysdeps/i386/fpu/__math.h (__finite): Fix typo. * sysdeps/unix/sysv/linux/shmdt.c: Add cast to prevent warning. * time/europe: Update from tzdata1997f. * time/zic.c: Update from tzcode1997e. 1997-05-20 19:20 Miguel de Icaza <miguel@athena.nuclecu.unam.mx> * sysdeps/sparc/setjmp.S: Flush windows. Bug found by Richard Henderson. 1997-05-19 12:54 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * misc/efgcvt_r.c (fcvt_r, ecvt_r): Rewritten as to fit the specs. 1997-05-19 18:41 Thorsten Kukuk <kukuk@uni-paderborn.de> * nis/nss_nisplus/nisplus-spwd.c (_nss_nisplus_parse_spent): Use atol instead of atoi. 1997-05-18 00:22 Philip Blundell <pjb27@cam.ac.uk> * inet/Makefile (routines): Add if_index. * sysdeps/unix/sysv/linux/if_index.c: New file. * sysdeps/stub/if_index.c: New file. * sysdeps/unix/sysv/linux/net/if.h: Add prototypes for routines in if_index.c (required by IPv6 basic API). * sysdeps/unix/sysv/linux/netinet/in.h: Add struct ipv6_pktinfo. 1997-05-17 23:29 Philip Blundell <pjb27@cam.ac.uk> * sysdeps/unix/sysv/linux/netinet/in.h: Update IPv6 definitions for new advanced API draft. 1997-05-13 21:33 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * stdio-common/printf_fp.c: Only use the field width for deciding on padding when printing special values. * stdio-common/printf_fphex.c: Likewise. 1997-05-15 13:14 Miles Bader <miles@gnu.ai.mit.edu> Changes by Thomas Bushnell <thomas@gnu.ai.mit.edu>: * hurd/hurdauth.c (_S_msg_add_auth): Implement correctly. 1997-05-12 14:50 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu> * hurd/hurdsig.c (_hurdsig_init): Double size of sigthread stack; msg_add_auth was overflowing it. 1997-05-12 21:20 Richard Henderson <rth@tamu.edu> * elf/dl-lookup.c (_dl_lookup_symbol_skip): Call _dl_signal_error when we can't find the symbol. 1997-05-12 16:54 Ulrich Drepper <drepper@cygnus.com> * posix/regex.c: Fix handling of 32-bit Windog environments. Patch by Arnold Robbins <arnold@skeeve.atl.ga.us>. 1997-05-10 23:26 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/unix/sysv/linux/m68k/syscalls.list: Add cacheflush. 1997-05-10 11:40 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * elf/ldd.bash.in: Remove spurious quote character from version message. 1997-05-10 08:49 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * locale/programs/locale.c (write_charmaps): Don't get stuck in a loop if the file ends in a long line without newline. * locale/programs/charmap.c (charmap_read): Likewise. 1997-05-12 03:47 Ulrich Drepper <drepper@cygnus.com> * sunrpc/rpc/xdr.h: Include more headers to be self-contained. * sunrpc/rpc/svc_auth.h: Likewise. * sunrpc/rpc/svc.h: Likewise. * sunrpc/rpc/rpc_msg.h: Likewise. * sunrpc/rpc/pmap_rmt.h: Likewise. * sunrpc/rpc/pmap_clnt.h: Likewise. * sunrpc/rpc/clnt.h: Likewise. * sunrpc/rpc/auth_unix.h: Likewise. * sysdeps/generic/rpc/auth.h: Likewise. Patches by Michael Deutschmann <ldeutsch@mail.netshop.net>. 1997-05-11 15:29 Philip Blundell <pjb27@cam.ac.uk> * sysdeps/stub/sigaction.c (__sigaction): Correct typo. * sysdeps/standalone/arm/errnos.h: New file. * sysdeps/stub/sys/param.h: Add dummy definition of MAXSYMLINKS. * sysdeps/unix/arm/fork.S: New file. * sysdeps/unix/sysv/linux/arm/sysdep.h: New file. * sysdeps/stub/tempname.c (__stdio_gen_tempname): Add missing `streamptr' argument. * sysdeps/stub/vdprintf.c: Remove second copy of file (!), include <stdarg.h> to get va_list defined, return 0 not NULL. * sysdeps/unix/sysv/linux/statfsbuf.h: Include <gnu/types.h>. * sysdeps/unix/sysv/linux/arm/syscall.S: New file. * sysdeps/stub/direntry.h (struct dirent): Add missing ';'. * sysdeps/stub/seekdir.c (seekdir): Likewise. * sysdeps/stub/dirfd.c (dirfd): Argument dirp is DIR*, not FILE*. * sysdeps/standalone/dirstream.h: Define struct __dirstream not DIR; <dirent.h> provides typedef. * sysdeps/unix/sysv/linux/arm/clone.S: New file. * sysdeps/unix/sysv/linux/arm/socket.S: New file. * sysdeps/stub/sysconf.c (__sysconf): Fix typos. 1997-05-01 06:35 Geoff Keating <geoffk@ozemail.com.au> * sysdeps/powerpc/Dist: New file. * sysdeps/powerpc/Makefile: New file. * sysdeps/powerpc/fclrexcpt.c: New file. * sysdeps/powerpc/fegetenv.c: New file. * sysdeps/powerpc/fegetround.c: New file. * sysdeps/powerpc/feholdexcpt.c: New file. * sysdeps/powerpc/fenvbits.h: New file. * sysdeps/powerpc/fenv_const.c: New file. * sysdeps/powerpc/fenv_libc.h: New file. * sysdeps/powerpc/fesetenv.c: New file. * sysdeps/powerpc/fesetround.c: New file. * sysdeps/powerpc/feupdateenv.c: New file. * sysdeps/powerpc/fgetexcptflg.c: New file. * sysdeps/powerpc/fraiseexcpt.c: New file. * sysdeps/powerpc/fsetexcptflg.c: New file. * sysdeps/powerpc/ftestexcept.c: New file. * sysdeps/powerpc/mathbits.h: New file. * sysdeps/powerpc/dl-machine.h: Wrap in #ifndef dl_machine_h; define elf_machine_lookup_noexec_p, elf_machine_lookup_noplt_p, ELF_MACHINE_RELOC_NOPLT; consequent changes to elf_machine_rela. * sysdeps/powerpc/__math.h: Remove definition for hypot and __sgn. * sysdep/powerpc/fpu_control.h: Correct IEEE default mode. * sysdeps/unix/sysv/linux/powerpc/sysdep.h: Don't use .text, but instead .section ".text". 1997-04-25 05:06 Geoff Keating <geoffk@ozemail.com.au> * sysdeps/powerpc/__longjmp.S: Use symbolic register numbering. * sysdeps/powerpc/bsd-_setjmp.S: Likewise. * sysdeps/powerpc/bsd-setjmp.S: Likewise. * sysdeps/powerpc/setjmp.S: Likewise. * sysdeps/unix/sysv/linux/clone.S: Likewise. * sysdeps/unix/sysv/linux/socket.S: Likewise. * sysdeps/unix/sysv/linux/syscall.S: Likewise. 1997-04-20 04:37 Geoff Keating <geoffk@ozemail.com.au> * sysdeps/powerpc/strchr.s: New file. * sysdeps/powerpc/strcmp.s: New (ugly) file. * sysdeps/powerpc/memset.s: New file. * string/tester.c: Include prototype and _GNU_SOURCE to make standalone compilation possible. Give strcmp a better test. Give memset a better test. 1997-04-05 06:34 Geoff Keating <geoffk@ozemail.com.au> * sysdeps/powerpc/strlen.s: Fixed bugs (how did it ever pass its tests before?). Changed to symbolic register numbering as an experiment. * sysdeps/powerpc/ffs.c: Don't include bstring.h, it doesn't exist. * sysdeps/rs6000/ffs.c: Likewise. 1997-05-12 02:28 Ulrich Drepper <drepper@cygnus.com> * time/sys/time.h: Make second argument of setitimer const. Patch by Michael Deutschmann <ldeutsch@mail.netshop.net>. * sysdeps/stub/setitimer.c: Likewise. * sysdeps/mach/hurd/setitimer.c: Likewise.
420 lines
12 KiB
C
420 lines
12 KiB
C
/* @(#)pmap_rmt.c 2.2 88/08/01 4.0 RPCSRC */
|
|
/*
|
|
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
|
* unrestricted use provided that this legend is included on all tape
|
|
* media and as a part of the software program in whole or part. Users
|
|
* may copy or modify Sun RPC without charge, but are not authorized
|
|
* to license or distribute it to anyone else except as part of a product or
|
|
* program developed by the user.
|
|
*
|
|
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
|
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
|
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
|
|
*
|
|
* Sun RPC is provided with no support and without any obligation on the
|
|
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
|
* modification or enhancement.
|
|
*
|
|
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
|
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
|
* OR ANY PART THEREOF.
|
|
*
|
|
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
|
* or profits or other special, indirect and consequential damages, even if
|
|
* Sun has been advised of the possibility of such damages.
|
|
*
|
|
* Sun Microsystems, Inc.
|
|
* 2550 Garcia Avenue
|
|
* Mountain View, California 94043
|
|
*/
|
|
#if !defined(lint) && defined(SCCSIDS)
|
|
static char sccsid[] = "@(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro";
|
|
#endif
|
|
|
|
/*
|
|
* pmap_rmt.c
|
|
* Client interface to pmap rpc service.
|
|
* remote call and broadcast service
|
|
*
|
|
* Copyright (C) 1984, Sun Microsystems, Inc.
|
|
*/
|
|
|
|
#include <unistd.h>
|
|
#include <string.h>
|
|
#include <rpc/rpc.h>
|
|
#include <rpc/pmap_prot.h>
|
|
#include <rpc/pmap_clnt.h>
|
|
#include <rpc/pmap_rmt.h>
|
|
#include <sys/socket.h>
|
|
#include <stdio.h>
|
|
#include <errno.h>
|
|
#undef _POSIX_SOURCE /* Ultrix <sys/param.h> needs --roland@gnu */
|
|
#include <sys/param.h> /* Ultrix needs before net/if --roland@gnu */
|
|
#include <net/if.h>
|
|
#include <sys/ioctl.h>
|
|
#include <arpa/inet.h>
|
|
#define MAX_BROADCAST_SIZE 1400
|
|
|
|
static struct timeval timeout = {3, 0};
|
|
|
|
/*
|
|
* pmapper remote-call-service interface.
|
|
* This routine is used to call the pmapper remote call service
|
|
* which will look up a service program in the port maps, and then
|
|
* remotely call that routine with the given parameters. This allows
|
|
* programs to do a lookup and call in one step.
|
|
*/
|
|
enum clnt_stat
|
|
pmap_rmtcall (addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, port_ptr)
|
|
struct sockaddr_in *addr;
|
|
u_long prog, vers, proc;
|
|
xdrproc_t xdrargs, xdrres;
|
|
caddr_t argsp, resp;
|
|
struct timeval tout;
|
|
u_long *port_ptr;
|
|
{
|
|
int socket = -1;
|
|
CLIENT *client;
|
|
struct rmtcallargs a;
|
|
struct rmtcallres r;
|
|
enum clnt_stat stat;
|
|
|
|
addr->sin_port = htons (PMAPPORT);
|
|
client = clntudp_create (addr, PMAPPROG, PMAPVERS, timeout, &socket);
|
|
if (client != (CLIENT *) NULL)
|
|
{
|
|
a.prog = prog;
|
|
a.vers = vers;
|
|
a.proc = proc;
|
|
a.args_ptr = argsp;
|
|
a.xdr_args = xdrargs;
|
|
r.port_ptr = port_ptr;
|
|
r.results_ptr = resp;
|
|
r.xdr_results = xdrres;
|
|
stat = CLNT_CALL (client, PMAPPROC_CALLIT, (xdrproc_t)xdr_rmtcall_args,
|
|
(caddr_t)&a, (xdrproc_t)xdr_rmtcallres,
|
|
(caddr_t)&r, tout);
|
|
CLNT_DESTROY (client);
|
|
}
|
|
else
|
|
{
|
|
stat = RPC_FAILED;
|
|
}
|
|
/* (void)close(socket); CLNT_DESTROY already closed it */
|
|
addr->sin_port = 0;
|
|
return stat;
|
|
}
|
|
|
|
|
|
/*
|
|
* XDR remote call arguments
|
|
* written for XDR_ENCODE direction only
|
|
*/
|
|
bool_t
|
|
xdr_rmtcall_args (xdrs, cap)
|
|
XDR *xdrs;
|
|
struct rmtcallargs *cap;
|
|
{
|
|
u_int lenposition, argposition, position;
|
|
|
|
if (xdr_u_long (xdrs, &(cap->prog)) &&
|
|
xdr_u_long (xdrs, &(cap->vers)) &&
|
|
xdr_u_long (xdrs, &(cap->proc)))
|
|
{
|
|
lenposition = XDR_GETPOS (xdrs);
|
|
if (!xdr_u_long (xdrs, &(cap->arglen)))
|
|
return FALSE;
|
|
argposition = XDR_GETPOS (xdrs);
|
|
if (!(*(cap->xdr_args)) (xdrs, cap->args_ptr))
|
|
return FALSE;
|
|
position = XDR_GETPOS (xdrs);
|
|
cap->arglen = (u_long) position - (u_long) argposition;
|
|
XDR_SETPOS (xdrs, lenposition);
|
|
if (!xdr_u_long (xdrs, &(cap->arglen)))
|
|
return FALSE;
|
|
XDR_SETPOS (xdrs, position);
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
/*
|
|
* XDR remote call results
|
|
* written for XDR_DECODE direction only
|
|
*/
|
|
bool_t
|
|
xdr_rmtcallres (xdrs, crp)
|
|
XDR *xdrs;
|
|
struct rmtcallres *crp;
|
|
{
|
|
caddr_t port_ptr;
|
|
|
|
port_ptr = (caddr_t) crp->port_ptr;
|
|
if (xdr_reference (xdrs, &port_ptr, sizeof (u_long), (xdrproc_t) xdr_u_long)
|
|
&& xdr_u_long (xdrs, &crp->resultslen))
|
|
{
|
|
crp->port_ptr = (u_long *) port_ptr;
|
|
return (*(crp->xdr_results)) (xdrs, crp->results_ptr);
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
/*
|
|
* The following is kludged-up support for simple rpc broadcasts.
|
|
* Someday a large, complicated system will replace these trivial
|
|
* routines which only support udp/ip .
|
|
*/
|
|
|
|
static int
|
|
getbroadcastnets (struct in_addr *addrs, int sock, char *buf)
|
|
/* int sock: any valid socket will do */
|
|
/* char *buf: why allocate more when we can use existing... */
|
|
{
|
|
struct ifconf ifc;
|
|
struct ifreq ifreq, *ifr;
|
|
struct sockaddr_in *sin;
|
|
int n, i;
|
|
|
|
ifc.ifc_len = UDPMSGSIZE;
|
|
ifc.ifc_buf = buf;
|
|
if (ioctl (sock, SIOCGIFCONF, (char *) &ifc) < 0)
|
|
{
|
|
perror (_("broadcast: ioctl (get interface configuration)"));
|
|
return (0);
|
|
}
|
|
ifr = ifc.ifc_req;
|
|
for (i = 0, n = ifc.ifc_len / sizeof (struct ifreq); n > 0; n--, ifr++)
|
|
{
|
|
ifreq = *ifr;
|
|
if (ioctl (sock, SIOCGIFFLAGS, (char *) &ifreq) < 0)
|
|
{
|
|
perror (_("broadcast: ioctl (get interface flags)"));
|
|
continue;
|
|
}
|
|
if ((ifreq.ifr_flags & IFF_BROADCAST) &&
|
|
(ifreq.ifr_flags & IFF_UP) &&
|
|
ifr->ifr_addr.sa_family == AF_INET)
|
|
{
|
|
sin = (struct sockaddr_in *) &ifr->ifr_addr;
|
|
#ifdef SIOCGIFBRDADDR /* 4.3BSD */
|
|
if (ioctl (sock, SIOCGIFBRDADDR, (char *) &ifreq) < 0)
|
|
{
|
|
addrs[i++] = inet_makeaddr (inet_netof
|
|
/* Changed to pass struct instead of s_addr member
|
|
by roland@gnu. */
|
|
(sin->sin_addr), INADDR_ANY);
|
|
}
|
|
else
|
|
{
|
|
addrs[i++] = ((struct sockaddr_in *)
|
|
&ifreq.ifr_addr)->sin_addr;
|
|
}
|
|
#else /* 4.2 BSD */
|
|
addrs[i++] = inet_makeaddr (inet_netof
|
|
(sin->sin_addr.s_addr), INADDR_ANY);
|
|
#endif
|
|
}
|
|
}
|
|
return i;
|
|
}
|
|
|
|
|
|
enum clnt_stat
|
|
clnt_broadcast (prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
|
|
u_long prog; /* program number */
|
|
u_long vers; /* version number */
|
|
u_long proc; /* procedure number */
|
|
xdrproc_t xargs; /* xdr routine for args */
|
|
caddr_t argsp; /* pointer to args */
|
|
xdrproc_t xresults; /* xdr routine for results */
|
|
caddr_t resultsp; /* pointer to results */
|
|
resultproc_t eachresult; /* call with each result obtained */
|
|
{
|
|
enum clnt_stat stat;
|
|
AUTH *unix_auth = authunix_create_default ();
|
|
XDR xdr_stream;
|
|
XDR *xdrs = &xdr_stream;
|
|
int outlen, inlen, fromlen, nets;
|
|
int sock;
|
|
int on = 1;
|
|
#ifdef FD_SETSIZE
|
|
fd_set mask;
|
|
fd_set readfds;
|
|
#else
|
|
int readfds;
|
|
int mask;
|
|
#endif /* def FD_SETSIZE */
|
|
int i;
|
|
bool_t done = FALSE;
|
|
u_long xid;
|
|
u_long port;
|
|
struct in_addr addrs[20];
|
|
struct sockaddr_in baddr, raddr; /* broadcast and response addresses */
|
|
struct rmtcallargs a;
|
|
struct rmtcallres r;
|
|
struct rpc_msg msg;
|
|
struct timeval t, t1;
|
|
char outbuf[MAX_BROADCAST_SIZE], inbuf[UDPMSGSIZE];
|
|
|
|
/*
|
|
* initialization: create a socket, a broadcast address, and
|
|
* preserialize the arguments into a send buffer.
|
|
*/
|
|
if ((sock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
|
|
{
|
|
perror (_("Cannot create socket for broadcast rpc"));
|
|
stat = RPC_CANTSEND;
|
|
goto done_broad;
|
|
}
|
|
#ifdef SO_BROADCAST
|
|
if (setsockopt (sock, SOL_SOCKET, SO_BROADCAST, &on, sizeof (on)) < 0)
|
|
{
|
|
perror (_("Cannot set socket option SO_BROADCAST"));
|
|
stat = RPC_CANTSEND;
|
|
goto done_broad;
|
|
}
|
|
#endif /* def SO_BROADCAST */
|
|
#ifdef FD_SETSIZE
|
|
FD_ZERO (&mask);
|
|
FD_SET (sock, &mask);
|
|
#else
|
|
mask = (1 << sock);
|
|
#endif /* def FD_SETSIZE */
|
|
nets = getbroadcastnets (addrs, sock, inbuf);
|
|
bzero ((char *) &baddr, sizeof (baddr));
|
|
baddr.sin_family = AF_INET;
|
|
baddr.sin_port = htons (PMAPPORT);
|
|
baddr.sin_addr.s_addr = htonl (INADDR_ANY);
|
|
/* baddr.sin_addr.S_un.S_addr = htonl(INADDR_ANY); */
|
|
(void) gettimeofday (&t, (struct timezone *) 0);
|
|
msg.rm_xid = xid = getpid () ^ t.tv_sec ^ t.tv_usec;
|
|
t.tv_usec = 0;
|
|
msg.rm_direction = CALL;
|
|
msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
|
|
msg.rm_call.cb_prog = PMAPPROG;
|
|
msg.rm_call.cb_vers = PMAPVERS;
|
|
msg.rm_call.cb_proc = PMAPPROC_CALLIT;
|
|
msg.rm_call.cb_cred = unix_auth->ah_cred;
|
|
msg.rm_call.cb_verf = unix_auth->ah_verf;
|
|
a.prog = prog;
|
|
a.vers = vers;
|
|
a.proc = proc;
|
|
a.xdr_args = xargs;
|
|
a.args_ptr = argsp;
|
|
r.port_ptr = &port;
|
|
r.xdr_results = xresults;
|
|
r.results_ptr = resultsp;
|
|
xdrmem_create (xdrs, outbuf, MAX_BROADCAST_SIZE, XDR_ENCODE);
|
|
if ((!xdr_callmsg (xdrs, &msg)) || (!xdr_rmtcall_args (xdrs, &a)))
|
|
{
|
|
stat = RPC_CANTENCODEARGS;
|
|
goto done_broad;
|
|
}
|
|
outlen = (int) xdr_getpos (xdrs);
|
|
xdr_destroy (xdrs);
|
|
/*
|
|
* Basic loop: broadcast a packet and wait a while for response(s).
|
|
* The response timeout grows larger per iteration.
|
|
*/
|
|
for (t.tv_sec = 4; t.tv_sec <= 14; t.tv_sec += 2)
|
|
{
|
|
for (i = 0; i < nets; i++)
|
|
{
|
|
baddr.sin_addr = addrs[i];
|
|
if (sendto (sock, outbuf, outlen, 0,
|
|
(struct sockaddr *) &baddr,
|
|
sizeof (struct sockaddr)) != outlen)
|
|
{
|
|
perror (_("Cannot send broadcast packet"));
|
|
stat = RPC_CANTSEND;
|
|
goto done_broad;
|
|
}
|
|
}
|
|
if (eachresult == NULL)
|
|
{
|
|
stat = RPC_SUCCESS;
|
|
goto done_broad;
|
|
}
|
|
recv_again:
|
|
msg.acpted_rply.ar_verf = _null_auth;
|
|
msg.acpted_rply.ar_results.where = (caddr_t) & r;
|
|
msg.acpted_rply.ar_results.proc = (xdrproc_t) xdr_rmtcallres;
|
|
readfds = mask;
|
|
t1 = t;
|
|
switch (select (_rpc_dtablesize (), &readfds, (fd_set *) NULL,
|
|
(fd_set *) NULL, &t1))
|
|
{
|
|
|
|
case 0: /* timed out */
|
|
stat = RPC_TIMEDOUT;
|
|
continue;
|
|
|
|
case -1: /* some kind of error */
|
|
if (errno == EINTR)
|
|
goto recv_again;
|
|
perror (_("Broadcast select problem"));
|
|
stat = RPC_CANTRECV;
|
|
goto done_broad;
|
|
|
|
} /* end of select results switch */
|
|
try_again:
|
|
fromlen = sizeof (struct sockaddr);
|
|
inlen = recvfrom (sock, inbuf, UDPMSGSIZE, 0,
|
|
(struct sockaddr *) &raddr, &fromlen);
|
|
if (inlen < 0)
|
|
{
|
|
if (errno == EINTR)
|
|
goto try_again;
|
|
perror (_("Cannot receive reply to broadcast"));
|
|
stat = RPC_CANTRECV;
|
|
goto done_broad;
|
|
}
|
|
if ((size_t) inlen < sizeof (u_long))
|
|
goto recv_again;
|
|
/*
|
|
* see if reply transaction id matches sent id.
|
|
* If so, decode the results.
|
|
*/
|
|
xdrmem_create (xdrs, inbuf, (u_int) inlen, XDR_DECODE);
|
|
if (xdr_replymsg (xdrs, &msg))
|
|
{
|
|
if ((msg.rm_xid == xid) &&
|
|
(msg.rm_reply.rp_stat == MSG_ACCEPTED) &&
|
|
(msg.acpted_rply.ar_stat == SUCCESS))
|
|
{
|
|
raddr.sin_port = htons ((u_short) port);
|
|
done = (*eachresult) (resultsp, &raddr);
|
|
}
|
|
/* otherwise, we just ignore the errors ... */
|
|
}
|
|
else
|
|
{
|
|
#ifdef notdef
|
|
/* some kind of deserialization problem ... */
|
|
if (msg.rm_xid == xid)
|
|
fprintf (stderr, "Broadcast deserialization problem");
|
|
/* otherwise, just random garbage */
|
|
#endif
|
|
}
|
|
xdrs->x_op = XDR_FREE;
|
|
msg.acpted_rply.ar_results.proc = (xdrproc_t)xdr_void;
|
|
(void) xdr_replymsg (xdrs, &msg);
|
|
(void) (*xresults) (xdrs, resultsp);
|
|
xdr_destroy (xdrs);
|
|
if (done)
|
|
{
|
|
stat = RPC_SUCCESS;
|
|
goto done_broad;
|
|
}
|
|
else
|
|
{
|
|
goto recv_again;
|
|
}
|
|
}
|
|
done_broad:
|
|
(void) close (sock);
|
|
AUTH_DESTROY (unix_auth);
|
|
return stat;
|
|
}
|