1 /* $NetBSD: clnt_vc.c,v 1.4 2000/07/14 08:40:42 fvdl Exp $ */
4 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
5 * unrestricted use provided that this legend is included on all tape
6 * media and as a part of the software program in whole or part. Users
7 * may copy or modify Sun RPC without charge, but are not authorized
8 * to license or distribute it to anyone else except as part of a product or
9 * program developed by the user.
11 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
12 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
13 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
15 * Sun RPC is provided with no support and without any obligation on the
16 * part of Sun Microsystems, Inc. to assist in its use, correction,
17 * modification or enhancement.
19 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
20 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
21 * OR ANY PART THEREOF.
23 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
24 * or profits or other special, indirect and consequential damages, even if
25 * Sun has been advised of the possibility of such damages.
27 * Sun Microsystems, Inc.
29 * Mountain View, California 94043
32 #if defined(LIBC_SCCS) && !defined(lint)
33 static char *sccsid2 = "@(#)clnt_tcp.c 1.37 87/10/05 Copyr 1984 Sun Micro";
34 static char *sccsid = "@(#)clnt_tcp.c 2.2 88/08/01 4.0 RPCSRC";
35 static char sccsid3[] = "@(#)clnt_vc.c 1.19 89/03/16 Copyr 1988 Sun Micro";
37 #include <sys/cdefs.h>
38 __FBSDID("$FreeBSD$");
41 * clnt_tcp.c, Implements a TCP/IP based, client side RPC.
43 * Copyright (C) 1984, Sun Microsystems, Inc.
45 * TCP based RPC supports 'batched calls'.
46 * A sequence of calls may be batched-up in a send buffer. The rpc call
47 * return immediately to the client even though the call was not necessarily
48 * sent. The batching occurs if the results' xdr routine is NULL (0) AND
49 * the rpc timeout value is zero (see clnt.h, rpc).
51 * Clients should NOT casually batch calls that in fact return results; that is,
52 * the server side should be aware that a call is batched and not produce any
53 * return message. Batched calls that produce many result messages can
54 * deadlock (netlock) the client and the server....
56 * Now go hang yourself.
59 #include "namespace.h"
60 #include "reentrant.h"
61 #include <sys/types.h>
63 #include <sys/syslog.h>
64 #include <sys/socket.h>
68 #include <arpa/inet.h>
80 #include <rpc/rpcsec_gss.h>
81 #include "un-namespace.h"
85 #define MCALL_MSG_SIZE 24
89 struct cmsgcred cmcred;
92 static enum clnt_stat clnt_vc_call(CLIENT *, rpcproc_t, xdrproc_t, void *,
93 xdrproc_t, void *, struct timeval);
94 static void clnt_vc_geterr(CLIENT *, struct rpc_err *);
95 static bool_t clnt_vc_freeres(CLIENT *, xdrproc_t, void *);
96 static void clnt_vc_abort(CLIENT *);
97 static bool_t clnt_vc_control(CLIENT *, u_int, void *);
98 static void clnt_vc_destroy(CLIENT *);
99 static struct clnt_ops *clnt_vc_ops(void);
100 static bool_t time_not_ok(struct timeval *);
101 static int read_vc(void *, void *, int);
102 static int write_vc(void *, void *, int);
103 static int __msgwrite(int, void *, size_t);
104 static int __msgread(int, void *, size_t);
107 int ct_fd; /* connection's fd */
108 bool_t ct_closeit; /* close it on destroy */
109 struct timeval ct_wait; /* wait interval in milliseconds */
110 bool_t ct_waitset; /* wait set by clnt_control? */
111 struct netbuf ct_addr; /* remote addr */
112 struct rpc_err ct_error;
114 char ct_mcallc[MCALL_MSG_SIZE]; /* marshalled callmsg */
117 u_int ct_mpos; /* pos after marshal */
118 XDR ct_xdrs; /* XDR stream */
122 * This machinery implements per-fd locks for MT-safety. It is not
123 * sufficient to do per-CLIENT handle locks for MT-safety because a
124 * user may create more than one CLIENT handle with the same fd behind
125 * it. Therfore, we allocate an array of flags (vc_fd_locks), protected
126 * by the clnt_fd_lock mutex, and an array (vc_cv) of condition variables
127 * similarly protected. Vc_fd_lock[fd] == 1 => a call is activte on some
128 * CLIENT handle created for that fd.
129 * The current implementation holds locks across the entire RPC and reply.
130 * Yes, this is silly, and as soon as this code is proven to work, this
131 * should be the first thing fixed. One step at a time.
133 static int *vc_fd_locks;
134 static cond_t *vc_cv;
135 #define release_fd_lock(fd, mask) { \
136 mutex_lock(&clnt_fd_lock); \
137 vc_fd_locks[fd] = 0; \
138 mutex_unlock(&clnt_fd_lock); \
139 thr_sigsetmask(SIG_SETMASK, &(mask), (sigset_t *) NULL); \
140 cond_signal(&vc_cv[fd]); \
143 static const char clnt_vc_errstr[] = "%s : %s";
144 static const char clnt_vc_str[] = "clnt_vc_create";
145 static const char clnt_read_vc_str[] = "read_vc";
146 static const char __no_mem_str[] = "out of memory";
149 * Create a client handle for a connection.
150 * Default options are set, which the user can change using clnt_control()'s.
151 * The rpc/vc package does buffering similar to stdio, so the client
152 * must pick send and receive buffer sizes, 0 => use the default.
153 * NB: fd is copied into a private area.
154 * NB: The rpch->cl_auth is set null authentication. Caller may wish to
155 * set this something more useful.
157 * fd should be an open socket
160 clnt_vc_create(fd, raddr, prog, vers, sendsz, recvsz)
161 int fd; /* open file descriptor */
162 const struct netbuf *raddr; /* servers address */
163 const rpcprog_t prog; /* program number */
164 const rpcvers_t vers; /* version number */
165 u_int sendsz; /* buffer recv size */
166 u_int recvsz; /* buffer send size */
168 CLIENT *cl; /* client handle */
169 struct ct_data *ct = NULL; /* client handle */
171 struct rpc_msg call_msg;
172 static u_int32_t disrupt;
175 struct sockaddr_storage ss;
177 struct __rpc_sockinfo si;
180 disrupt = (u_int32_t)(long)raddr;
182 cl = (CLIENT *)mem_alloc(sizeof (*cl));
183 ct = (struct ct_data *)mem_alloc(sizeof (*ct));
184 if ((cl == (CLIENT *)NULL) || (ct == (struct ct_data *)NULL)) {
185 (void) syslog(LOG_ERR, clnt_vc_errstr,
186 clnt_vc_str, __no_mem_str);
187 rpc_createerr.cf_stat = RPC_SYSTEMERROR;
188 rpc_createerr.cf_error.re_errno = errno;
191 ct->ct_addr.buf = NULL;
192 sigfillset(&newmask);
193 thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
194 mutex_lock(&clnt_fd_lock);
195 if (vc_fd_locks == (int *) NULL) {
196 int cv_allocsz, fd_allocsz;
197 int dtbsize = __rpc_dtbsize();
199 fd_allocsz = dtbsize * sizeof (int);
200 vc_fd_locks = (int *) mem_alloc(fd_allocsz);
201 if (vc_fd_locks == (int *) NULL) {
202 mutex_unlock(&clnt_fd_lock);
203 thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
206 memset(vc_fd_locks, '\0', fd_allocsz);
208 assert(vc_cv == (cond_t *) NULL);
209 cv_allocsz = dtbsize * sizeof (cond_t);
210 vc_cv = (cond_t *) mem_alloc(cv_allocsz);
211 if (vc_cv == (cond_t *) NULL) {
212 mem_free(vc_fd_locks, fd_allocsz);
213 vc_fd_locks = (int *) NULL;
214 mutex_unlock(&clnt_fd_lock);
215 thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
220 for (i = 0; i < dtbsize; i++)
221 cond_init(&vc_cv[i], 0, (void *) 0);
224 assert(vc_cv != (cond_t *) NULL);
227 * XXX - fvdl connecting while holding a mutex?
230 if (_getpeername(fd, (struct sockaddr *)(void *)&ss, &slen) < 0) {
231 if (errno != ENOTCONN) {
232 rpc_createerr.cf_stat = RPC_SYSTEMERROR;
233 rpc_createerr.cf_error.re_errno = errno;
234 mutex_unlock(&clnt_fd_lock);
235 thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
238 if (_connect(fd, (struct sockaddr *)raddr->buf, raddr->len) < 0){
239 rpc_createerr.cf_stat = RPC_SYSTEMERROR;
240 rpc_createerr.cf_error.re_errno = errno;
241 mutex_unlock(&clnt_fd_lock);
242 thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
246 mutex_unlock(&clnt_fd_lock);
247 thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
248 if (!__rpc_fd2sockinfo(fd, &si))
251 ct->ct_closeit = FALSE;
254 * Set up private data struct
257 ct->ct_wait.tv_usec = 0;
258 ct->ct_waitset = FALSE;
259 ct->ct_addr.buf = malloc(raddr->maxlen);
260 if (ct->ct_addr.buf == NULL)
262 memcpy(ct->ct_addr.buf, raddr->buf, raddr->len);
263 ct->ct_addr.len = raddr->maxlen;
264 ct->ct_addr.maxlen = raddr->maxlen;
267 * Initialize call message
269 (void)gettimeofday(&now, NULL);
270 call_msg.rm_xid = ((u_int32_t)++disrupt) ^ __RPC_GETXID(&now);
271 call_msg.rm_direction = CALL;
272 call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
273 call_msg.rm_call.cb_prog = (u_int32_t)prog;
274 call_msg.rm_call.cb_vers = (u_int32_t)vers;
277 * pre-serialize the static part of the call msg and stash it away
279 xdrmem_create(&(ct->ct_xdrs), ct->ct_u.ct_mcallc, MCALL_MSG_SIZE,
281 if (! xdr_callhdr(&(ct->ct_xdrs), &call_msg)) {
282 if (ct->ct_closeit) {
287 ct->ct_mpos = XDR_GETPOS(&(ct->ct_xdrs));
288 XDR_DESTROY(&(ct->ct_xdrs));
289 assert(ct->ct_mpos + sizeof(uint32_t) <= MCALL_MSG_SIZE);
292 * Create a client handle which uses xdrrec for serialization
293 * and authnone for authentication.
295 cl->cl_ops = clnt_vc_ops();
297 cl->cl_auth = authnone_create();
298 sendsz = __rpc_get_t_size(si.si_af, si.si_proto, (int)sendsz);
299 recvsz = __rpc_get_t_size(si.si_af, si.si_proto, (int)recvsz);
300 xdrrec_create(&(ct->ct_xdrs), sendsz, recvsz,
301 cl->cl_private, read_vc, write_vc);
307 mem_free(ct->ct_addr.buf, ct->ct_addr.len);
308 mem_free(ct, sizeof (struct ct_data));
311 mem_free(cl, sizeof (CLIENT));
312 return ((CLIENT *)NULL);
315 static enum clnt_stat
316 clnt_vc_call(cl, proc, xdr_args, args_ptr, xdr_results, results_ptr, timeout)
321 xdrproc_t xdr_results;
323 struct timeval timeout;
325 struct ct_data *ct = (struct ct_data *) cl->cl_private;
326 XDR *xdrs = &(ct->ct_xdrs);
327 struct rpc_msg reply_msg;
329 u_int32_t *msg_x_id = &ct->ct_u.ct_mcalli; /* yuk */
332 sigset_t mask, newmask;
338 sigfillset(&newmask);
339 thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
340 mutex_lock(&clnt_fd_lock);
341 while (vc_fd_locks[ct->ct_fd])
342 cond_wait(&vc_cv[ct->ct_fd], &clnt_fd_lock);
347 vc_fd_locks[ct->ct_fd] = rpc_lock_value;
348 mutex_unlock(&clnt_fd_lock);
349 if (!ct->ct_waitset) {
350 /* If time is not within limits, we ignore it. */
351 if (time_not_ok(&timeout) == FALSE)
352 ct->ct_wait = timeout;
356 (xdr_results == NULL && timeout.tv_sec == 0
357 && timeout.tv_usec == 0) ? FALSE : TRUE;
360 xdrs->x_op = XDR_ENCODE;
361 ct->ct_error.re_status = RPC_SUCCESS;
362 x_id = ntohl(--(*msg_x_id));
364 if (cl->cl_auth->ah_cred.oa_flavor != RPCSEC_GSS) {
365 if ((! XDR_PUTBYTES(xdrs, ct->ct_u.ct_mcallc, ct->ct_mpos)) ||
366 (! XDR_PUTINT32(xdrs, &proc)) ||
367 (! AUTH_MARSHALL(cl->cl_auth, xdrs)) ||
368 (! (*xdr_args)(xdrs, args_ptr))) {
369 if (ct->ct_error.re_status == RPC_SUCCESS)
370 ct->ct_error.re_status = RPC_CANTENCODEARGS;
371 (void)xdrrec_endofrecord(xdrs, TRUE);
372 release_fd_lock(ct->ct_fd, mask);
373 return (ct->ct_error.re_status);
376 *(uint32_t *) &ct->ct_u.ct_mcallc[ct->ct_mpos] = htonl(proc);
377 if (! __rpc_gss_wrap(cl->cl_auth, ct->ct_u.ct_mcallc,
378 ct->ct_mpos + sizeof(uint32_t),
379 xdrs, xdr_args, args_ptr)) {
380 if (ct->ct_error.re_status == RPC_SUCCESS)
381 ct->ct_error.re_status = RPC_CANTENCODEARGS;
382 (void)xdrrec_endofrecord(xdrs, TRUE);
383 release_fd_lock(ct->ct_fd, mask);
384 return (ct->ct_error.re_status);
387 if (! xdrrec_endofrecord(xdrs, shipnow)) {
388 release_fd_lock(ct->ct_fd, mask);
389 return (ct->ct_error.re_status = RPC_CANTSEND);
392 release_fd_lock(ct->ct_fd, mask);
393 return (RPC_SUCCESS);
396 * Hack to provide rpc-based message passing
398 if (timeout.tv_sec == 0 && timeout.tv_usec == 0) {
399 release_fd_lock(ct->ct_fd, mask);
400 return(ct->ct_error.re_status = RPC_TIMEDOUT);
405 * Keep receiving until we get a valid transaction id
407 xdrs->x_op = XDR_DECODE;
409 reply_msg.acpted_rply.ar_verf = _null_auth;
410 reply_msg.acpted_rply.ar_results.where = NULL;
411 reply_msg.acpted_rply.ar_results.proc = (xdrproc_t)xdr_void;
412 if (! xdrrec_skiprecord(xdrs)) {
413 release_fd_lock(ct->ct_fd, mask);
414 return (ct->ct_error.re_status);
416 /* now decode and validate the response header */
417 if (! xdr_replymsg(xdrs, &reply_msg)) {
418 if (ct->ct_error.re_status == RPC_SUCCESS)
420 release_fd_lock(ct->ct_fd, mask);
421 return (ct->ct_error.re_status);
423 if (reply_msg.rm_xid == x_id)
430 _seterr_reply(&reply_msg, &(ct->ct_error));
431 if (ct->ct_error.re_status == RPC_SUCCESS) {
432 if (! AUTH_VALIDATE(cl->cl_auth,
433 &reply_msg.acpted_rply.ar_verf)) {
434 ct->ct_error.re_status = RPC_AUTHERROR;
435 ct->ct_error.re_why = AUTH_INVALIDRESP;
437 if (cl->cl_auth->ah_cred.oa_flavor != RPCSEC_GSS) {
438 reply_stat = (*xdr_results)(xdrs, results_ptr);
440 reply_stat = __rpc_gss_unwrap(cl->cl_auth,
441 xdrs, xdr_results, results_ptr);
444 if (ct->ct_error.re_status == RPC_SUCCESS)
445 ct->ct_error.re_status =
449 /* free verifier ... */
450 if (reply_msg.acpted_rply.ar_verf.oa_base != NULL) {
451 xdrs->x_op = XDR_FREE;
452 (void)xdr_opaque_auth(xdrs,
453 &(reply_msg.acpted_rply.ar_verf));
455 } /* end successful completion */
457 /* maybe our credentials need to be refreshed ... */
458 if (refreshes-- && AUTH_REFRESH(cl->cl_auth, &reply_msg))
460 } /* end of unsuccessful completion */
461 release_fd_lock(ct->ct_fd, mask);
462 return (ct->ct_error.re_status);
466 clnt_vc_geterr(cl, errp)
468 struct rpc_err *errp;
473 assert(errp != NULL);
475 ct = (struct ct_data *) cl->cl_private;
476 *errp = ct->ct_error;
480 clnt_vc_freeres(cl, xdr_res, res_ptr)
493 ct = (struct ct_data *)cl->cl_private;
494 xdrs = &(ct->ct_xdrs);
496 sigfillset(&newmask);
497 thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
498 mutex_lock(&clnt_fd_lock);
499 while (vc_fd_locks[ct->ct_fd])
500 cond_wait(&vc_cv[ct->ct_fd], &clnt_fd_lock);
501 xdrs->x_op = XDR_FREE;
502 dummy = (*xdr_res)(xdrs, res_ptr);
503 mutex_unlock(&clnt_fd_lock);
504 thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
505 cond_signal(&vc_cv[ct->ct_fd]);
518 clnt_vc_control(cl, request, info)
531 ct = (struct ct_data *)cl->cl_private;
533 sigfillset(&newmask);
534 thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
535 mutex_lock(&clnt_fd_lock);
536 while (vc_fd_locks[ct->ct_fd])
537 cond_wait(&vc_cv[ct->ct_fd], &clnt_fd_lock);
542 vc_fd_locks[ct->ct_fd] = rpc_lock_value;
543 mutex_unlock(&clnt_fd_lock);
547 ct->ct_closeit = TRUE;
548 release_fd_lock(ct->ct_fd, mask);
550 case CLSET_FD_NCLOSE:
551 ct->ct_closeit = FALSE;
552 release_fd_lock(ct->ct_fd, mask);
558 /* for other requests which use info */
560 release_fd_lock(ct->ct_fd, mask);
565 if (time_not_ok((struct timeval *)info)) {
566 release_fd_lock(ct->ct_fd, mask);
569 ct->ct_wait = *(struct timeval *)infop;
570 ct->ct_waitset = TRUE;
573 *(struct timeval *)infop = ct->ct_wait;
575 case CLGET_SERVER_ADDR:
576 (void) memcpy(info, ct->ct_addr.buf, (size_t)ct->ct_addr.len);
579 *(int *)info = ct->ct_fd;
582 /* The caller should not free this memory area */
583 *(struct netbuf *)info = ct->ct_addr;
585 case CLSET_SVC_ADDR: /* set to new address */
586 release_fd_lock(ct->ct_fd, mask);
590 * use the knowledge that xid is the
591 * first element in the call structure
592 * This will get the xid of the PREVIOUS call
595 ntohl(*(u_int32_t *)(void *)&ct->ct_u.ct_mcalli);
598 /* This will set the xid of the NEXT call */
599 *(u_int32_t *)(void *)&ct->ct_u.ct_mcalli =
600 htonl(*((u_int32_t *)info) + 1);
601 /* increment by 1 as clnt_vc_call() decrements once */
605 * This RELIES on the information that, in the call body,
606 * the version number field is the fifth field from the
607 * begining of the RPC header. MUST be changed if the
608 * call_struct is changed
611 ntohl(*(u_int32_t *)(void *)(ct->ct_u.ct_mcallc +
612 4 * BYTES_PER_XDR_UNIT));
616 *(u_int32_t *)(void *)(ct->ct_u.ct_mcallc +
617 4 * BYTES_PER_XDR_UNIT) =
618 htonl(*(u_int32_t *)info);
623 * This RELIES on the information that, in the call body,
624 * the program number field is the fourth field from the
625 * begining of the RPC header. MUST be changed if the
626 * call_struct is changed
629 ntohl(*(u_int32_t *)(void *)(ct->ct_u.ct_mcallc +
630 3 * BYTES_PER_XDR_UNIT));
634 *(u_int32_t *)(void *)(ct->ct_u.ct_mcallc +
635 3 * BYTES_PER_XDR_UNIT) =
636 htonl(*(u_int32_t *)info);
640 release_fd_lock(ct->ct_fd, mask);
643 release_fd_lock(ct->ct_fd, mask);
652 struct ct_data *ct = (struct ct_data *) cl->cl_private;
653 int ct_fd = ct->ct_fd;
659 ct = (struct ct_data *) cl->cl_private;
661 sigfillset(&newmask);
662 thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
663 mutex_lock(&clnt_fd_lock);
664 while (vc_fd_locks[ct_fd])
665 cond_wait(&vc_cv[ct_fd], &clnt_fd_lock);
666 if (ct->ct_closeit && ct->ct_fd != -1) {
667 (void)_close(ct->ct_fd);
669 XDR_DESTROY(&(ct->ct_xdrs));
671 free(ct->ct_addr.buf);
672 mem_free(ct, sizeof(struct ct_data));
673 mem_free(cl, sizeof(CLIENT));
674 mutex_unlock(&clnt_fd_lock);
675 thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
676 cond_signal(&vc_cv[ct_fd]);
680 * Interface between xdr serializer and tcp connection.
681 * Behaves like the system calls, read & write, but keeps some error state
682 * around for the rpc level.
685 read_vc(ctp, buf, len)
692 struct ct_data *ct = (struct ct_data *)ctp;
694 int milliseconds = (int)((ct->ct_wait.tv_sec * 1000) +
695 (ct->ct_wait.tv_usec / 1000));
702 switch (_poll(&fd, 1, milliseconds)) {
704 ct->ct_error.re_status = RPC_TIMEDOUT;
710 ct->ct_error.re_status = RPC_CANTRECV;
711 ct->ct_error.re_errno = errno;
718 if ((_getpeername(ct->ct_fd, &sa, &sal) == 0) &&
719 (sa.sa_family == AF_LOCAL)) {
720 len = __msgread(ct->ct_fd, buf, (size_t)len);
722 len = _read(ct->ct_fd, buf, (size_t)len);
728 ct->ct_error.re_errno = ECONNRESET;
729 ct->ct_error.re_status = RPC_CANTRECV;
730 len = -1; /* it's really an error */
734 ct->ct_error.re_errno = errno;
735 ct->ct_error.re_status = RPC_CANTRECV;
742 write_vc(ctp, buf, len)
749 struct ct_data *ct = (struct ct_data *)ctp;
753 if ((_getpeername(ct->ct_fd, &sa, &sal) == 0) &&
754 (sa.sa_family == AF_LOCAL)) {
755 for (cnt = len; cnt > 0; cnt -= i, buf = (char *)buf + i) {
756 if ((i = __msgwrite(ct->ct_fd, buf,
757 (size_t)cnt)) == -1) {
758 ct->ct_error.re_errno = errno;
759 ct->ct_error.re_status = RPC_CANTSEND;
764 for (cnt = len; cnt > 0; cnt -= i, buf = (char *)buf + i) {
765 if ((i = _write(ct->ct_fd, buf, (size_t)cnt)) == -1) {
766 ct->ct_error.re_errno = errno;
767 ct->ct_error.re_status = RPC_CANTSEND;
775 static struct clnt_ops *
778 static struct clnt_ops ops;
779 sigset_t mask, newmask;
781 /* VARIABLES PROTECTED BY ops_lock: ops */
783 sigfillset(&newmask);
784 thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
785 mutex_lock(&ops_lock);
786 if (ops.cl_call == NULL) {
787 ops.cl_call = clnt_vc_call;
788 ops.cl_abort = clnt_vc_abort;
789 ops.cl_geterr = clnt_vc_geterr;
790 ops.cl_freeres = clnt_vc_freeres;
791 ops.cl_destroy = clnt_vc_destroy;
792 ops.cl_control = clnt_vc_control;
794 mutex_unlock(&ops_lock);
795 thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
800 * Make sure that the time is not garbage. -1 value is disallowed.
801 * Note this is different from time_not_ok in clnt_dg.c
807 return (t->tv_sec <= -1 || t->tv_sec > 100000000 ||
808 t->tv_usec <= -1 || t->tv_usec > 1000000);
812 __msgread(sock, buf, cnt)
821 char control[CMSG_SPACE(sizeof(struct cmsgcred))];
824 bzero((char *)&cm, sizeof(cm));
825 iov[0].iov_base = buf;
826 iov[0].iov_len = cnt;
832 msg.msg_control = (caddr_t)&cm;
833 msg.msg_controllen = CMSG_SPACE(sizeof(struct cmsgcred));
836 return(_recvmsg(sock, &msg, 0));
840 __msgwrite(sock, buf, cnt)
849 char control[CMSG_SPACE(sizeof(struct cmsgcred))];
852 bzero((char *)&cm, sizeof(cm));
853 iov[0].iov_base = buf;
854 iov[0].iov_len = cnt;
856 cm.cmsg.cmsg_type = SCM_CREDS;
857 cm.cmsg.cmsg_level = SOL_SOCKET;
858 cm.cmsg.cmsg_len = CMSG_LEN(sizeof(struct cmsgcred));
864 msg.msg_control = (caddr_t)&cm;
865 msg.msg_controllen = CMSG_SPACE(sizeof(struct cmsgcred));
868 return(_sendmsg(sock, &msg, 0));