X-Git-Url: https://git.saurik.com/apple/libinfo.git/blobdiff_plain/ccd4a120fd72e1cd2071458320f7a1914ef55421..47da0bbe8e69f4b0a44c878d614a89c2e550a7ca:/rpc.subproj/pmap_clnt.c diff --git a/rpc.subproj/pmap_clnt.c b/rpc.subproj/pmap_clnt.c index afcfb05..5ddfd00 100644 --- a/rpc.subproj/pmap_clnt.c +++ b/rpc.subproj/pmap_clnt.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_clnt.c 1.37 87/08/11 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)pmap_clnt.c 2.2 88/08/01 4.0 RPCSRC";*/ -static char *rcsid = "$Id: pmap_clnt.c,v 1.4 2002/02/19 20:36:23 epeyton Exp $"; +static char *rcsid = "$Id: pmap_clnt.c,v 1.5 2004/12/19 22:45:44 zarzycki Exp $"; #endif /* @@ -75,11 +74,17 @@ static char *rcsid = "$Id: pmap_clnt.c,v 1.4 2002/02/19 20:36:23 epeyton Exp $"; #include #include -static struct timeval timeout = { 5, 0 }; -static struct timeval tottimeout = { 60, 0 }; +#include "pmap_wakeup.h" -void clnt_perror(); +extern CLIENT *clntudp_bufcreate_timeout(struct sockaddr_in *raddr, uint32_t program, uint32_t version, int *sockp, uint32_t sendsz, uint32_t recvsz, struct timeval *timeout, struct timeval *totaltimeout); +static struct timeval set_retry_timeout = { 5, 0 }; +static struct timeval set_total_timeout = { 60, 0 }; + +static struct timeval unset_retry_timeout = { 1, 0 }; +static struct timeval unset_total_timeout = { 5, 0 }; + +void clnt_perror(); /* * Set a mapping between program,version and port. @@ -87,10 +92,17 @@ void clnt_perror(); */ bool_t pmap_set(program, version, protocol, port) +#ifdef __LP64__ + uint32_t program; + uint32_t version; + int32_t protocol; + uint16_t port; +#else u_long program; u_long version; int protocol; u_short port; +#endif { struct sockaddr_in myaddress; int socket = -1; @@ -98,26 +110,24 @@ pmap_set(program, version, protocol, port) struct pmap parms; bool_t rslt; + if (pmap_wakeup() != 0) return FALSE; + memset(&myaddress, 0, sizeof(struct sockaddr_in)); myaddress.sin_family = AF_INET; myaddress.sin_addr.s_addr = htonl(INADDR_LOOPBACK); - client = clntudp_bufcreate(&myaddress, PMAPPROG, PMAPVERS, - timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE); - if (client == (CLIENT *)NULL) - return (FALSE); + client = clntudp_bufcreate_timeout(&myaddress, PMAPPROG, PMAPVERS, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE, &set_retry_timeout, &set_total_timeout); + if (client == NULL) return FALSE; + parms.pm_prog = program; parms.pm_vers = version; parms.pm_prot = protocol; parms.pm_port = port; - if (CLNT_CALL(client, PMAPPROC_SET, xdr_pmap, &parms, xdr_bool, &rslt, - tottimeout) != RPC_SUCCESS) { - clnt_perror(client, "Cannot register service"); - return (FALSE); - } + if (CLNT_CALL(client, PMAPPROC_SET, (xdrproc_t)xdr_pmap, &parms, (xdrproc_t)xdr_bool, &rslt, set_total_timeout) != RPC_SUCCESS) return FALSE; + CLNT_DESTROY(client); - (void)close(socket); - return (rslt); + close(socket); + return rslt; } /* @@ -126,8 +136,13 @@ pmap_set(program, version, protocol, port) */ bool_t pmap_unset(program, version) +#ifdef __LP64__ + uint32_t program; + uint32_t version; +#else u_long program; u_long version; +#endif { struct sockaddr_in myaddress; int socket = -1; @@ -135,20 +150,23 @@ pmap_unset(program, version) struct pmap parms; bool_t rslt; + if (pmap_wakeup() != 0) return FALSE; + memset(&myaddress, 0, sizeof(struct sockaddr_in)); myaddress.sin_family = AF_INET; myaddress.sin_addr.s_addr = htonl(INADDR_LOOPBACK); - client = clntudp_bufcreate(&myaddress, PMAPPROG, PMAPVERS, - timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE); - if (client == (CLIENT *)NULL) - return (FALSE); + client = clntudp_bufcreate_timeout(&myaddress, PMAPPROG, PMAPVERS, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE, &unset_retry_timeout, &unset_total_timeout); + if (client == NULL) return FALSE; + parms.pm_prog = program; parms.pm_vers = version; - parms.pm_port = parms.pm_prot = 0; - CLNT_CALL(client, PMAPPROC_UNSET, xdr_pmap, &parms, xdr_bool, &rslt, - tottimeout); + parms.pm_port = 0; + parms.pm_prot = 0; + + CLNT_CALL(client, PMAPPROC_UNSET, (xdrproc_t)xdr_pmap, &parms, (xdrproc_t)xdr_bool, &rslt, unset_total_timeout); + CLNT_DESTROY(client); - (void)close(socket); - return (rslt); + close(socket); + return rslt; }