X-Git-Url: https://git.saurik.com/apple/libinfo.git/blobdiff_plain/c29f2fccbf0d388644e29ea3e98c38a343688bd2..f64cfb2378dc3a60cd30c50180a366ec54b98781:/rpc.subproj/pmap_rmt.c diff --git a/rpc.subproj/pmap_rmt.c b/rpc.subproj/pmap_rmt.c index a91b2a2..a35084f 100644 --- a/rpc.subproj/pmap_rmt.c +++ b/rpc.subproj/pmap_rmt.c @@ -79,8 +79,6 @@ static char *rcsid = "$Id: pmap_rmt.c,v 1.6 2004/12/19 22:45:44 zarzycki Exp $"; #include #define MAX_BROADCAST_SIZE 1400 -#include "pmap_wakeup.h" - static struct timeval timeout = { 3, 0 }; @@ -93,12 +91,21 @@ static struct timeval timeout = { 3, 0 }; */ enum clnt_stat pmap_rmtcall(addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, port_ptr) +#ifdef __LP64__ + struct sockaddr_in *addr; + uint32_t prog, vers, proc; + xdrproc_t xdrargs, xdrres; + caddr_t argsp, resp; + struct timeval tout; + uint32_t *port_ptr; +#else struct sockaddr_in *addr; u_long prog, vers, proc; xdrproc_t xdrargs, xdrres; caddr_t argsp, resp; struct timeval tout; u_long *port_ptr; +#endif { int socket = -1; register CLIENT *client; @@ -106,8 +113,6 @@ pmap_rmtcall(addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, port_pt struct rmtcallres r; enum clnt_stat stat; - pmap_wakeup(); - addr->sin_port = htons(PMAPPORT); client = clntudp_create(addr, PMAPPROG, PMAPVERS, timeout, &socket); if (client != (CLIENT *)NULL) { @@ -119,8 +124,7 @@ pmap_rmtcall(addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, port_pt 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); + stat = CLNT_CALL(client, PMAPPROC_CALLIT, (xdrproc_t)xdr_rmtcall_args, &a, (xdrproc_t)xdr_rmtcallres, &r, tout); CLNT_DESTROY(client); } else { stat = RPC_FAILED; @@ -149,10 +153,14 @@ xdr_rmtcall_args(xdrs, cap) if (! xdr_u_long(xdrs, &(cap->arglen))) return (FALSE); argposition = XDR_GETPOS(xdrs); - if (! (*(cap->xdr_args))(xdrs, cap->args_ptr)) + if (! (*(cap->xdr_args))(xdrs, cap->args_ptr, 0)) return (FALSE); position = XDR_GETPOS(xdrs); +#ifdef __LP64__ + cap->arglen = (uint32_t)position - (uint32_t)argposition; +#else cap->arglen = (u_long)position - (u_long)argposition; +#endif XDR_SETPOS(xdrs, lenposition); if (! xdr_u_long(xdrs, &(cap->arglen))) return (FALSE); @@ -174,11 +182,17 @@ xdr_rmtcallres(xdrs, crp) 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)); +#ifdef __LP64__ + if (xdr_reference(xdrs, &port_ptr, sizeof (uint32_t), (xdrproc_t)xdr_u_long) && xdr_u_long(xdrs, &crp->resultslen)) { + crp->port_ptr = (unsigned int *)port_ptr; + return ((*(crp->xdr_results))(xdrs, crp->results_ptr, 0)); } +#else + if (xdr_reference(xdrs, &port_ptr, sizeof (u_long), (xdrproc_t)xdr_u_long) && xdr_u_long(xdrs, &crp->resultslen)) { + crp->port_ptr = (unsigned long *)port_ptr; + return ((*(crp->xdr_results))(xdrs, crp->results_ptr, 0)); + } +#endif return (FALSE); } @@ -245,6 +259,16 @@ typedef bool_t (*resultproc_t)(); enum clnt_stat clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult) +#ifdef __LP64__ + uint32_t prog; /* program number */ + uint32_t vers; /* version number */ + uint32_t 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 */ +#else u_long prog; /* program number */ u_long vers; /* version number */ u_long proc; /* procedure number */ @@ -253,20 +277,26 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult) xdrproc_t xresults; /* xdr routine for results */ caddr_t resultsp; /* pointer to results */ resultproc_t eachresult; /* call with each result obtained */ +#endif { enum clnt_stat stat; AUTH *unix_auth = authunix_create_default(); XDR xdr_stream; register XDR *xdrs = &xdr_stream; - int outlen, inlen, fromlen, nets; + int outlen, inlen, nets; + unsigned int fromlen; register int sock; int on = 1; fd_set mask; fd_set readfds; register int i; bool_t done = FALSE; - u_long xid; - u_long port; + uint32_t xid; +#ifdef __LP64__ + unsigned int port; +#else + unsigned long port; +#endif struct in_addr addrs[20]; struct sockaddr_in baddr, raddr; /* broadcast and response addresses */ struct rmtcallargs a; @@ -276,6 +306,8 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult) char outbuf[MAX_BROADCAST_SIZE], inbuf[UDPMSGSIZE]; int rfd; + stat = RPC_SUCCESS; + /* * initialization: create a socket, a broadcast address, and * preserialize the arguments into a send buffer. @@ -355,7 +387,7 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult) 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; + msg.acpted_rply.ar_results.proc = (xdrproc_t)xdr_rmtcallres; readfds = mask; switch (select(sock+1, &readfds, NULL, NULL, &t)) { @@ -373,8 +405,7 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult) } /* end of select results switch */ try_again: fromlen = sizeof(struct sockaddr); - inlen = recvfrom(sock, inbuf, UDPMSGSIZE, 0, - (struct sockaddr *)&raddr, &fromlen); + inlen = recvfrom(sock, inbuf, UDPMSGSIZE, 0, (struct sockaddr *)&raddr, &fromlen); if (inlen < 0) { if (errno == EINTR) goto try_again; @@ -382,8 +413,13 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult) stat = RPC_CANTRECV; goto done_broad; } +#ifdef __LP64__ + if (inlen < sizeof(uint32_t)) + goto recv_again; +#else if (inlen < sizeof(u_long)) goto recv_again; +#endif /* * see if reply transaction id matches sent id. * If so, decode the results. @@ -406,9 +442,9 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult) #endif } xdrs->x_op = XDR_FREE; - msg.acpted_rply.ar_results.proc = xdr_void; + msg.acpted_rply.ar_results.proc = (xdrproc_t)xdr_void; (void)xdr_replymsg(xdrs, &msg); - (void)(*xresults)(xdrs, resultsp); + (void)(*xresults)(xdrs, resultsp, 0); xdr_destroy(xdrs); if (done) { stat = RPC_SUCCESS;