summaryrefslogtreecommitdiff
path: root/sunrpc/pmap_rmt.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1997-03-27 01:59:53 +0000
committerUlrich Drepper <drepper@redhat.com>1997-03-27 01:59:53 +0000
commite7fd8a39abd3a9c9d2139e686b17efb5dc3bf444 (patch)
tree637853189c42709eb7fa91817173d6097765888a /sunrpc/pmap_rmt.c
parent34b402e5a967b97fc73cc45fbef61bbeb8526f3d (diff)
1997-03-27 02:28 Ulrich Drepper <drepper@cygnus.com> * gmon/gmon.c (monstartup): Mark all messages. (write_call_graph): Rewrite to use larger I/O vector for writev call to reduce syscall overhead. (write_bb_counts): Simplify writev handling. * inet/rexec.c: Make string parameters `const'. * resolv/netdb.h: Add prototypes for rcmd, rexec, ruserok, and rresvport. * math/Makefile: Don't define CFLAGS-* macros to prevent inlining in libm-test. * math/libm-test.c (this_does_nothing): Remove functions. It's notuseful on any platform but ix86. (inverse_func_pair_test): Don't use this_does_nothing. Use memory reference. (identities1_test): Likewise. (identities2_test): Likewise. (identities3_test): Likewise. (basic_test): Likewise. Patch by Andreas Schwab. (BUILD_COMPLEX): New macro. Create complex number from real and imaginary parts. This works around bugs/inefficiencies in current gcc. (cexp_test): Use BUILD_COMPLEX. Add more tests. * nss/nsswitch.c: Fix typo. * posix/glob.h: Add declaration for glob_pattern_p. * posix/glob.c: Rename glob_pattern_p to __glob_pattern_p and make glob_pattern_p a weak alias. This function is used in other packages (e.g. bash). * signal/Makefile (routines): Add sigisempty, sigandset, and sigorset. * signal/signal.h: Add prototypes for sigisempty, sigandset, and sigorset. * signal/sigisempty.c: New file. * signal/sigandset.c: New file. * signal/sigorset.c: New file. * sysdeps/generic/sigset.h: Define __sigisemptyset, __sigandset, and __sigorset. * sysdeps/unix/sysv/linux/sigset.h: Likewise. * stdlib/strtod.c: Handle `n-char-sequence' in NaN parsing. It determines the bits in the mantissa part of the NaN. * stdlib/strtof.c: Define SET_MANTISSA for float type. * wcsmbs/wcstof.c: Define SET_MANTISSA for float type. * stdlib/strtold.c: Define SET_MANTISSA for long double type. * wcsmbs/wcstold.c: Define SET_MANTISSA for long double type. * sysdeps/libm-ieee754/s_cexp.c: Use explicit assignment to complex number components. Some more corrects for special cases. * sysdeps/libm-ieee754/s_cexpf.c: Likewise. * sysdeps/libm-ieee754/s_cexpl.c: Likewise. * sysdeps/sparc/elf/start.S: Remove as per request of Miguel de Icaza. * sysdeps/unix/sysv/linux/netinet/icmp.h: Remove since we have ip_icmp.h. Reported by HJ Lu. 1997-03-25 03:50 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/m68k/Makefile (CFLAGS-rtld.c): Add -Wno-unused. * sysdeps/m68k/dl-machine.h (elf_machine_rela): Rewritten as for i386. (elf_machine_lookup_noexec_p, elf_machine_lookup_noplt_p, ELF_MACHINE_RELOC_NOPLT): Define. 1997-03-25 03:48 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * grp/grp.h: Include <stddef.h> only once. 1997-03-25 09:38 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/unix/sysv/linux/termbits.h (OXTABS): Don't define. * sysdeps/unix/sysv/linux/alpha/termbits.h (OXTABS): Likewise. * termios/sys/ttydefaults.h (TTYDEF_OFLAG): Use either OXTABS or TAB3, if one of them is defined. 1997-03-26 04:53 Ulrich Drepper <drepper@cygnus.com> * posix/glob.c (next_brace_sub): Decrement depth counter when '}' is found. Patch by Dennis Henriksen <opus@flamingo.osrl.dk>. 1997-03-25 16:25 Thorsten Kukuk <kukuk@vt.uni-paderborn.de> * sunrpc/Makefile: Comment gccwarn out. * sunrpc/auth_none.c: Fix prototypes and parameters for compiling with enabled warnings. * sunrpc/auth_unix.c: Likewise. * sunrpc/authuxprot.c: Likewise. * sunrpc/bindrsvprt.c: Likewise. * sunrpc/clnt_gen.c: Likewise. * sunrpc/clnt_perr.c: Likewise. * sunrpc/clnt_raw.c: Likewise. * sunrpc/clnt_simp.c: Likewise. * sunrpc/clnt_tcp.c: Likewise. * sunrpc/clnt_udp.c: Likewise. * sunrpc/get_myaddr.c: Likewise. * sunrpc/getrpcport.c: Likewise. * sunrpc/pm_getmaps.c: Likewise. * sunrpc/pm_getport.c: Likewise. * sunrpc/pmap_clnt.c: Likewise. * sunrpc/pmap_prot.c: Likewise. * sunrpc/pmap_prot2.c: Likewise. * sunrpc/pmap_rmt.c: Likewise. * sunrpc/rpc/auth.h: Likewise. * sunrpc/rpc/clnt.h: Likewise. * sunrpc/rpc/pmap_clnt.h: Likewise. * sunrpc/rpc/svc.h: Likewise. * sunrpc/rpc/svc_auth.h: Likewise. * sunrpc/rpc/types.h: Likewise. * sunrpc/rpc/xdr.h: Likewise. * sunrpc/rpc_clntout.c: Likewise. * sunrpc/rpc_cmsg.c: Likewise. * sunrpc/rpc_dtable.c: Likewise. * sunrpc/rpc_prot.c: Likewise. * sunrpc/svc.c: Likewise. * sunrpc/svc_auth.c: Likewise. * sunrpc/svc_authux.c: Likewise. * sunrpc/svc_raw.c: Likewise. * sunrpc/svc_run.c: Likewise. * sunrpc/svc_simple.c: Likewise. * sunrpc/svc_tcp.c: Likewise. * sunrpc/svc_udp.c: Likewise. * sunrpc/xdr.c: Likewise. * sunrpc/xdr_array.c: Likewise. * sunrpc/xdr_mem.c: Likewise. * sunrpc/xdr_rec.c: Likewise. * sunrpc/xdr_ref.c: Likewise. * sunrpc/xdr_stdio.c: Likewise. 1997-03-25 13:39 Ulrich Drepper <drepper@cygnus.com> * math/libm-test.c (log2_test): Compile this function and call it. (exp2_test): Likewise, but check whether function really exists before testing. * math/Makefile (libm-calls): Add s_log2 and s_exp2. 1997-03-25 04:50 Ulrich Drepper <drepper@cygnus.com> Implement exp2 function. * sysdeps/libm-i387/s_exp2.S: New file. * sysdeps/libm-i387/s_exp2f.S: New file. * sysdeps/libm-i387/s_exp2l.S: New file. Implement log2 function. * sysdeps/libm-i387/s_log2.S: New file. * sysdeps/libm-i387/s_log2f.S: New file. * sysdeps/libm-i387/s_log2l.S: New file. * sysdeps/libm-ieee754/s_log2.c: New file. * sysdeps/libm-ieee754/s_log2f.c: New file. * sysdeps/stub/s_log2.c: New file. Stub version.
Diffstat (limited to 'sunrpc/pmap_rmt.c')
-rw-r--r--sunrpc/pmap_rmt.c568
1 files changed, 297 insertions, 271 deletions
diff --git a/sunrpc/pmap_rmt.c b/sunrpc/pmap_rmt.c
index 8907929973..c3667d4738 100644
--- a/sunrpc/pmap_rmt.c
+++ b/sunrpc/pmap_rmt.c
@@ -39,6 +39,8 @@ static char sccsid[] = "@(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro";
* 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>
@@ -53,11 +55,7 @@ static char sccsid[] = "@(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro";
#include <arpa/inet.h>
#define MAX_BROADCAST_SIZE 1400
-#ifndef errno
-extern int errno;
-#endif
-static struct timeval timeout = { 3, 0 };
-
+static struct timeval timeout = {3, 0};
/*
* pmapper remote-call-service interface.
@@ -65,42 +63,46 @@ static struct timeval timeout = { 3, 0 };
* 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;
+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;
- register CLIENT *client;
- struct rmtcallargs a;
- struct rmtcallres r;
- enum clnt_stat stat;
+ 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, xdr_rmtcall_args, &a,
- xdr_rmtcallres, &r, tout);
- CLNT_DESTROY(client);
- } else {
- stat = RPC_FAILED;
- }
- /* (void)close(socket); CLNT_DESTROY already closed it */
- addr->sin_port = 0;
- return (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;
}
@@ -109,30 +111,31 @@ pmap_rmtcall(addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, port_pt
* written for XDR_ENCODE direction only
*/
bool_t
-xdr_rmtcall_args(xdrs, cap)
- register XDR *xdrs;
- register struct rmtcallargs *cap;
+xdr_rmtcall_args (xdrs, cap)
+ XDR *xdrs;
+ struct rmtcallargs *cap;
{
- u_int lenposition, argposition, position;
+ 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);
+ 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;
}
/*
@@ -140,19 +143,20 @@ xdr_rmtcall_args(xdrs, cap)
* written for XDR_DECODE direction only
*/
bool_t
-xdr_rmtcallres(xdrs, crp)
- register XDR *xdrs;
- register struct rmtcallres *crp;
+xdr_rmtcallres (xdrs, crp)
+ XDR *xdrs;
+ struct rmtcallres *crp;
{
- caddr_t port_ptr;
+ caddr_t port_ptr;
- port_ptr = (caddr_t)crp->port_ptr;
- if (xdr_reference(xdrs, &port_ptr, sizeof (u_long),
- 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);
+ 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;
}
@@ -163,231 +167,253 @@ xdr_rmtcallres(xdrs, crp)
*/
static int
-getbroadcastnets(addrs, sock, buf)
- struct in_addr *addrs;
- int sock; /* any valid socket will do */
- char *buf; /* why allocate more when we can use existing... */
+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;
+ 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;
- }
+ 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);
+ addrs[i++] = inet_makeaddr (inet_netof
+ (sin->sin_addr.s_addr), INADDR_ANY);
#endif
- }
}
- return (i);
+ }
+ 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 */
+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;
- register XDR *xdrs = &xdr_stream;
- int outlen, inlen, fromlen, nets;
- register int sock;
- int on = 1;
+ 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;
+ fd_set mask;
+ fd_set readfds;
#else
- int readfds;
- register int mask;
+ int readfds;
+ int mask;
#endif /* def FD_SETSIZE */
- register int i;
- bool_t done = FALSE;
- register 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];
+ 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;
- }
+ /*
+ * 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;
- }
+ 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);
+ FD_ZERO (&mask);
+ FD_SET (sock, &mask);
#else
- mask = (1 << sock);
+ 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;
+ 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;
+ }
}
- 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 = xdr_rmtcallres;
- readfds = mask;
- t1 = t;
- switch (select(_rpc_dtablesize(), &readfds, (int *)NULL,
- (int *)NULL, &t1)) {
+ 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 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;
+ 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 (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 {
+ } /* 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 (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 */
+ /* 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 = 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;
- }
}
+ 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);
+ (void) close (sock);
+ AUTH_DESTROY (unix_auth);
+ return stat;
}