X-Git-Url: https://git.saurik.com/apple/libinfo.git/blobdiff_plain/ccd4a120fd72e1cd2071458320f7a1914ef55421..f64cfb2378dc3a60cd30c50180a366ec54b98781:/rpc.subproj/pmap_rmt.c diff --git a/rpc.subproj/pmap_rmt.c b/rpc.subproj/pmap_rmt.c index c749cbf..a35084f 100644 --- a/rpc.subproj/pmap_rmt.c +++ b/rpc.subproj/pmap_rmt.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.1 (the "License"). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -54,7 +53,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)pmap_rmt.c 2.2 88/08/01 4.0 RPCSRC";*/ -static char *rcsid = "$Id: pmap_rmt.c,v 1.5 2003/06/05 21:43:28 majka Exp $"; +static char *rcsid = "$Id: pmap_rmt.c,v 1.6 2004/12/19 22:45:44 zarzycki Exp $"; #endif /* @@ -80,7 +79,6 @@ static char *rcsid = "$Id: pmap_rmt.c,v 1.5 2003/06/05 21:43:28 majka Exp $"; #include #define MAX_BROADCAST_SIZE 1400 -extern int errno; 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; @@ -117,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; @@ -147,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); @@ -172,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); } @@ -243,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 */ @@ -251,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; @@ -274,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. @@ -353,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)) { @@ -371,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; @@ -380,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. @@ -404,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;