* ensure memory is released if operations fail (in authunix_create(),
xdr_callmsg(), xprt_register(), svc_tcp(), svc_udp(), etc) * don't attempt to close a socket filedescriptor if it's -1 (some from freebsd, some i found) * make the initial xid a little more random (from freebsd) * fix some spelos and tyops in comments (some from freebsd) * use warn() instead of warnx() for many errors; the user probably wants to know what the error code was. * knf & whitespace nitpicks
This commit is contained in:
parent
7ef318056c
commit
6c13a3b826
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: auth_none.c,v 1.10 1998/07/26 11:39:26 mycroft Exp $ */
|
||||
/* $NetBSD: auth_none.c,v 1.11 1999/01/20 11:37:34 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
@ -35,7 +35,7 @@
|
||||
static char *sccsid = "@(#)auth_none.c 1.19 87/08/11 Copyr 1984 Sun Micro";
|
||||
static char *sccsid = "@(#)auth_none.c 2.1 88/07/29 4.0 RPCSRC";
|
||||
#else
|
||||
__RCSID("$NetBSD: auth_none.c,v 1.10 1998/07/26 11:39:26 mycroft Exp $");
|
||||
__RCSID("$NetBSD: auth_none.c,v 1.11 1999/01/20 11:37:34 lukem Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -102,8 +102,8 @@ authnone_create()
|
||||
ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth;
|
||||
ap->no_client.ah_ops = &ops;
|
||||
xdrs = &xdr_stream;
|
||||
xdrmem_create(xdrs, ap->marshalled_client, (u_int)MAX_MARSHEL_SIZE,
|
||||
XDR_ENCODE);
|
||||
xdrmem_create(xdrs, ap->marshalled_client,
|
||||
(u_int)MAX_MARSHEL_SIZE, XDR_ENCODE);
|
||||
(void)xdr_opaque_auth(xdrs, &ap->no_client.ah_cred);
|
||||
(void)xdr_opaque_auth(xdrs, &ap->no_client.ah_verf);
|
||||
ap->mcnt = XDR_GETPOS(xdrs);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: auth_unix.c,v 1.13 1998/11/15 17:24:07 christos Exp $ */
|
||||
/* $NetBSD: auth_unix.c,v 1.14 1999/01/20 11:37:34 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
@ -35,7 +35,7 @@
|
||||
static char *sccsid = "@(#)auth_unix.c 1.19 87/08/11 Copyr 1984 Sun Micro";
|
||||
static char *sccsid = "@(#)auth_unix.c 2.2 88/08/01 4.0 RPCSRC";
|
||||
#else
|
||||
__RCSID("$NetBSD: auth_unix.c,v 1.13 1998/11/15 17:24:07 christos Exp $");
|
||||
__RCSID("$NetBSD: auth_unix.c,v 1.14 1999/01/20 11:37:34 lukem Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -125,24 +125,26 @@ authunix_create(machname, uid, gid, len, aup_gids)
|
||||
/*
|
||||
* Allocate and set up auth handle
|
||||
*/
|
||||
au = NULL;
|
||||
auth = (AUTH *)mem_alloc(sizeof(*auth));
|
||||
#ifndef KERNEL
|
||||
if (auth == NULL) {
|
||||
warnx("authunix_create: out of memory");
|
||||
return (NULL);
|
||||
goto cleanup_authunix_create;
|
||||
}
|
||||
#endif
|
||||
au = (struct audata *)mem_alloc(sizeof(*au));
|
||||
#ifndef KERNEL
|
||||
if (au == NULL) {
|
||||
warnx("authunix_create: out of memory");
|
||||
return (NULL);
|
||||
goto cleanup_authunix_create;
|
||||
}
|
||||
#endif
|
||||
auth->ah_ops = &auth_unix_ops;
|
||||
auth->ah_private = au;
|
||||
auth->ah_verf = au->au_shcred = _null_auth;
|
||||
au->au_shfaults = 0;
|
||||
au->au_origcred.oa_base = NULL;
|
||||
|
||||
/*
|
||||
* fill in param struct from the given params
|
||||
@ -168,7 +170,7 @@ authunix_create(machname, uid, gid, len, aup_gids)
|
||||
#else
|
||||
if ((au->au_origcred.oa_base = mem_alloc((u_int) len)) == NULL) {
|
||||
warnx("authunix_create: out of memory");
|
||||
return (NULL);
|
||||
goto cleanup_authunix_create;
|
||||
}
|
||||
#endif
|
||||
memmove(au->au_origcred.oa_base, mymem, (size_t)len);
|
||||
@ -179,6 +181,17 @@ authunix_create(machname, uid, gid, len, aup_gids)
|
||||
auth->ah_cred = au->au_origcred;
|
||||
marshal_new_auth(auth);
|
||||
return (auth);
|
||||
#ifndef KERNEL
|
||||
cleanup_authunix_create:
|
||||
if (auth)
|
||||
mem_free(auth, sizeof(*auth));
|
||||
if (au) {
|
||||
if (au->au_origcred.oa_base)
|
||||
mem_free(au->au_origcred.oa_base, (u_int)len);
|
||||
mem_free(au, sizeof(*au));
|
||||
}
|
||||
return (NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@ -238,7 +251,8 @@ authunix_validate(auth, verf)
|
||||
|
||||
if (verf->oa_flavor == AUTH_SHORT) {
|
||||
au = AUTH_PRIVATE(auth);
|
||||
xdrmem_create(&xdrs, verf->oa_base, verf->oa_length, XDR_DECODE);
|
||||
xdrmem_create(&xdrs, verf->oa_base, verf->oa_length,
|
||||
XDR_DECODE);
|
||||
|
||||
if (au->au_shcred.oa_base != NULL) {
|
||||
mem_free(au->au_shcred.oa_base,
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: authunix_prot.c,v 1.7 1998/02/13 05:52:14 lukem Exp $ */
|
||||
/* $NetBSD: authunix_prot.c,v 1.8 1999/01/20 11:37:34 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
@ -35,7 +35,7 @@
|
||||
static char *sccsid = "@(#)authunix_prot.c 1.15 87/08/11 Copyr 1984 Sun Micro";
|
||||
static char *sccsid = "@(#)authunix_prot.c 2.1 88/07/29 4.0 RPCSRC";
|
||||
#else
|
||||
__RCSID("$NetBSD: authunix_prot.c,v 1.7 1998/02/13 05:52:14 lukem Exp $");
|
||||
__RCSID("$NetBSD: authunix_prot.c,v 1.8 1999/01/20 11:37:34 lukem Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -76,4 +76,3 @@ xdr_authunix_parms(xdrs, p)
|
||||
}
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: bindresvport.c,v 1.13 1998/11/15 17:32:41 christos Exp $ */
|
||||
/* $NetBSD: bindresvport.c,v 1.14 1999/01/20 11:37:35 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
@ -35,7 +35,7 @@
|
||||
static char *sccsid = "@(#)bindresvport.c 1.8 88/02/08 SMI";
|
||||
static char *sccsid = "@(#)bindresvport.c 2.2 88/07/29 4.0 RPCSRC";
|
||||
#else
|
||||
__RCSID("$NetBSD: bindresvport.c,v 1.13 1998/11/15 17:32:41 christos Exp $");
|
||||
__RCSID("$NetBSD: bindresvport.c,v 1.14 1999/01/20 11:37:35 lukem Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -107,8 +107,8 @@ bindresvport(sd, sin)
|
||||
}
|
||||
|
||||
if (sin != &myaddr) { /* What did the kernel assign? */
|
||||
if (getsockname(sd, (struct sockaddr *)(void *)sin, &sinlen)
|
||||
< 0)
|
||||
if (getsockname(sd, (struct sockaddr *)(void *)sin,
|
||||
&sinlen) < 0)
|
||||
errno = saved_errno;
|
||||
return (res);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: clnt_perror.c,v 1.15 1998/11/15 17:32:42 christos Exp $ */
|
||||
/* $NetBSD: clnt_perror.c,v 1.16 1999/01/20 11:37:35 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
@ -35,7 +35,7 @@
|
||||
static char *sccsid = "@(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro";
|
||||
static char *sccsid = "@(#)clnt_perror.c 2.1 88/07/29 4.0 RPCSRC";
|
||||
#else
|
||||
__RCSID("$NetBSD: clnt_perror.c,v 1.15 1998/11/15 17:32:42 christos Exp $");
|
||||
__RCSID("$NetBSD: clnt_perror.c,v 1.16 1999/01/20 11:37:35 lukem Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -75,9 +75,9 @@ static char *
|
||||
_buf()
|
||||
{
|
||||
|
||||
if (buf == 0)
|
||||
buf = (char *)malloc(256);
|
||||
buflen = 256;
|
||||
if (buf == 0)
|
||||
buf = (char *)malloc(buflen);
|
||||
return (buf);
|
||||
}
|
||||
|
||||
@ -126,15 +126,13 @@ clnt_sperror(rpch, s)
|
||||
|
||||
case RPC_CANTSEND:
|
||||
case RPC_CANTRECV:
|
||||
i = snprintf(str, len, "; errno = %s",
|
||||
strerror(e.re_errno));
|
||||
i = snprintf(str, len, "; errno = %s", strerror(e.re_errno));
|
||||
str += i;
|
||||
len -= i;
|
||||
break;
|
||||
|
||||
case RPC_VERSMISMATCH:
|
||||
i = snprintf(str, len,
|
||||
"; low version = %u, high version = %u",
|
||||
i = snprintf(str, len, "; low version = %u, high version = %u",
|
||||
e.re_vers.low, e.re_vers.high);
|
||||
str += i;
|
||||
len -= i;
|
||||
@ -157,16 +155,14 @@ clnt_sperror(rpch, s)
|
||||
break;
|
||||
|
||||
case RPC_PROGVERSMISMATCH:
|
||||
i = snprintf(str, len,
|
||||
"; low version = %u, high version = %u",
|
||||
i = snprintf(str, len, "; low version = %u, high version = %u",
|
||||
e.re_vers.low, e.re_vers.high);
|
||||
str += i;
|
||||
len -= i;
|
||||
break;
|
||||
|
||||
default: /* unknown */
|
||||
i = snprintf(str, len,
|
||||
"; s1 = %u, s2 = %u",
|
||||
i = snprintf(str, len, "; s1 = %u, s2 = %u",
|
||||
e.re_lb.s1, e.re_lb.s2);
|
||||
str += i;
|
||||
len -= i;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: clnt_raw.c,v 1.13 1998/11/15 17:27:35 christos Exp $ */
|
||||
/* $NetBSD: clnt_raw.c,v 1.14 1999/01/20 11:37:35 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
@ -35,7 +35,7 @@
|
||||
static char *sccsid = "@(#)clnt_raw.c 1.22 87/08/11 Copyr 1984 Sun Micro";
|
||||
static char *sccsid = "@(#)clnt_raw.c 2.2 88/08/01 4.0 RPCSRC";
|
||||
#else
|
||||
__RCSID("$NetBSD: clnt_raw.c,v 1.13 1998/11/15 17:27:35 christos Exp $");
|
||||
__RCSID("$NetBSD: clnt_raw.c,v 1.14 1999/01/20 11:37:35 lukem Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -254,8 +254,7 @@ clntraw_freeres(cl, xdr_res, res_ptr)
|
||||
XDR *xdrs = &clp->xdr_stream;
|
||||
bool_t rval;
|
||||
|
||||
if (clp == 0)
|
||||
{
|
||||
if (clp == 0) {
|
||||
rval = (bool_t) RPC_FAILED;
|
||||
return (rval);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: clnt_simple.c,v 1.14 1998/11/15 17:25:39 christos Exp $ */
|
||||
/* $NetBSD: clnt_simple.c,v 1.15 1999/01/20 11:37:35 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
@ -35,7 +35,7 @@
|
||||
static char *sccsid = "@(#)clnt_simple.c 1.35 87/08/11 Copyr 1984 Sun Micro";
|
||||
static char *sccsid = "@(#)clnt_simple.c 2.2 88/08/01 4.0 RPCSRC";
|
||||
#else
|
||||
__RCSID("$NetBSD: clnt_simple.c,v 1.14 1998/11/15 17:25:39 christos Exp $");
|
||||
__RCSID("$NetBSD: clnt_simple.c,v 1.15 1999/01/20 11:37:35 lukem Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -94,12 +94,13 @@ callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out)
|
||||
crp->oldhost[0] = 0;
|
||||
crp->socket = RPC_ANYSOCK;
|
||||
}
|
||||
if (crp->valid && crp->oldprognum == prognum && crp->oldversnum == versnum
|
||||
&& strcmp(crp->oldhost, host) == 0) {
|
||||
if (crp->valid && crp->oldprognum == prognum
|
||||
&& crp->oldversnum == versnum && strcmp(crp->oldhost, host) == 0) {
|
||||
/* reuse old client */
|
||||
} else {
|
||||
crp->valid = 0;
|
||||
(void)close(crp->socket);
|
||||
if (crp->socket != -1)
|
||||
(void)close(crp->socket);
|
||||
crp->socket = RPC_ANYSOCK;
|
||||
if (crp->client) {
|
||||
clnt_destroy(crp->client);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: clnt_tcp.c,v 1.15 1998/11/15 17:29:17 christos Exp $ */
|
||||
/* $NetBSD: clnt_tcp.c,v 1.16 1999/01/20 11:37:36 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
@ -35,7 +35,7 @@
|
||||
static char *sccsid = "@(#)clnt_tcp.c 1.37 87/10/05 Copyr 1984 Sun Micro";
|
||||
static char *sccsid = "@(#)clnt_tcp.c 2.2 88/08/01 4.0 RPCSRC";
|
||||
#else
|
||||
__RCSID("$NetBSD: clnt_tcp.c,v 1.15 1998/11/15 17:29:17 christos Exp $");
|
||||
__RCSID("$NetBSD: clnt_tcp.c,v 1.16 1999/01/20 11:37:36 lukem Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -127,8 +127,8 @@ struct ct_data {
|
||||
* consulted for the right port number.
|
||||
* NB: *sockp is copied into a private area.
|
||||
* NB: It is the clients responsibility to close *sockp.
|
||||
* NB: The rpch->cl_auth is set null authentication. Caller may wish to set this
|
||||
* something more useful.
|
||||
* NB: The rpch->cl_auth is set null authentication. Caller may wish to set
|
||||
* this something more useful.
|
||||
*/
|
||||
CLIENT *
|
||||
clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
|
||||
@ -143,6 +143,10 @@ clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
|
||||
struct ct_data *ct = NULL;
|
||||
struct timeval now;
|
||||
struct rpc_msg call_msg;
|
||||
static u_int32_t disrupt;
|
||||
|
||||
if (disrupt == 0)
|
||||
disrupt = (u_int32_t)(long)raddr;
|
||||
|
||||
h = (CLIENT *)mem_alloc(sizeof(*h));
|
||||
if (h == NULL) {
|
||||
@ -164,7 +168,8 @@ clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
|
||||
*/
|
||||
if (raddr->sin_port == 0) {
|
||||
u_short port;
|
||||
if ((port = pmap_getport(raddr, prog, vers, IPPROTO_TCP)) == 0) {
|
||||
if ((port = pmap_getport(raddr, prog, vers, IPPROTO_TCP))
|
||||
== 0) {
|
||||
mem_free(ct, sizeof(struct ct_data));
|
||||
mem_free(h, sizeof(CLIENT));
|
||||
return ((CLIENT *)NULL);
|
||||
@ -183,7 +188,8 @@ clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
|
||||
sizeof(*raddr)) < 0)) {
|
||||
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
|
||||
rpc_createerr.cf_error.re_errno = errno;
|
||||
(void)close(*sockp);
|
||||
if (*sockp != -1)
|
||||
(void)close(*sockp);
|
||||
goto fooy;
|
||||
}
|
||||
ct->ct_closeit = TRUE;
|
||||
@ -203,14 +209,15 @@ clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
|
||||
* Initialize call message
|
||||
*/
|
||||
(void)gettimeofday(&now, (struct timezone *)0);
|
||||
call_msg.rm_xid = (u_int32_t)(getpid() ^ now.tv_sec ^ now.tv_usec);
|
||||
call_msg.rm_xid =
|
||||
(u_int32_t)((++disrupt) ^ getpid() ^ now.tv_sec ^ now.tv_usec);
|
||||
call_msg.rm_direction = CALL;
|
||||
call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
|
||||
call_msg.rm_call.cb_prog = (u_int32_t)prog;
|
||||
call_msg.rm_call.cb_vers = (u_int32_t)vers;
|
||||
|
||||
/*
|
||||
* pre-serialize the staic part of the call msg and stash it away
|
||||
* pre-serialize the static part of the call msg and stash it away
|
||||
*/
|
||||
xdrmem_create(&(ct->ct_xdrs), ct->ct_u.ct_mcallc, MCALL_MSG_SIZE,
|
||||
XDR_ENCODE);
|
||||
@ -240,7 +247,8 @@ fooy:
|
||||
*/
|
||||
if (ct)
|
||||
mem_free(ct, sizeof(struct ct_data));
|
||||
mem_free(h, sizeof(CLIENT));
|
||||
if (h)
|
||||
mem_free(h, sizeof(CLIENT));
|
||||
return ((CLIENT *)NULL);
|
||||
}
|
||||
|
||||
@ -320,7 +328,8 @@ call_again:
|
||||
*/
|
||||
_seterr_reply(&reply_msg, &(ct->ct_error));
|
||||
if (ct->ct_error.re_status == RPC_SUCCESS) {
|
||||
if (! AUTH_VALIDATE(h->cl_auth, &reply_msg.acpted_rply.ar_verf)) {
|
||||
if (! AUTH_VALIDATE(h->cl_auth,
|
||||
&reply_msg.acpted_rply.ar_verf)) {
|
||||
ct->ct_error.re_status = RPC_AUTHERROR;
|
||||
ct->ct_error.re_why = AUTH_INVALIDRESP;
|
||||
} else if (! (*xdr_results)(xdrs, results_ptr)) {
|
||||
@ -330,7 +339,8 @@ call_again:
|
||||
/* free verifier ... */
|
||||
if (reply_msg.acpted_rply.ar_verf.oa_base != NULL) {
|
||||
xdrs->x_op = XDR_FREE;
|
||||
(void)xdr_opaque_auth(xdrs, &(reply_msg.acpted_rply.ar_verf));
|
||||
(void)xdr_opaque_auth(xdrs,
|
||||
&(reply_msg.acpted_rply.ar_verf));
|
||||
}
|
||||
} /* end successful completion */
|
||||
else {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: clnt_udp.c,v 1.15 1998/11/15 17:30:40 christos Exp $ */
|
||||
/* $NetBSD: clnt_udp.c,v 1.16 1999/01/20 11:37:36 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
@ -35,7 +35,7 @@
|
||||
static char *sccsid = "@(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro";
|
||||
static char *sccsid = "@(#)clnt_udp.c 2.2 88/08/01 4.0 RPCSRC";
|
||||
#else
|
||||
__RCSID("$NetBSD: clnt_udp.c,v 1.15 1998/11/15 17:30:40 christos Exp $");
|
||||
__RCSID("$NetBSD: clnt_udp.c,v 1.16 1999/01/20 11:37:36 lukem Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -137,6 +137,10 @@ clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)
|
||||
struct cu_data *cu = NULL;
|
||||
struct timeval now;
|
||||
struct rpc_msg call_msg;
|
||||
static u_int32_t disrupt;
|
||||
|
||||
if (disrupt == 0)
|
||||
disrupt = (u_int32_t)(long)raddr;
|
||||
|
||||
cl = (CLIENT *)mem_alloc(sizeof(CLIENT));
|
||||
if (cl == NULL) {
|
||||
@ -175,7 +179,8 @@ clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)
|
||||
cu->cu_total.tv_usec = -1;
|
||||
cu->cu_sendsz = sendsz;
|
||||
cu->cu_recvsz = recvsz;
|
||||
call_msg.rm_xid = (u_int32_t)(getpid() ^ now.tv_sec ^ now.tv_usec);
|
||||
call_msg.rm_xid =
|
||||
(u_int32_t)((++disrupt) ^ getpid() ^ now.tv_sec ^ now.tv_usec);
|
||||
call_msg.rm_direction = CALL;
|
||||
call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
|
||||
call_msg.rm_call.cb_prog = (u_int32_t)program;
|
||||
@ -195,7 +200,7 @@ clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)
|
||||
rpc_createerr.cf_error.re_errno = errno;
|
||||
goto fooy;
|
||||
}
|
||||
/* attempt to bind to prov port */
|
||||
/* attempt to bind to priv port */
|
||||
(void)bindresvport(*sockp, (struct sockaddr_in *)0);
|
||||
/* the sockets rpc controls are non-blocking */
|
||||
(void)ioctl(*sockp, FIONBIO, (char *)(void *)&dontblock);
|
||||
@ -339,7 +344,8 @@ send_again:
|
||||
if (inlen < sizeof(u_int32_t))
|
||||
continue;
|
||||
/* see if reply transaction id matches sent id */
|
||||
if (*((u_int32_t *)(cu->cu_inbuf)) != *((u_int32_t *)(cu->cu_outbuf)))
|
||||
if (*((u_int32_t *)(cu->cu_inbuf)) !=
|
||||
*((u_int32_t *)(cu->cu_outbuf)))
|
||||
continue;
|
||||
/* we now assume we have the proper reply */
|
||||
break;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pmap_clnt.c,v 1.9 1998/07/26 13:16:59 mycroft Exp $ */
|
||||
/* $NetBSD: pmap_clnt.c,v 1.10 1999/01/20 11:37:37 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
@ -35,7 +35,7 @@
|
||||
static char *sccsid = "@(#)pmap_clnt.c 1.37 87/08/11 Copyr 1984 Sun Micro";
|
||||
static char *sccsid = "@(#)pmap_clnt.c 2.2 88/08/01 4.0 RPCSRC";
|
||||
#else
|
||||
__RCSID("$NetBSD: pmap_clnt.c,v 1.9 1998/07/26 13:16:59 mycroft Exp $");
|
||||
__RCSID("$NetBSD: pmap_clnt.c,v 1.10 1999/01/20 11:37:37 lukem Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -92,10 +92,13 @@ pmap_set(program, version, protocol, port)
|
||||
if (CLNT_CALL(client, PMAPPROC_SET, xdr_pmap, &parms, xdr_bool, &rslt,
|
||||
tottimeout) != RPC_SUCCESS) {
|
||||
clnt_perror(client, "Cannot register service");
|
||||
if (socket != -1)
|
||||
(void)close(socket);
|
||||
return (FALSE);
|
||||
}
|
||||
CLNT_DESTROY(client);
|
||||
(void)close(socket);
|
||||
if (socket != -1)
|
||||
(void)close(socket);
|
||||
return (rslt);
|
||||
}
|
||||
|
||||
@ -126,6 +129,7 @@ pmap_unset(program, version)
|
||||
CLNT_CALL(client, PMAPPROC_UNSET, xdr_pmap, &parms, xdr_bool, &rslt,
|
||||
tottimeout);
|
||||
CLNT_DESTROY(client);
|
||||
(void)close(socket);
|
||||
if (socket != -1)
|
||||
(void)close(socket);
|
||||
return (rslt);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pmap_getmaps.c,v 1.9 1998/11/15 17:32:42 christos Exp $ */
|
||||
/* $NetBSD: pmap_getmaps.c,v 1.10 1999/01/20 11:37:37 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
@ -35,7 +35,7 @@
|
||||
static char *sccsid = "@(#)pmap_getmaps.c 1.10 87/08/11 Copyr 1984 Sun Micro";
|
||||
static char *sccsid = "@(#)pmap_getmaps.c 2.2 88/08/01 4.0 RPCSRC";
|
||||
#else
|
||||
__RCSID("$NetBSD: pmap_getmaps.c,v 1.9 1998/11/15 17:32:42 christos Exp $");
|
||||
__RCSID("$NetBSD: pmap_getmaps.c,v 1.10 1999/01/20 11:37:37 lukem Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -90,13 +90,14 @@ pmap_getmaps(address)
|
||||
client = clnttcp_create(address, PMAPPROG,
|
||||
PMAPVERS, &sock, 50, 500);
|
||||
if (client != (CLIENT *)NULL) {
|
||||
if (CLNT_CALL(client, PMAPPROC_DUMP, xdr_void, NULL, xdr_pmaplist,
|
||||
&head, minutetimeout) != RPC_SUCCESS) {
|
||||
if (CLNT_CALL(client, PMAPPROC_DUMP, xdr_void, NULL,
|
||||
xdr_pmaplist, &head, minutetimeout) != RPC_SUCCESS) {
|
||||
clnt_perror(client, "pmap_getmaps rpc problem");
|
||||
}
|
||||
CLNT_DESTROY(client);
|
||||
}
|
||||
(void)close(sock);
|
||||
if (sock != -1)
|
||||
(void)close(sock);
|
||||
address->sin_port = 0;
|
||||
return (head);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pmap_getport.c,v 1.9 1998/11/15 17:32:42 christos Exp $ */
|
||||
/* $NetBSD: pmap_getport.c,v 1.10 1999/01/20 11:37:37 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
@ -35,7 +35,7 @@
|
||||
static char *sccsid = "@(#)pmap_getport.c 1.9 87/08/11 Copyr 1984 Sun Micro";
|
||||
static char *sccsid = "@(#)pmap_getport.c 2.2 88/08/01 4.0 RPCSRC";
|
||||
#else
|
||||
__RCSID("$NetBSD: pmap_getport.c,v 1.9 1998/11/15 17:32:42 christos Exp $");
|
||||
__RCSID("$NetBSD: pmap_getport.c,v 1.10 1999/01/20 11:37:37 lukem Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -100,7 +100,8 @@ pmap_getport(address, program, version, protocol)
|
||||
}
|
||||
CLNT_DESTROY(client);
|
||||
}
|
||||
(void)close(sock);
|
||||
if (sock != -1)
|
||||
(void)close(sock);
|
||||
address->sin_port = 0;
|
||||
return (port);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pmap_rmt.c,v 1.17 1998/11/15 17:32:43 christos Exp $ */
|
||||
/* $NetBSD: pmap_rmt.c,v 1.18 1999/01/20 11:37:37 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
@ -35,7 +35,7 @@
|
||||
static char *sccsid = "@(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro";
|
||||
static char *sccsid = "@(#)pmap_rmt.c 2.2 88/08/01 4.0 RPCSRC";
|
||||
#else
|
||||
__RCSID("$NetBSD: pmap_rmt.c,v 1.17 1998/11/15 17:32:43 christos Exp $");
|
||||
__RCSID("$NetBSD: pmap_rmt.c,v 1.18 1999/01/20 11:37:37 lukem Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -90,7 +90,8 @@ static const struct timeval timeout = { 3, 0 };
|
||||
* 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)
|
||||
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;
|
||||
@ -121,7 +122,8 @@ pmap_rmtcall(addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, port_pt
|
||||
} else {
|
||||
stat = RPC_FAILED;
|
||||
}
|
||||
(void)close(sock);
|
||||
if (sock != -1)
|
||||
(void)close(sock);
|
||||
addr->sin_port = 0;
|
||||
return (stat);
|
||||
}
|
||||
@ -200,7 +202,7 @@ getbroadcastnets(addrs, sock, buf)
|
||||
ifc.ifc_len = UDPMSGSIZE;
|
||||
ifc.ifc_buf = buf;
|
||||
if (ioctl(sock, SIOCGIFCONF, &ifc) < 0) {
|
||||
warnx("getbroadcastnets: ioctl (get interface configuration)");
|
||||
warn("getbroadcastnets: ioctl (get interface configuration)");
|
||||
return (0);
|
||||
}
|
||||
#define max(a, b) (a > b ? a : b)
|
||||
@ -213,7 +215,7 @@ getbroadcastnets(addrs, sock, buf)
|
||||
continue;
|
||||
ifreq = *ifr;
|
||||
if (ioctl(sock, SIOCGIFFLAGS, &ifreq) < 0) {
|
||||
warnx("getbroadcastnets: ioctl (get interface flags)");
|
||||
warn("getbroadcastnets: ioctl (get interface flags)");
|
||||
continue;
|
||||
}
|
||||
if ((ifreq.ifr_flags & IFF_BROADCAST) &&
|
||||
@ -277,13 +279,13 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
|
||||
* preserialize the arguments into a send buffer.
|
||||
*/
|
||||
if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
|
||||
warnx("Cannot create socket for broadcast rpc");
|
||||
warn("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) {
|
||||
warnx("Cannot set socket option SO_BROADCAST");
|
||||
warn("Cannot set socket option SO_BROADCAST");
|
||||
stat = RPC_CANTSEND;
|
||||
goto done_broad;
|
||||
}
|
||||
@ -331,7 +333,7 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
|
||||
if (sendto(sock, outbuf, outlen, 0,
|
||||
(struct sockaddr *)(void *)&baddr,
|
||||
sizeof (struct sockaddr)) != outlen) {
|
||||
warnx("Cannot send broadcast packet");
|
||||
warn("Cannot send broadcast packet");
|
||||
stat = RPC_CANTSEND;
|
||||
goto done_broad;
|
||||
}
|
||||
@ -354,7 +356,7 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
|
||||
case -1: /* some kind of error */
|
||||
if (errno == EINTR)
|
||||
goto recv_again;
|
||||
warnx("Broadcast poll problem");
|
||||
warn("Broadcast poll problem");
|
||||
stat = RPC_CANTRECV;
|
||||
goto done_broad;
|
||||
|
||||
@ -366,7 +368,7 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
|
||||
if (inlen < 0) {
|
||||
if (errno == EINTR)
|
||||
goto try_again;
|
||||
warnx("Cannot receive reply to broadcast");
|
||||
warn("Cannot receive reply to broadcast");
|
||||
stat = RPC_CANTRECV;
|
||||
goto done_broad;
|
||||
}
|
||||
@ -389,7 +391,8 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
|
||||
#ifdef notdef
|
||||
/* some kind of deserialization problem ... */
|
||||
if (msg.rm_xid == xid)
|
||||
fprintf(stderr, "Broadcast deserialization problem");
|
||||
fprintf(stderr,
|
||||
"Broadcast deserialization problem");
|
||||
/* otherwise, just random garbage */
|
||||
#endif
|
||||
}
|
||||
@ -407,7 +410,8 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
|
||||
}
|
||||
stat = RPC_TIMEDOUT;
|
||||
done_broad:
|
||||
(void)close(sock);
|
||||
if (sock != -1)
|
||||
(void)close(sock);
|
||||
AUTH_DESTROY(unix_auth);
|
||||
return (stat);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: rpc_callmsg.c,v 1.11 1998/11/15 17:32:43 christos Exp $ */
|
||||
/* $NetBSD: rpc_callmsg.c,v 1.12 1999/01/20 11:37:38 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
@ -35,7 +35,7 @@
|
||||
static char *sccsid = "@(#)rpc_callmsg.c 1.4 87/08/11 Copyr 1984 Sun Micro";
|
||||
static char *sccsid = "@(#)rpc_callmsg.c 2.1 88/07/29 4.0 RPCSRC";
|
||||
#else
|
||||
__RCSID("$NetBSD: rpc_callmsg.c,v 1.11 1998/11/15 17:32:43 christos Exp $");
|
||||
__RCSID("$NetBSD: rpc_callmsg.c,v 1.12 1999/01/20 11:37:38 lukem Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -141,7 +141,9 @@ xdr_callmsg(xdrs, cmsg)
|
||||
}
|
||||
if (oa->oa_base == NULL) {
|
||||
oa->oa_base = (caddr_t)
|
||||
mem_alloc(oa->oa_length);
|
||||
mem_alloc(oa->oa_length);
|
||||
if (oa->oa_base == NULL)
|
||||
return (FALSE);
|
||||
}
|
||||
buf = XDR_INLINE(xdrs, RNDUP(oa->oa_length));
|
||||
if (buf == NULL) {
|
||||
@ -175,7 +177,9 @@ xdr_callmsg(xdrs, cmsg)
|
||||
}
|
||||
if (oa->oa_base == NULL) {
|
||||
oa->oa_base = (caddr_t)
|
||||
mem_alloc(oa->oa_length);
|
||||
mem_alloc(oa->oa_length);
|
||||
if (oa->oa_base == NULL)
|
||||
return (FALSE);
|
||||
}
|
||||
buf = XDR_INLINE(xdrs, RNDUP(oa->oa_length));
|
||||
if (buf == NULL) {
|
||||
@ -205,7 +209,6 @@ xdr_callmsg(xdrs, cmsg)
|
||||
xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_vers)) &&
|
||||
xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_proc)) &&
|
||||
xdr_opaque_auth(xdrs, &(cmsg->rm_call.cb_cred)) )
|
||||
return (xdr_opaque_auth(xdrs, &(cmsg->rm_call.cb_verf)));
|
||||
return (xdr_opaque_auth(xdrs, &(cmsg->rm_call.cb_verf)));
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: rpc_prot.c,v 1.10 1998/11/15 17:32:43 christos Exp $ */
|
||||
/* $NetBSD: rpc_prot.c,v 1.11 1999/01/20 11:37:38 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
@ -35,7 +35,7 @@
|
||||
static char *sccsid = "@(#)rpc_prot.c 1.36 87/08/11 Copyr 1984 Sun Micro";
|
||||
static char *sccsid = "@(#)rpc_prot.c 2.3 88/08/07 4.0 RPCSRC";
|
||||
#else
|
||||
__RCSID("$NetBSD: rpc_prot.c,v 1.10 1998/11/15 17:32:43 christos Exp $");
|
||||
__RCSID("$NetBSD: rpc_prot.c,v 1.11 1999/01/20 11:37:38 lukem Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -205,7 +205,7 @@ xdr_callhdr(xdrs, cmsg)
|
||||
xdr_enum(xdrs, (enum_t *)&(cmsg->rm_direction)) &&
|
||||
xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_rpcvers)) &&
|
||||
xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_prog)) )
|
||||
return (xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_vers)));
|
||||
return (xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_vers)));
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
@ -288,7 +288,7 @@ _seterr_reply(msg, error)
|
||||
if (msg->acpted_rply.ar_stat == SUCCESS) {
|
||||
error->re_status = RPC_SUCCESS;
|
||||
return;
|
||||
};
|
||||
}
|
||||
accepted(msg->acpted_rply.ar_stat, error);
|
||||
break;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: svc.c,v 1.15 1998/11/15 17:32:45 christos Exp $ */
|
||||
/* $NetBSD: svc.c,v 1.16 1999/01/20 11:37:38 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
@ -35,7 +35,7 @@
|
||||
static char *sccsid = "@(#)svc.c 1.44 88/02/08 Copyr 1984 Sun Micro";
|
||||
static char *sccsid = "@(#)svc.c 2.4 88/08/11 4.0 RPCSRC";
|
||||
#else
|
||||
__RCSID("$NetBSD: svc.c,v 1.15 1998/11/15 17:32:45 christos Exp $");
|
||||
__RCSID("$NetBSD: svc.c,v 1.16 1999/01/20 11:37:38 lukem Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -112,6 +112,8 @@ xprt_register(xprt)
|
||||
if (xports == NULL) {
|
||||
xports = (SVCXPRT **)
|
||||
mem_alloc(FD_SETSIZE * sizeof(SVCXPRT *));
|
||||
if (xports == NULL)
|
||||
return;
|
||||
memset(xports, '\0', FD_SETSIZE * sizeof(SVCXPRT *));
|
||||
}
|
||||
if (sock < FD_SETSIZE) {
|
||||
@ -443,10 +445,12 @@ svc_getreqset(readfds)
|
||||
prog_found = FALSE;
|
||||
low_vers = (u_long) -1L;
|
||||
high_vers = (u_long) 0L;
|
||||
for (s = svc_head; s != NULL_SVC; s = s->sc_next) {
|
||||
for (s = svc_head; s != NULL_SVC;
|
||||
s = s->sc_next) {
|
||||
if (s->sc_prog == r.rq_prog) {
|
||||
if (s->sc_vers == r.rq_vers) {
|
||||
(*s->sc_dispatch)(&r, xprt);
|
||||
(*s->sc_dispatch)(&r,
|
||||
xprt);
|
||||
goto call_done;
|
||||
} /* found correct version */
|
||||
prog_found = TRUE;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: svc_run.c,v 1.12 1998/02/13 05:52:36 lukem Exp $ */
|
||||
/* $NetBSD: svc_run.c,v 1.13 1999/01/20 11:37:39 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
@ -35,7 +35,7 @@
|
||||
static char *sccsid = "@(#)svc_run.c 1.1 87/10/13 Copyr 1984 Sun Micro";
|
||||
static char *sccsid = "@(#)svc_run.c 2.1 88/07/29 4.0 RPCSRC";
|
||||
#else
|
||||
__RCSID("$NetBSD: svc_run.c,v 1.12 1998/02/13 05:52:36 lukem Exp $");
|
||||
__RCSID("$NetBSD: svc_run.c,v 1.13 1999/01/20 11:37:39 lukem Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -69,7 +69,7 @@ svc_run()
|
||||
if (errno == EINTR) {
|
||||
continue;
|
||||
}
|
||||
warnx("svc_run: - select failed");
|
||||
warn("svc_run: - select failed");
|
||||
return;
|
||||
case 0:
|
||||
continue;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: svc_simple.c,v 1.12 1998/11/15 17:32:46 christos Exp $ */
|
||||
/* $NetBSD: svc_simple.c,v 1.13 1999/01/20 11:37:39 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
@ -35,7 +35,7 @@
|
||||
static char *sccsid = "@(#)svc_simple.c 1.18 87/08/11 Copyr 1984 Sun Micro";
|
||||
static char *sccsid = "@(#)svc_simple.c 2.2 88/08/01 4.0 RPCSRC";
|
||||
#else
|
||||
__RCSID("$NetBSD: svc_simple.c,v 1.12 1998/11/15 17:32:46 christos Exp $");
|
||||
__RCSID("$NetBSD: svc_simple.c,v 1.13 1999/01/20 11:37:39 lukem Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -160,4 +160,3 @@ universal(rqstp, transp)
|
||||
}
|
||||
errx(1, "never registered prog %d", prog);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: svc_tcp.c,v 1.20 1999/01/20 08:40:13 lukem Exp $ */
|
||||
/* $NetBSD: svc_tcp.c,v 1.21 1999/01/20 11:37:39 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
@ -35,7 +35,7 @@
|
||||
static char *sccsid = "@(#)svc_tcp.c 1.21 87/08/11 Copyr 1984 Sun Micro";
|
||||
static char *sccsid = "@(#)svc_tcp.c 2.2 88/08/01 4.0 RPCSRC";
|
||||
#else
|
||||
__RCSID("$NetBSD: svc_tcp.c,v 1.20 1999/01/20 08:40:13 lukem Exp $");
|
||||
__RCSID("$NetBSD: svc_tcp.c,v 1.21 1999/01/20 11:37:39 lukem Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -146,13 +146,13 @@ svctcp_create(sock, sendsize, recvsize)
|
||||
{
|
||||
bool_t madesock = FALSE;
|
||||
SVCXPRT *xprt;
|
||||
struct tcp_rendezvous *r;
|
||||
struct tcp_rendezvous *r = NULL;
|
||||
struct sockaddr_in addr;
|
||||
int len = sizeof(struct sockaddr_in);
|
||||
|
||||
if (sock == RPC_ANYSOCK) {
|
||||
if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
|
||||
warn("svctcp_create - udp socket creation problem");
|
||||
warn("svctcp_create - socket creation problem");
|
||||
goto cleanup_svctcp_create;
|
||||
}
|
||||
madesock = TRUE;
|
||||
@ -195,6 +195,8 @@ svctcp_create(sock, sendsize, recvsize)
|
||||
cleanup_svctcp_create:
|
||||
if (madesock)
|
||||
(void)close(sock);
|
||||
if (r != NULL)
|
||||
mem_free(r, sizeof(*r));
|
||||
return ((SVCXPRT *)NULL);
|
||||
}
|
||||
|
||||
@ -410,7 +412,8 @@ svctcp_getargs(xprt, xdr_args, args_ptr)
|
||||
caddr_t args_ptr;
|
||||
{
|
||||
|
||||
return ((*xdr_args)(&(((struct tcp_conn *)(xprt->xp_p1))->xdrs), args_ptr));
|
||||
return ((*xdr_args)(&(((struct tcp_conn *)(xprt->xp_p1))->xdrs),
|
||||
args_ptr));
|
||||
}
|
||||
|
||||
static bool_t
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: svc_udp.c,v 1.15 1998/11/15 17:32:46 christos Exp $ */
|
||||
/* $NetBSD: svc_udp.c,v 1.16 1999/01/20 11:37:40 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
@ -35,7 +35,7 @@
|
||||
static char *sccsid = "@(#)svc_udp.c 1.24 87/08/11 Copyr 1984 Sun Micro";
|
||||
static char *sccsid = "@(#)svc_udp.c 2.2 88/07/29 4.0 RPCSRC";
|
||||
#else
|
||||
__RCSID("$NetBSD: svc_udp.c,v 1.15 1998/11/15 17:32:46 christos Exp $");
|
||||
__RCSID("$NetBSD: svc_udp.c,v 1.16 1999/01/20 11:37:40 lukem Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -119,15 +119,15 @@ svcudp_bufcreate(sock, sendsz, recvsz)
|
||||
u_int sendsz, recvsz;
|
||||
{
|
||||
bool_t madesock = FALSE;
|
||||
SVCXPRT *xprt;
|
||||
struct svcudp_data *su;
|
||||
SVCXPRT *xprt = NULL;
|
||||
struct svcudp_data *su = NULL;
|
||||
struct sockaddr_in addr;
|
||||
int len = sizeof(struct sockaddr_in);
|
||||
|
||||
if (sock == RPC_ANYSOCK) {
|
||||
if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
|
||||
warnx("svcudp_create: socket creation problem");
|
||||
return ((SVCXPRT *)NULL);
|
||||
warn("svcudp_create: socket creation problem");
|
||||
goto cleanup_svcudp_bufcreate;
|
||||
}
|
||||
madesock = TRUE;
|
||||
}
|
||||
@ -139,25 +139,23 @@ svcudp_bufcreate(sock, sendsz, recvsz)
|
||||
(void)bind(sock, (struct sockaddr *)(void *)&addr, len);
|
||||
}
|
||||
if (getsockname(sock, (struct sockaddr *)(void *)&addr, &len) != 0) {
|
||||
warnx("svcudp_create - cannot getsockname");
|
||||
if (madesock)
|
||||
(void)close(sock);
|
||||
return ((SVCXPRT *)NULL);
|
||||
warn("svcudp_create - cannot getsockname");
|
||||
goto cleanup_svcudp_bufcreate;
|
||||
}
|
||||
xprt = (SVCXPRT *)mem_alloc(sizeof(SVCXPRT));
|
||||
if (xprt == NULL) {
|
||||
warnx("svcudp_create: out of memory");
|
||||
return (NULL);
|
||||
goto cleanup_svcudp_bufcreate;
|
||||
}
|
||||
su = (struct svcudp_data *)mem_alloc(sizeof(*su));
|
||||
if (su == NULL) {
|
||||
warnx("svcudp_create: out of memory");
|
||||
return (NULL);
|
||||
goto cleanup_svcudp_bufcreate;
|
||||
}
|
||||
su->su_iosz = ((MAX(sendsz, recvsz) + 3) / 4) * 4;
|
||||
if ((rpc_buffer(xprt) = mem_alloc(su->su_iosz)) == NULL) {
|
||||
warnx("svcudp_create: out of memory");
|
||||
return (NULL);
|
||||
goto cleanup_svcudp_bufcreate;
|
||||
}
|
||||
xdrmem_create(
|
||||
&(su->su_xdrs), rpc_buffer(xprt), su->su_iosz, XDR_DECODE);
|
||||
@ -169,6 +167,14 @@ svcudp_bufcreate(sock, sendsz, recvsz)
|
||||
xprt->xp_sock = sock;
|
||||
xprt_register(xprt);
|
||||
return (xprt);
|
||||
cleanup_svcudp_bufcreate:
|
||||
if (madesock)
|
||||
(void)close(sock);
|
||||
if (su)
|
||||
mem_free(su, sizeof(*su));
|
||||
if (xprt)
|
||||
mem_free(xprt, sizeof(SVCXPRT));
|
||||
return ((SVCXPRT *)NULL);
|
||||
}
|
||||
|
||||
SVCXPRT *
|
||||
@ -353,7 +359,8 @@ struct udp_cache {
|
||||
* the hashing function
|
||||
*/
|
||||
#define CACHE_LOC(transp, xid) \
|
||||
(xid % (u_int32_t)(SPARSENESS*((struct udp_cache *) su_data(transp)->su_cache)->uc_size))
|
||||
(xid % (u_int32_t)(SPARSENESS*((struct udp_cache *)\
|
||||
su_data(transp)->su_cache)->uc_size))
|
||||
|
||||
|
||||
/*
|
||||
@ -436,7 +443,8 @@ cache_set(xprt, replylen)
|
||||
}
|
||||
newbuf = mem_alloc(su->su_iosz);
|
||||
if (newbuf == NULL) {
|
||||
CACHE_PERROR("cache_set: could not allocate new rpc_buffer");
|
||||
CACHE_PERROR(
|
||||
"cache_set: could not allocate new rpc_buffer");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -447,7 +455,8 @@ cache_set(xprt, replylen)
|
||||
victim->cache_replylen = replylen;
|
||||
victim->cache_reply = rpc_buffer(xprt);
|
||||
rpc_buffer(xprt) = newbuf;
|
||||
xdrmem_create(&(su->su_xdrs), rpc_buffer(xprt), su->su_iosz, XDR_ENCODE);
|
||||
xdrmem_create(&(su->su_xdrs), rpc_buffer(xprt), su->su_iosz,
|
||||
XDR_ENCODE);
|
||||
victim->cache_xid = su->su_xid;
|
||||
victim->cache_proc = uc->uc_proc;
|
||||
victim->cache_vers = uc->uc_vers;
|
||||
@ -476,7 +485,7 @@ cache_get(xprt, msg, replyp, replylenp)
|
||||
struct svcudp_data *su = su_data(xprt);
|
||||
struct udp_cache *uc = (struct udp_cache *) su->su_cache;
|
||||
|
||||
# define EQADDR(a1, a2) (memcmp(&a1, &a2, sizeof(a1)) == 0)
|
||||
#define EQADDR(a1, a2) (memcmp(&a1, &a2, sizeof(a1)) == 0)
|
||||
|
||||
loc = (u_int)CACHE_LOC(xprt, su->su_xid);
|
||||
for (ent = uc->uc_entries[loc]; ent != NULL; ent = ent->cache_next) {
|
||||
@ -500,4 +509,3 @@ cache_get(xprt, msg, replyp, replylenp)
|
||||
uc->uc_addr = xprt->xp_raddr;
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: xdr_array.c,v 1.10 1998/02/13 05:52:41 lukem Exp $ */
|
||||
/* $NetBSD: xdr_array.c,v 1.11 1999/01/20 11:37:40 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
@ -35,7 +35,7 @@
|
||||
static char *sccsid = "@(#)xdr_array.c 1.10 87/08/11 Copyr 1984 Sun Micro";
|
||||
static char *sccsid = "@(#)xdr_array.c 2.1 88/07/29 4.0 RPCSRC";
|
||||
#else
|
||||
__RCSID("$NetBSD: xdr_array.c,v 1.10 1998/02/13 05:52:41 lukem Exp $");
|
||||
__RCSID("$NetBSD: xdr_array.c,v 1.11 1999/01/20 11:37:40 lukem Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -167,4 +167,3 @@ xdr_vector(xdrs, basep, nelem, elemsize, xdr_elem)
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user