ReactOS  0.4.13-dev-687-g023794c
clnt_vc.c File Reference
#include <wintirpc.h>
#include <reentrant.h>
#include <sys/types.h>
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <rpc/rpc.h>
#include "rpc_com.h"
Include dependency graph for clnt_vc.c:

Go to the source code of this file.

Classes

struct  cmsgcred
 
struct  cmessage
 
struct  ct_data
 

Macros

#define MCALL_MSG_SIZE   24
 
#define CMGROUP_MAX   16
 
#define SCM_CREDS   0x03 /* process creds (struct cmsgcred) */
 
#define release_fd_lock(fd, mask)
 
#define acquire_fd_lock(fd)
 
#define CALLBACK_TIMEOUT   5000
 
#define RQCRED_SIZE   400 /* this size is excessive */
 

Functions

static enum clnt_stat clnt_vc_call (CLIENT *, rpcproc_t, xdrproc_t, void *, xdrproc_t, void *, struct timeval)
 
static void clnt_vc_geterr (CLIENT *, struct rpc_err *)
 
static bool_t clnt_vc_freeres (CLIENT *, xdrproc_t, void *)
 
static void clnt_vc_abort (CLIENT *)
 
static bool_t clnt_vc_control (CLIENT *, u_int, void *)
 
static void clnt_vc_destroy (CLIENT *)
 
static struct clnt_ops * clnt_vc_ops (void)
 
static bool_t time_not_ok (struct timeval *)
 
static int read_vc (void *, void *, int)
 
static int write_vc (void *, void *, int)
 
static unsigned int WINAPI clnt_cb_thread (void *args)
 
CLIENTclnt_vc_create (int fd, const struct netbuf *raddr, const rpcprog_t prog, const rpcvers_t vers, u_int sendsz, u_int recvsz, int *cb_xdr, int *cb_fn, void *cb_args)
 
static int write_vc (void *ctp, char *buf, int len)
 

Variables

static intvc_fd_locks
 
mutex_t clnt_fd_lock
 
static cond_tvc_cv
 
static const char clnt_vc_errstr [] = "%s : %s"
 
static const char clnt_vc_str [] = "clnt_vc_create"
 
static const char clnt_read_vc_str [] = "read_vc"
 
static const char __no_mem_str [] = "out of memory"
 

Macro Definition Documentation

◆ acquire_fd_lock

#define acquire_fd_lock (   fd)
Value:
{ \
mutex_lock(&clnt_fd_lock); \
mutex_unlock(&clnt_fd_lock); \
}
static cond_t * vc_cv
Definition: clnt_vc.c:163
static int fd
Definition: io.c:51
mutex_t clnt_fd_lock
Definition: mt_misc.c:50
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:420
#define WINSOCK_HANDLE_HASH(x)
Definition: wintirpc.h:70
static int * vc_fd_locks
Definition: clnt_vc.c:161

Definition at line 183 of file clnt_vc.c.

◆ CALLBACK_TIMEOUT

#define CALLBACK_TIMEOUT   5000

Definition at line 198 of file clnt_vc.c.

◆ CMGROUP_MAX

#define CMGROUP_MAX   16

Definition at line 96 of file clnt_vc.c.

◆ MCALL_MSG_SIZE

#define MCALL_MSG_SIZE   24

Definition at line 94 of file clnt_vc.c.

◆ release_fd_lock

#define release_fd_lock (   fd,
  mask 
)
Value:
{ \
mutex_lock(&clnt_fd_lock); \
vc_fd_locks[fd] = 0; \
mutex_unlock(&clnt_fd_lock); \
thr_sigsetmask(SIG_SETMASK, &(mask), (sigset_t *) NULL); \
cond_signal(&vc_cv[fd]); \
}
static cond_t * vc_cv
Definition: clnt_vc.c:163
static int fd
Definition: io.c:51
mutex_t clnt_fd_lock
Definition: mt_misc.c:50
GLenum GLint GLuint mask
Definition: glext.h:6028
smooth NULL
Definition: ftsmooth.c:416

Definition at line 165 of file clnt_vc.c.

◆ RQCRED_SIZE

#define RQCRED_SIZE   400 /* this size is excessive */

Definition at line 199 of file clnt_vc.c.

◆ SCM_CREDS

#define SCM_CREDS   0x03 /* process creds (struct cmsgcred) */

Definition at line 97 of file clnt_vc.c.

Function Documentation

◆ clnt_cb_thread()

static unsigned int WINAPI clnt_cb_thread ( void args)
static

Definition at line 200 of file clnt_vc.c.

201 {
202  int status = NO_ERROR;
203  CLIENT *cl = (CLIENT *)args;
204  struct ct_data *ct = (struct ct_data *) cl->cl_private;
205  XDR *xdrs = &(ct->ct_xdrs);
206  long saved_timeout_sec = ct->ct_wait.tv_sec;
207  long saved_timeout_usec = ct->ct_wait.tv_usec;
208  struct rpc_msg reply_msg;
209  char cred_area[2 * MAX_AUTH_BYTES + RQCRED_SIZE];
210 
211  fprintf(stderr/*stdout*/, "%04x: Creating callback thread\n", GetCurrentThreadId());
212  while(1) {
213  cb_req header;
214  void *res = NULL;
216  while (vc_fd_locks[WINSOCK_HANDLE_HASH(ct->ct_fd)] ||
217  !ct->use_stored_reply_msg ||
218  (ct->use_stored_reply_msg && ct->reply_msg.rm_direction != CALL)) {
219  if (cl->shutdown)
220  break;
224  break;
225  }
228 
229  if (cl->shutdown) {
230  fprintf(stdout, "%04x: callback received shutdown signal\n", GetCurrentThreadId());
231  release_fd_lock(ct->ct_fd, mask);
232  goto out;
233  }
234 
235  saved_timeout_sec = ct->ct_wait.tv_sec;
236  saved_timeout_usec = ct->ct_wait.tv_usec;
237  xdrs->x_op = XDR_DECODE;
238  if (ct->use_stored_reply_msg && ct->reply_msg.rm_direction == CALL) {
239  goto process_rpc_call;
240  } else if (!ct->use_stored_reply_msg) {
241  ct->ct_wait.tv_sec = ct->ct_wait.tv_usec = 0;
242  __xdrrec_setnonblock(xdrs, 0);
243  if (!xdrrec_skiprecord(xdrs))
244  goto skip_process;
245  if (!xdr_getxiddir(xdrs, &ct->reply_msg)) {
246  goto skip_process;
247  }
248  if (ct->reply_msg.rm_direction == CALL) {
249  goto process_rpc_call;
250  } else {
251  if (ct->reply_msg.rm_direction == REPLY)
253  goto skip_setlastfrag;
254  }
255  } else {
256  goto skip_setlastfrag;
257  }
258 process_rpc_call:
259  //call to get call headers
261  ct->reply_msg.rm_call.cb_cred.oa_base = cred_area;
262  ct->reply_msg.rm_call.cb_verf.oa_base = &(cred_area[MAX_AUTH_BYTES]);
263  if (!xdr_getcallbody(xdrs, &ct->reply_msg)) {
264  fprintf(stderr, "%04x: xdr_getcallbody failed\n", GetCurrentThreadId());
265  goto skip_process;
266  } else
267  fprintf(stdout, "%04x: callbody: rpcvers %d cb_prog %d cb_vers %d cb_proc %d\n",
269  ct->reply_msg.rm_call.cb_rpcvers, ct->reply_msg.rm_call.cb_prog,
270  ct->reply_msg.rm_call.cb_vers, ct->reply_msg.rm_call.cb_proc);
271  header.rq_prog = ct->reply_msg.rm_call.cb_prog;
272  header.rq_vers = ct->reply_msg.rm_call.cb_vers;
273  header.rq_proc = ct->reply_msg.rm_call.cb_proc;
274  header.xdr = xdrs;
275  status = (*cl->cb_fn)(cl->cb_args, &header, &res);
276  if (status) {
277  fprintf(stderr, "%04x: callback function failed with %d\n", status);
278  }
279 
280  xdrs->x_op = XDR_ENCODE;
281  __xdrrec_setblock(xdrs);
282  reply_msg.rm_xid = ct->reply_msg.rm_xid;
283  fprintf(stdout, "%04x: cb: replying to xid %d\n", GetCurrentThreadId(),
284  ct->reply_msg.rm_xid);
285  ct->reply_msg.rm_xid = 0;
286  reply_msg.rm_direction = REPLY;
287  reply_msg.rm_reply.rp_stat = MSG_ACCEPTED;
288  reply_msg.acpted_rply.ar_verf = _null_auth;
289  reply_msg.acpted_rply.ar_stat = status;
290  reply_msg.acpted_rply.ar_results.where = NULL;
291  reply_msg.acpted_rply.ar_results.proc = (xdrproc_t)xdr_void;
292  xdr_replymsg(xdrs, &reply_msg);
293  if (!status) {
294  (*cl->cb_xdr)(xdrs, res); /* encode the results */
295  xdrs->x_op = XDR_FREE;
296  (*cl->cb_xdr)(xdrs, res); /* free the results */
297  }
298  if (! xdrrec_endofrecord(xdrs, 1)) {
299  fprintf(stderr, "%04x: failed to send REPLY\n", GetCurrentThreadId());
300  }
301 skip_process:
302  ct->reply_msg.rm_direction = -1;
303  xdrrec_setlastfrag(xdrs);
304 skip_setlastfrag:
305  ct->ct_wait.tv_sec = saved_timeout_sec;
306  ct->ct_wait.tv_usec = saved_timeout_usec;
307  release_fd_lock(ct->ct_fd, mask);
308  }
309 out:
310  return status;
311 }
void * cb_args
Definition: clnt.h:148
#define MAX_AUTH_BYTES
Definition: auth.h:77
#define TRUE
Definition: types.h:120
bool_t __xdrrec_setnonblock(XDR *, int)
Definition: xdr_rec.c:663
Definition: rpc_msg.h:78
struct timeval ct_wait
Definition: clnt_vc.c:135
static cond_t * vc_cv
Definition: clnt_vc.c:163
bool_t xdrrec_endofrecord(XDR *xdrs, bool_t sendnow)
Definition: xdr_rec.c:555
int(* cb_fn)(void *, void *, void **)
Definition: clnt.h:147
mutex_t clnt_fd_lock
Definition: mt_misc.c:50
#define NO_ERROR
Definition: dderror.h:5
Definition: match.c:390
Definition: xdr.h:103
#define mutex_lock(m)
Definition: reentrant.h:128
FILE * stdout
#define mutex_unlock(m)
Definition: reentrant.h:129
bool_t(* xdrproc_t)(XDR *,...)
Definition: xdr.h:144
GLenum GLint GLuint mask
Definition: glext.h:6028
struct opaque_auth _null_auth
bool_t shutdown
Definition: clnt.h:149
XDR ct_xdrs
Definition: clnt_vc.c:144
void xdrrec_setlastfrag(XDR *xdrs)
Definition: xdr_rec.c:488
#define cond_wait_timed(c, m, t)
Definition: reentrant.h:136
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
bool_t use_stored_reply_msg
Definition: clnt_vc.c:146
smooth NULL
Definition: ftsmooth.c:416
#define release_fd_lock(fd, mask)
Definition: clnt_vc.c:165
int ct_fd
Definition: clnt_vc.c:133
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:420
bool_t xdr_getcallbody(XDR *xdrs, struct rpc_msg *rmsg)
Definition: rpc_prot.c:234
#define WINSOCK_HANDLE_HASH(x)
Definition: wintirpc.h:70
#define CALLBACK_TIMEOUT
Definition: clnt_vc.c:198
static FILE * out
Definition: regtests2xml.c:44
Definition: clnt.h:152
int(* cb_xdr)(void *, void *)
Definition: clnt.h:146
static int * vc_fd_locks
Definition: clnt_vc.c:161
#define RQCRED_SIZE
Definition: clnt_vc.c:199
Definition: xdr.h:85
bool_t xdr_void(void)
Definition: xdr.c:92
struct rpc_msg reply_msg
Definition: clnt_vc.c:145
Definition: rpc_msg.h:79
Definition: xdr.h:87
GLuint res
Definition: glext.h:9613
Definition: xdr.h:86
FILE * stderr
bool_t xdrrec_skiprecord(XDR *xdrs)
Definition: xdr_rec.c:496
bool_t xdr_getxiddir(XDR *xdrs, struct rpc_msg *rmsg)
Definition: rpc_prot.c:209
void * cl_private
Definition: clnt.h:142
static SERVICE_STATUS status
Definition: service.c:31
bool_t xdr_replymsg(XDR *xdrs, struct rpc_msg *rmsg)
Definition: rpc_prot.c:188
bool_t __xdrrec_setblock(XDR *)
Definition: xdr_rec.c:677
struct CFHEADER header
Definition: fdi.c:109
Definition: ps.c:97

Referenced by clnt_vc_create().

◆ clnt_vc_abort()

static void clnt_vc_abort ( CLIENT cl)
static

Definition at line 760 of file clnt_vc.c.

762 {
763 }

Referenced by clnt_vc_ops().

◆ clnt_vc_call()

static enum clnt_stat clnt_vc_call ( CLIENT cl,
rpcproc_t  proc,
xdrproc_t  xdr_args,
void args_ptr,
xdrproc_t  xdr_results,
void results_ptr,
struct timeval  timeout 
)
static

Definition at line 509 of file clnt_vc.c.

517 {
518  struct ct_data *ct = (struct ct_data *) cl->cl_private;
519  XDR *xdrs = &(ct->ct_xdrs);
520  u_int32_t x_id;
521  u_int32_t *msg_x_id = &ct->ct_u.ct_mcalli; /* yuk */
522  bool_t shipnow;
523  static int refreshes = 2;
524  u_int seq = -1;
525  time_t start_send, time_now;
526 #ifndef _WIN32
527  sigset_t mask, newmask;
528 #else
529  /* XXX Need Windows signal/event stuff XXX */
530 #endif
531  enum clnt_stat status;
532 
533  assert(cl != NULL);
534 
535 #ifndef _WIN32
536  sigfillset(&newmask);
537  thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
538 #else
539  /* XXX Need Windows signal/event stuff XXX */
540 #endif
541 
542  acquire_fd_lock(ct->ct_fd);
543 
544  if (!ct->ct_waitset) {
545  /* If time is not within limits, we ignore it. */
546  if (time_not_ok(&timeout) == FALSE)
547  ct->ct_wait = timeout;
548  }
549 
550  shipnow =
551  (xdr_results == NULL && timeout.tv_sec == 0
552  && timeout.tv_usec == 0) ? FALSE : TRUE;
553 
554 call_again:
555  __xdrrec_setblock(xdrs);
556  xdrs->x_op = XDR_ENCODE;
557  ct->ct_error.re_status = RPC_SUCCESS;
558  x_id = ntohl(--(*msg_x_id));
559 
560  if ((! XDR_PUTBYTES(xdrs, ct->ct_u.ct_mcallc, ct->ct_mpos)) ||
561  (! XDR_PUTINT32(xdrs, (int32_t *)&proc)) ||
562  (! AUTH_MARSHALL(cl->cl_auth, xdrs, &seq)) ||
563  (! AUTH_WRAP(cl->cl_auth, xdrs, xdr_args, args_ptr))) {
564  if (ct->ct_error.re_status == RPC_SUCCESS)
565  ct->ct_error.re_status = RPC_CANTENCODEARGS;
566  (void)xdrrec_endofrecord(xdrs, TRUE);
567  goto out;
568  }
569 
570  if (! xdrrec_endofrecord(xdrs, shipnow)) {
571  ct->ct_error.re_status = RPC_CANTSEND;
572  goto out;
573  }
574  if (! shipnow) {
575  release_fd_lock(ct->ct_fd, mask);
576  return (RPC_SUCCESS);
577  }
578 
579 #ifdef NO_CB_4_KRB5P
580  if (cl->cb_thread != INVALID_HANDLE_VALUE)
581  release_fd_lock(ct->ct_fd, mask);
582 #endif
583  /*
584  * Keep receiving until we get a valid transaction id
585  */
586 
587  time(&start_send);
588  while (TRUE) {
589 #ifdef NO_CB_4_KRB5P
590  if (cl->cb_thread != INVALID_HANDLE_VALUE) {
592  while ((vc_fd_locks[WINSOCK_HANDLE_HASH(ct->ct_fd)] &&
594  (ct->reply_msg.rm_xid && ct->reply_msg.rm_xid != x_id))
598  }
599 #endif
600  __xdrrec_setnonblock(xdrs, 0);
601  xdrs->x_op = XDR_DECODE;
602  ct->reply_msg.acpted_rply.ar_verf = _null_auth;
603  ct->reply_msg.acpted_rply.ar_results.where = NULL;
604  ct->reply_msg.acpted_rply.ar_results.proc = (xdrproc_t)xdr_void;
605  if (!ct->use_stored_reply_msg) {
606  if (!xdrrec_skiprecord(xdrs)) {
607  if (ct->ct_error.re_status != RPC_CANTRECV) {
608  time(&time_now);
609  if (time_now - start_send >= timeout.tv_sec) {
610  ct->ct_error.re_status = RPC_TIMEDOUT;
611  goto out;
612  }
613 #ifdef NO_CB_4_KRB5P
614  if (cl->cb_thread != INVALID_HANDLE_VALUE)
615 #endif
616  release_fd_lock(ct->ct_fd, mask);
617  SwitchToThread();
618  continue;
619  }
620  goto out;
621  }
622  if (!xdr_getxiddir(xdrs, &ct->reply_msg)) {
623  if (ct->ct_error.re_status == RPC_SUCCESS) {
624 #ifdef NO_CB_4_KRB5P
625  if (cl->cb_thread != INVALID_HANDLE_VALUE)
626 #endif
627  release_fd_lock(ct->ct_fd, mask);
628  SwitchToThread();
629  continue;
630  }
631  goto out;
632  }
633 
634  if (ct->reply_msg.rm_direction != REPLY) {
635  if (cl->cb_thread == INVALID_HANDLE_VALUE) {
636  ct->reply_msg.rm_xid = 0;
637  } else {
639  }
640  release_fd_lock(ct->ct_fd, mask);
641  SwitchToThread();
642  continue;
643  }
644  }
645  if (ct->reply_msg.rm_xid == x_id) {
647  ct->reply_msg.rm_xid = 0;
648  if (!xdr_getreplyunion(xdrs, &ct->reply_msg))
649  goto out;
650  break;
651  }
652  else {
653  time(&time_now);
654  if (time_now - start_send >= timeout.tv_sec) {
655  ct->ct_error.re_status = RPC_TIMEDOUT;
656  goto out;
657  }
659 #ifdef NO_CB_4_KRB5P
660  if (cl->cb_thread != INVALID_HANDLE_VALUE)
661 #endif
662  release_fd_lock(ct->ct_fd, mask);
663  SwitchToThread();
664  }
665  }
666 
667  /*
668  * process header
669  */
670  _seterr_reply(&ct->reply_msg, &(ct->ct_error));
671  if (ct->ct_error.re_status == RPC_SUCCESS) {
672  if (! AUTH_VALIDATE(cl->cl_auth,
673  &ct->reply_msg.acpted_rply.ar_verf, seq)) {
674  ct->ct_error.re_status = RPC_AUTHERROR;
675  ct->ct_error.re_why = AUTH_INVALIDRESP;
676  }
677  else if (! AUTH_UNWRAP(cl->cl_auth, xdrs, xdr_results, results_ptr, seq)) {
678  if (ct->ct_error.re_status == RPC_SUCCESS)
679  ct->ct_error.re_status = RPC_CANTDECODERES;
680  }
681  /* free verifier ... */
682  if (ct->reply_msg.acpted_rply.ar_verf.oa_base != NULL) {
683  xdrs->x_op = XDR_FREE;
684  (void)xdr_opaque_auth(xdrs,
685  &(ct->reply_msg.acpted_rply.ar_verf));
686  }
687  } /* end successful completion */
688  else {
689  if (ct->reply_msg.acpted_rply.ar_verf.oa_base != NULL) {
690  xdrs->x_op = XDR_FREE;
691  (void)xdr_opaque_auth(xdrs,
692  &(ct->reply_msg.acpted_rply.ar_verf));
693  }
694  /* maybe our credentials need to be refreshed ... */
695  if (refreshes-- > 0 && AUTH_REFRESH(cl->cl_auth, &ct->reply_msg))
696  goto call_again;
697  } /* end of unsuccessful completion */
698  ct->reply_msg.rm_direction = -1;
699 out:
700  status = ct->ct_error.re_status;
701  release_fd_lock(ct->ct_fd, mask);
702  return status;
703 }
BOOL WINAPI SwitchToThread(VOID)
Definition: thread.c:409
#define TRUE
Definition: types.h:120
bool_t __xdrrec_setnonblock(XDR *, int)
Definition: xdr_rec.c:663
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define XDR_PUTINT32(xdrs, int32p)
Definition: xdr.h:187
union ct_data::@175 ct_u
struct timeval ct_wait
Definition: clnt_vc.c:135
void _seterr_reply(struct rpc_msg *msg, struct rpc_err *error)
Definition: rpc_prot.c:348
char ct_mcallc[MCALL_MSG_SIZE]
Definition: clnt_vc.c:140
int32_t bool_t
Definition: types.h:101
struct rpc_err ct_error
Definition: clnt_vc.c:138
#define AUTH_UNWRAP(auth, xdrs, xfunc, xwhere, seq)
Definition: auth.h:269
static cond_t * vc_cv
Definition: clnt_vc.c:163
bool_t xdrrec_endofrecord(XDR *xdrs, bool_t sendnow)
Definition: xdr_rec.c:555
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define assert(x)
Definition: debug.h:53
Definition: dhcpd.h:245
mutex_t clnt_fd_lock
Definition: mt_misc.c:50
static HANDLE proc()
Definition: pdb.c:32
__u16 time
Definition: mkdosfs.c:366
Definition: xdr.h:103
GLbitfield GLuint64 timeout
Definition: glext.h:7164
#define mutex_lock(m)
Definition: reentrant.h:128
u_int ct_mpos
Definition: clnt_vc.c:143
#define mutex_unlock(m)
Definition: reentrant.h:129
bool_t(* xdrproc_t)(XDR *,...)
Definition: xdr.h:144
GLenum GLint GLuint mask
Definition: glext.h:6028
struct opaque_auth _null_auth
XDR ct_xdrs
Definition: clnt_vc.c:144
bool_t xdr_getreplyunion(XDR *xdrs, struct rpc_msg *rmsg)
Definition: rpc_prot.c:221
bool_t use_stored_reply_msg
Definition: clnt_vc.c:146
smooth NULL
Definition: ftsmooth.c:416
#define release_fd_lock(fd, mask)
Definition: clnt_vc.c:165
int ct_fd
Definition: clnt_vc.c:133
AUTH * cl_auth
Definition: clnt.h:122
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:420
#define WINSOCK_HANDLE_HASH(x)
Definition: wintirpc.h:70
#define acquire_fd_lock(fd)
Definition: clnt_vc.c:183
static FILE * out
Definition: regtests2xml.c:44
static bool_t time_not_ok(struct timeval *)
Definition: clnt_vc.c:1091
#define thr_sigsetmask(f, n, o)
Definition: reentrant.h:148
static int * vc_fd_locks
Definition: clnt_vc.c:161
Definition: xdr.h:85
unsigned int u_int32_t
Definition: rosdhcp.h:35
u_int32_t ct_mcalli
Definition: clnt_vc.c:141
bool_t xdr_void(void)
Definition: xdr.c:92
INT32 int32_t
Definition: types.h:71
#define AUTH_REFRESH(auth, msg)
Definition: auth.h:252
__kernel_time_t time_t
Definition: linux.h:252
UINT32 u_int
Definition: types.h:82
#define cond_wait(c, m)
Definition: reentrant.h:135
HANDLE cb_thread
Definition: clnt.h:145
#define XDR_PUTBYTES(xdrs, addr, len)
Definition: xdr.h:194
#define AUTH_WRAP(auth, xdrs, xfunc, xwhere)
Definition: auth.h:262
struct rpc_msg reply_msg
Definition: clnt_vc.c:145
bool_t xdr_opaque_auth()
#define AUTH_MARSHALL(auth, xdrs, seq)
Definition: auth.h:242
Definition: rpc_msg.h:79
Definition: xdr.h:87
Definition: xdr.h:86
bool_t xdrrec_skiprecord(XDR *xdrs)
Definition: xdr_rec.c:496
bool_t xdr_getxiddir(XDR *xdrs, struct rpc_msg *rmsg)
Definition: rpc_prot.c:209
bool_t ct_waitset
Definition: clnt_vc.c:136
#define AUTH_VALIDATE(auth, verfp, seq)
Definition: auth.h:247
void * cl_private
Definition: clnt.h:142
static SERVICE_STATUS status
Definition: service.c:31
bool_t __xdrrec_setblock(XDR *)
Definition: xdr_rec.c:677
clnt_stat
Definition: clnt_stat.h:21
#define ntohl(x)
Definition: module.h:203
Definition: ps.c:97

Referenced by clnt_vc_ops().

◆ clnt_vc_control()

static bool_t clnt_vc_control ( CLIENT cl,
u_int  request,
void info 
)
static

Definition at line 766 of file clnt_vc.c.

770 {
771  struct ct_data *ct;
772  void *infop = info;
773 #ifndef _WIN32
774  sigset_t mask;
775  sigset_t newmask;
776 #else
777  /* XXX Need Windows signal/event stuff XXX */
778 #endif
779 
780  assert(cl != NULL);
781 
782  ct = (struct ct_data *)cl->cl_private;
783 
784 #ifndef _WIN32
785  sigfillset(&newmask);
786  thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
787 #else
788  /* XXX Need Windows signal/event stuff XXX */
789 #endif
790  acquire_fd_lock(ct->ct_fd);
791 
792  switch (request) {
793  case CLSET_FD_CLOSE:
794  ct->ct_closeit = TRUE;
795  release_fd_lock(ct->ct_fd, mask);
796  return (TRUE);
797  case CLSET_FD_NCLOSE:
798  ct->ct_closeit = FALSE;
799  release_fd_lock(ct->ct_fd, mask);
800  return (TRUE);
801  default:
802  break;
803  }
804 
805  /* for other requests which use info */
806  if (info == NULL) {
807  release_fd_lock(ct->ct_fd, mask);
808  return (FALSE);
809  }
810  switch (request) {
811  case CLSET_TIMEOUT:
812  if (time_not_ok((struct timeval *)info)) {
813  release_fd_lock(ct->ct_fd, mask);
814  return (FALSE);
815  }
816  ct->ct_wait = *(struct timeval *)infop;
817  ct->ct_waitset = TRUE;
818  break;
819  case CLGET_TIMEOUT:
820  *(struct timeval *)infop = ct->ct_wait;
821  break;
822  case CLGET_SERVER_ADDR:
823  (void) memcpy(info, ct->ct_addr.buf, (size_t)ct->ct_addr.len);
824  break;
825  case CLGET_FD:
826  *(int *)info = ct->ct_fd;
827  break;
828  case CLGET_SVC_ADDR:
829  /* The caller should not free this memory area */
830  *(struct netbuf *)info = ct->ct_addr;
831  break;
832  case CLSET_SVC_ADDR: /* set to new address */
833  release_fd_lock(ct->ct_fd, mask);
834  return (FALSE);
835  case CLGET_XID:
836  /*
837  * use the knowledge that xid is the
838  * first element in the call structure
839  * This will get the xid of the PREVIOUS call
840  */
841  *(u_int32_t *)info =
842  ntohl(*(u_int32_t *)(void *)&ct->ct_u.ct_mcalli);
843  break;
844  case CLSET_XID:
845  /* This will set the xid of the NEXT call */
846  *(u_int32_t *)(void *)&ct->ct_u.ct_mcalli =
847  htonl(*((u_int32_t *)info) + 1);
848  /* increment by 1 as clnt_vc_call() decrements once */
849  break;
850  case CLGET_VERS:
851  /*
852  * This RELIES on the information that, in the call body,
853  * the version number field is the fifth field from the
854  * begining of the RPC header. MUST be changed if the
855  * call_struct is changed
856  */
857  *(u_int32_t *)info =
858  ntohl(*(u_int32_t *)(void *)(ct->ct_u.ct_mcallc +
859  4 * BYTES_PER_XDR_UNIT));
860  break;
861 
862  case CLSET_VERS:
863  *(u_int32_t *)(void *)(ct->ct_u.ct_mcallc +
864  4 * BYTES_PER_XDR_UNIT) =
865  htonl(*(u_int32_t *)info);
866  break;
867 
868  case CLGET_PROG:
869  /*
870  * This RELIES on the information that, in the call body,
871  * the program number field is the fourth field from the
872  * begining of the RPC header. MUST be changed if the
873  * call_struct is changed
874  */
875  *(u_int32_t *)info =
876  ntohl(*(u_int32_t *)(void *)(ct->ct_u.ct_mcallc +
877  3 * BYTES_PER_XDR_UNIT));
878  break;
879 
880  case CLSET_PROG:
881  *(u_int32_t *)(void *)(ct->ct_u.ct_mcallc +
882  3 * BYTES_PER_XDR_UNIT) =
883  htonl(*(u_int32_t *)info);
884  break;
885 
886  default:
887  release_fd_lock(ct->ct_fd, mask);
888  return (FALSE);
889  }
890  release_fd_lock(ct->ct_fd, mask);
891  return (TRUE);
892 }
#define TRUE
Definition: types.h:120
union ct_data::@175 ct_u
struct timeval ct_wait
Definition: clnt_vc.c:135
#define CLSET_SVC_ADDR
Definition: clnt.h:259
#define CLGET_FD
Definition: clnt.h:249
#define htonl(x)
Definition: module.h:212
char ct_mcallc[MCALL_MSG_SIZE]
Definition: clnt_vc.c:140
#define assert(x)
Definition: debug.h:53
#define CLGET_VERS
Definition: clnt.h:255
#define CLSET_FD_NCLOSE
Definition: clnt.h:252
#define CLSET_XID
Definition: clnt.h:254
#define CLSET_FD_CLOSE
Definition: clnt.h:251
struct _test_info info[]
Definition: SetCursorPos.c:19
GLenum GLint GLuint mask
Definition: glext.h:6028
smooth NULL
Definition: ftsmooth.c:416
bool_t ct_closeit
Definition: clnt_vc.c:134
#define release_fd_lock(fd, mask)
Definition: clnt_vc.c:165
int ct_fd
Definition: clnt_vc.c:133
struct netbuf ct_addr
Definition: clnt_vc.c:137
#define CLGET_SERVER_ADDR
Definition: clnt.h:248
#define acquire_fd_lock(fd)
Definition: clnt_vc.c:183
#define CLSET_PROG
Definition: clnt.h:258
#define CLSET_TIMEOUT
Definition: clnt.h:246
static bool_t time_not_ok(struct timeval *)
Definition: clnt_vc.c:1091
#define thr_sigsetmask(f, n, o)
Definition: reentrant.h:148
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned int u_int32_t
Definition: rosdhcp.h:35
u_int32_t ct_mcalli
Definition: clnt_vc.c:141
#define CLGET_XID
Definition: clnt.h:253
#define CLGET_SVC_ADDR
Definition: clnt.h:250
#define CLSET_VERS
Definition: clnt.h:256
Definition: tftpd.h:85
#define CLGET_PROG
Definition: clnt.h:257
Definition: types.h:144
#define CLGET_TIMEOUT
Definition: clnt.h:247
bool_t ct_waitset
Definition: clnt_vc.c:136
void * cl_private
Definition: clnt.h:142
#define ntohl(x)
Definition: module.h:203
#define BYTES_PER_XDR_UNIT
Definition: xdr.h:93

Referenced by clnt_vc_ops().

◆ clnt_vc_create()

CLIENT* clnt_vc_create ( int  fd,
const struct netbuf raddr,
const rpcprog_t  prog,
const rpcvers_t  vers,
u_int  sendsz,
u_int  recvsz,
int cb_xdr,
int cb_fn,
void cb_args 
)

Definition at line 324 of file clnt_vc.c.

334 {
335  CLIENT *cl; /* client handle */
336  struct ct_data *ct = NULL; /* client handle */
337  struct timeval now;
338  struct rpc_msg call_msg;
339  static u_int32_t disrupt;
340 #ifndef _WIN32
341  sigset_t mask;
342  sigset_t newmask;
343 #else
344  /* XXX Need Windows signal/event stuff XXX */
345 #endif
346  struct sockaddr_storage ss;
347  socklen_t slen;
348  struct __rpc_sockinfo si;
349 
350  if (disrupt == 0)
351  disrupt = PtrToUlong(raddr);
352 
353  cl = (CLIENT *)mem_alloc(sizeof (*cl));
354  ct = (struct ct_data *)mem_alloc(sizeof (*ct));
355  if ((cl == (CLIENT *)NULL) || (ct == (struct ct_data *)NULL)) {
356 // (void) syslog(LOG_ERR, clnt_vc_errstr,
357 // clnt_vc_str, __no_mem_str);
359  rpc_createerr.cf_error.re_errno = errno;
360  goto err;
361  }
362  ct->ct_addr.buf = NULL;
363 #ifndef _WIN32
364  sigfillset(&newmask);
365  thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
366 #else
367  /* XXX Need Windows signal/event stuff XXX */
368 #endif
370  if (vc_fd_locks == (int *) NULL) {
371  int cv_allocsz, fd_allocsz;
372  int dtbsize = __rpc_dtbsize();
373 
374  fd_allocsz = dtbsize * sizeof (int);
375  vc_fd_locks = (int *) mem_alloc(fd_allocsz);
376  if (vc_fd_locks == (int *) NULL) {
378 // thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
379  goto err;
380  } else
381  memset(vc_fd_locks, 0, fd_allocsz);
382 
383  assert(vc_cv == (cond_t *) NULL);
384  cv_allocsz = dtbsize * sizeof (cond_t);
385  vc_cv = (cond_t *) mem_alloc(cv_allocsz);
386  if (vc_cv == (cond_t *) NULL) {
387  mem_free(vc_fd_locks, fd_allocsz);
388  vc_fd_locks = (int *) NULL;
390 // thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
391  goto err;
392  } else {
393  int i;
394 
395  for (i = 0; i < dtbsize; i++)
396  cond_init(&vc_cv[i], 0, (void *) 0);
397  }
398  } else
399  assert(vc_cv != (cond_t *) NULL);
400 
401  /*
402  * XXX - fvdl connecting while holding a mutex?
403  */
404  slen = sizeof ss;
405  if (getpeername(fd, (struct sockaddr *)&ss, &slen) == SOCKET_ERROR) {
407  if (errno != WSAENOTCONN) {
409  rpc_createerr.cf_error.re_errno = errno;
411 // thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
412  goto err;
413  }
414  if (connect(fd, (struct sockaddr *)raddr->buf, raddr->len) == SOCKET_ERROR){
418 // thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
419  goto err;
420  }
421  }
423  if (!__rpc_fd2sockinfo(fd, &si))
424  goto err;
425 // thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
426 
427  ct->ct_closeit = FALSE;
428 
429  /*
430  * Set up private data struct
431  */
432  ct->ct_fd = fd;
433  ct->ct_wait.tv_usec = 0;
434  ct->ct_waitset = FALSE;
435  ct->ct_addr.buf = malloc(raddr->maxlen);
436  if (ct->ct_addr.buf == NULL)
437  goto err;
438  memcpy(ct->ct_addr.buf, raddr->buf, raddr->len);
439  ct->ct_addr.len = raddr->len;
440  ct->ct_addr.maxlen = raddr->maxlen;
442 
443  /*
444  * Initialize call message
445  */
447  call_msg.rm_xid = ((u_int32_t)++disrupt) ^ __RPC_GETXID(&now);
448  call_msg.rm_direction = CALL;
449  call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
450  call_msg.rm_call.cb_prog = (u_int32_t)prog;
451  call_msg.rm_call.cb_vers = (u_int32_t)vers;
452 
453  /*
454  * pre-serialize the static part of the call msg and stash it away
455  */
457  XDR_ENCODE);
458  if (! xdr_callhdr(&(ct->ct_xdrs), &call_msg)) {
459  if (ct->ct_closeit) {
460  (void)closesocket(fd);
461  }
462  goto err;
463  }
464  ct->ct_mpos = XDR_GETPOS(&(ct->ct_xdrs));
465  XDR_DESTROY(&(ct->ct_xdrs));
466 
467  /*
468  * Create a client handle which uses xdrrec for serialization
469  * and authnone for authentication.
470  */
471  cl->cl_ops = clnt_vc_ops();
472  cl->cl_private = ct;
473  cl->cl_auth = authnone_create();
474  sendsz = __rpc_get_t_size(si.si_af, si.si_proto, (int)sendsz);
475  recvsz = __rpc_get_t_size(si.si_af, si.si_proto, (int)recvsz);
476  xdrrec_create(&(ct->ct_xdrs), sendsz, recvsz,
477  cl->cl_private, read_vc, write_vc);
478 
479  if (cb_xdr && cb_fn && cb_args) {
480  cl->cb_xdr = cb_xdr;
481  cl->cb_fn = cb_fn;
482  cl->cb_args = cb_args;
484  0, clnt_cb_thread, cl, 0, NULL);
485  if (cl->cb_thread == INVALID_HANDLE_VALUE) {
486  fprintf(stderr, "_beginthreadex failed %d\n", GetLastError());
487  goto err;
488  } else
489  fprintf(stdout, "%04x: started the callback thread %04x\n",
491  } else
493  return (cl);
494 
495 err:
496  if (cl) {
497  if (ct) {
498  if (ct->ct_addr.len)
499  mem_free(ct->ct_addr.buf, ct->ct_addr.len);
500  mem_free(ct, sizeof (struct ct_data));
501  }
502  if (cl)
503  mem_free(cl, sizeof (CLIENT));
504  }
505  return ((CLIENT *)NULL);
506 }
void * cb_args
Definition: clnt.h:148
static struct clnt_ops * clnt_vc_ops(void)
Definition: clnt_vc.c:1058
u_int __rpc_get_t_size(int af, int proto, int size)
Definition: rpc_generic.c:139
#define SOCKET_ERROR
Definition: winsock.h:333
int __rpc_dtbsize(void)
Definition: rpc_generic.c:110
#define XDR_GETPOS(xdrs)
Definition: xdr.h:199
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
union ct_data::@175 ct_u
Definition: rpc_msg.h:78
struct timeval ct_wait
Definition: clnt_vc.c:135
static unsigned int WINAPI clnt_cb_thread(void *args)
Definition: clnt_vc.c:200
char ct_mcallc[MCALL_MSG_SIZE]
Definition: clnt_vc.c:140
char * prog
Definition: isohybrid.c:47
static cond_t * vc_cv
Definition: clnt_vc.c:163
#define cond_t
Definition: reentrant.h:120
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define assert(x)
Definition: debug.h:53
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
void * buf
Definition: types.h:147
static int fd
Definition: io.c:51
int(* cb_fn)(void *, void *, void **)
Definition: clnt.h:147
mutex_t clnt_fd_lock
Definition: mt_misc.c:50
int errno
_CRTIMP uintptr_t __cdecl _beginthreadex(_In_opt_ void *_Security, _In_ unsigned _StackSize, _In_ unsigned(__stdcall *_StartAddress)(void *), _In_opt_ void *_ArgList, _In_ unsigned _InitFlag, _Out_opt_ unsigned *_ThrdAddr)
#define cond_init(c, a, p)
Definition: reentrant.h:132
INT WSAAPI connect(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: sockctrl.c:23
#define mutex_lock(m)
Definition: reentrant.h:128
FILE * stdout
u_int ct_mpos
Definition: clnt_vc.c:143
#define mutex_unlock(m)
Definition: reentrant.h:129
#define gettimeofday(tv, tz)
Definition: adns_win32.h:159
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define mem_alloc(bsize)
Definition: types.h:123
GLenum GLint GLuint mask
Definition: glext.h:6028
int __rpc_fd2sockinfo(SOCKET fd, struct __rpc_sockinfo *sip)
Definition: rpc_generic.c:481
#define closesocket
Definition: main.c:39
XDR ct_xdrs
Definition: clnt_vc.c:144
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
time_t now
Definition: finger.c:65
bool_t use_stored_reply_msg
Definition: clnt_vc.c:146
smooth NULL
Definition: ftsmooth.c:416
bool_t ct_closeit
Definition: clnt_vc.c:134
int ct_fd
Definition: clnt_vc.c:133
AUTH * cl_auth
Definition: clnt.h:122
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:420
#define PtrToUlong(u)
Definition: config.h:107
struct netbuf ct_addr
Definition: clnt_vc.c:137
INT WSAAPI getpeername(IN SOCKET s, OUT LPSOCKADDR name, IN OUT INT FAR *namelen)
Definition: sockctrl.c:167
#define MCALL_MSG_SIZE
Definition: clnt_vc.c:94
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
enum clnt_stat cf_stat
Definition: clnt.h:496
static int write_vc(void *, void *, int)
static int read_vc(void *, void *, int)
Definition: clnt_vc.c:959
PVOID HANDLE
Definition: typedefs.h:71
int socklen_t
Definition: tcp.c:35
unsigned int maxlen
Definition: types.h:145
unsigned int len
Definition: types.h:146
int(* cb_xdr)(void *, void *)
Definition: clnt.h:146
#define thr_sigsetmask(f, n, o)
Definition: reentrant.h:148
static int * vc_fd_locks
Definition: clnt_vc.c:161
Definition: xdr.h:85
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned int u_int32_t
Definition: rosdhcp.h:35
#define WSAENOTCONN
Definition: winerror.h:1970
#define err(...)
#define RPC_MSG_VERSION
Definition: rpc_msg.h:66
HANDLE cb_thread
Definition: clnt.h:145
#define __RPC_GETXID(now)
Definition: rpc_com.h:58
void xdrmem_create(XDR *xdrs, char *addr, u_int size, enum xdr_op op)
Definition: xdr_mem.c:94
AUTH * authnone_create()
Definition: auth_none.c:100
struct rpc_err cf_error
Definition: clnt.h:497
FILE * stderr
#define mem_free(ptr, bsize)
Definition: types.h:124
#define malloc
Definition: debug_ros.c:4
bool_t ct_waitset
Definition: clnt_vc.c:136
#define u_int32_t
Definition: icmp.c:53
void * cl_private
Definition: clnt.h:142
#define ss
Definition: i386-dis.c:432
struct __rpc_client::clnt_ops * cl_ops
bool_t xdr_callhdr(XDR *xdrs, struct rpc_msg *cmsg)
Definition: rpc_prot.c:257
#define memset(x, y, z)
Definition: compat.h:39
#define XDR_DESTROY(xdrs)
Definition: xdr.h:214
void xdrrec_create(XDR *xdrs, u_int sendsize, u_int recvsize, int *void *, int *readit, int *writeit)
Definition: xdr_rec.c:179
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by clnt_tli_create(), and local_rpcb().

◆ clnt_vc_destroy()

static void clnt_vc_destroy ( CLIENT cl)
static

Definition at line 896 of file clnt_vc.c.

898 {
899  struct ct_data *ct = (struct ct_data *) cl->cl_private;
900  int ct_fd = ct->ct_fd;
901 #ifndef _WIN32
902  sigset_t mask;
903  sigset_t newmask;
904 #else
905  /* XXX Need Windows signal/event stuff XXX */
906 #endif
907 
908  assert(cl != NULL);
909 
910  ct = (struct ct_data *) cl->cl_private;
911 
912 #ifndef _WIN32
913  sigfillset(&newmask);
914  thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
915 #else
916  /* XXX Need Windows signal/event stuff XXX */
917 #endif
921 
922  if (cl->cb_thread != INVALID_HANDLE_VALUE) {
923  int status;
924  fprintf(stdout, "%04x: sending shutdown to callback thread %04x\n",
926  cl->shutdown = 1;
930  fprintf(stdout, "%04x: terminated callback thread\n", GetCurrentThreadId());
934  }
935 
936  if (ct->ct_closeit && ct->ct_fd != -1) {
937  (void)closesocket(ct->ct_fd);
938  }
939  XDR_DESTROY(&(ct->ct_xdrs));
940  if (ct->ct_addr.buf)
941  free(ct->ct_addr.buf);
942  mem_free(ct, sizeof(struct ct_data));
943  if (cl->cl_netid && cl->cl_netid[0])
944  mem_free(cl->cl_netid, strlen(cl->cl_netid) +1);
945  if (cl->cl_tp && cl->cl_tp[0])
946  mem_free(cl->cl_tp, strlen(cl->cl_tp) +1);
947  mem_free(cl, sizeof(CLIENT));
949 // thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
951 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define free
Definition: debug_ros.c:5
static cond_t * vc_cv
Definition: clnt_vc.c:163
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define assert(x)
Definition: debug.h:53
mutex_t clnt_fd_lock
Definition: mt_misc.c:50
#define mutex_lock(m)
Definition: reentrant.h:128
FILE * stdout
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define mutex_unlock(m)
Definition: reentrant.h:129
GLenum GLint GLuint mask
Definition: glext.h:6028
#define closesocket
Definition: main.c:39
bool_t shutdown
Definition: clnt.h:149
XDR ct_xdrs
Definition: clnt_vc.c:144
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
smooth NULL
Definition: ftsmooth.c:416
bool_t ct_closeit
Definition: clnt_vc.c:134
int ct_fd
Definition: clnt_vc.c:133
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:420
char * cl_tp
Definition: clnt.h:144
struct netbuf ct_addr
Definition: clnt_vc.c:137
#define WINSOCK_HANDLE_HASH(x)
Definition: wintirpc.h:70
#define cond_signal(m)
Definition: reentrant.h:133
#define thr_sigsetmask(f, n, o)
Definition: reentrant.h:148
static int * vc_fd_locks
Definition: clnt_vc.c:161
char * cl_netid
Definition: clnt.h:143
#define cond_wait(c, m)
Definition: reentrant.h:135
HANDLE cb_thread
Definition: clnt.h:145
#define mem_free(ptr, bsize)
Definition: types.h:124
void * cl_private
Definition: clnt.h:142
#define INFINITE
Definition: serial.h:102
static SERVICE_STATUS status
Definition: service.c:31
#define XDR_DESTROY(xdrs)
Definition: xdr.h:214
Definition: ps.c:97

Referenced by clnt_vc_ops().

◆ clnt_vc_freeres()

static bool_t clnt_vc_freeres ( CLIENT cl,
xdrproc_t  xdr_res,
void res_ptr 
)
static

Definition at line 720 of file clnt_vc.c.

724 {
725  struct ct_data *ct;
726  XDR *xdrs;
727  bool_t dummy;
728 #ifndef _WIN32
729  sigset_t mask;
730  sigset_t newmask;
731 #else
732  /* XXX Need Windows signal/event stuff XXX */
733 #endif
734 
735  assert(cl != NULL);
736 
737  ct = (struct ct_data *)cl->cl_private;
738  xdrs = &(ct->ct_xdrs);
739 
740 #ifndef _WIN32
741  sigfillset(&newmask);
742  thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
743 #else
744  /* XXX Need Windows signal/event stuff XXX */
745 #endif
749  xdrs->x_op = XDR_FREE;
750  dummy = (*xdr_res)(xdrs, res_ptr);
752 // thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
754 
755  return dummy;
756 }
int32_t bool_t
Definition: types.h:101
static cond_t * vc_cv
Definition: clnt_vc.c:163
#define assert(x)
Definition: debug.h:53
mutex_t clnt_fd_lock
Definition: mt_misc.c:50
Definition: xdr.h:103
#define mutex_lock(m)
Definition: reentrant.h:128
#define mutex_unlock(m)
Definition: reentrant.h:129
GLenum GLint GLuint mask
Definition: glext.h:6028
XDR ct_xdrs
Definition: clnt_vc.c:144
smooth NULL
Definition: ftsmooth.c:416
int ct_fd
Definition: clnt_vc.c:133
#define WINSOCK_HANDLE_HASH(x)
Definition: wintirpc.h:70
enum xdr_op x_op
Definition: xdr.h:104
#define cond_signal(m)
Definition: reentrant.h:133
#define thr_sigsetmask(f, n, o)
Definition: reentrant.h:148
static int * vc_fd_locks
Definition: clnt_vc.c:161
#define cond_wait(c, m)
Definition: reentrant.h:135
unsigned char dummy
Definition: maze.c:118
Definition: xdr.h:87
void * cl_private
Definition: clnt.h:142

Referenced by clnt_vc_ops().

◆ clnt_vc_geterr()

static void clnt_vc_geterr ( CLIENT cl,
struct rpc_err errp 
)
static

Definition at line 706 of file clnt_vc.c.

709 {
710  struct ct_data *ct;
711 
712  assert(cl != NULL);
713  assert(errp != NULL);
714 
715  ct = (struct ct_data *) cl->cl_private;
716  *errp = ct->ct_error;
717 }
struct rpc_err ct_error
Definition: clnt_vc.c:138
#define assert(x)
Definition: debug.h:53
smooth NULL
Definition: ftsmooth.c:416
void * cl_private
Definition: clnt.h:142

Referenced by clnt_vc_ops().

◆ clnt_vc_ops()

static struct clnt_ops * clnt_vc_ops ( void  )
static

Definition at line 1058 of file clnt_vc.c.

1059 {
1060  static struct clnt_ops ops;
1061  extern mutex_t ops_lock;
1062 #ifndef _WIN32
1063  sigset_t mask, newmask;
1064 
1065  /* VARIABLES PROTECTED BY ops_lock: ops */
1066 
1067  sigfillset(&newmask);
1068  thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
1069 #else
1070  /* XXX Need Windows signal/event stuff XXX */
1071 #endif
1072  mutex_lock(&ops_lock);
1073  if (ops.cl_call == NULL) {
1074  ops.cl_call = clnt_vc_call;
1075  ops.cl_abort = clnt_vc_abort;
1076  ops.cl_geterr = clnt_vc_geterr;
1077  ops.cl_freeres = clnt_vc_freeres;
1078  ops.cl_destroy = clnt_vc_destroy;
1079  ops.cl_control = clnt_vc_control;
1080  }
1082 // thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
1083  return (&ops);
1084 }
static bool_t clnt_vc_freeres(CLIENT *, xdrproc_t, void *)
Definition: clnt_vc.c:720
mutex_t ops_lock
Definition: mt_misc.c:71
static enum clnt_stat clnt_vc_call(CLIENT *, rpcproc_t, xdrproc_t, void *, xdrproc_t, void *, struct timeval)
Definition: clnt_vc.c:509
#define mutex_lock(m)
Definition: reentrant.h:128
#define mutex_unlock(m)
Definition: reentrant.h:129
GLenum GLint GLuint mask
Definition: glext.h:6028
smooth NULL
Definition: ftsmooth.c:416
static void clnt_vc_destroy(CLIENT *)
Definition: clnt_vc.c:896
static void clnt_vc_geterr(CLIENT *, struct rpc_err *)
Definition: clnt_vc.c:706
#define thr_sigsetmask(f, n, o)
Definition: reentrant.h:148
static bool_t clnt_vc_control(CLIENT *, u_int, void *)
Definition: clnt_vc.c:766
Definition: module.h:446
static void clnt_vc_abort(CLIENT *)
Definition: clnt_vc.c:760

Referenced by clnt_vc_create().

◆ read_vc()

static int read_vc ( void ctp,
void buf,
int  len 
)
static

Definition at line 959 of file clnt_vc.c.

963 {
964  /*
965  struct sockaddr sa;
966  socklen_t sal;
967  */
968  struct ct_data *ct = (struct ct_data *)ctp;
969  struct pollfd fd;
970  int milliseconds = ct->ct_wait.tv_usec;
971 
972  if (len == 0)
973  return (0);
974  fd.fd = ct->ct_fd;
975  fd.events = POLLIN;
976  for (;;) {
977 #ifndef __REACTOS__
978  switch (poll(&fd, 1, milliseconds)) {
979 #else
980  /* ReactOS: use select instead of poll */
981  fd_set infd;
982  struct timeval timeout;
983 
984  FD_ZERO(&infd);
985  FD_SET(ct->ct_fd, &infd);
986 
987  timeout.tv_sec = 0;
988  timeout.tv_usec = milliseconds * 1000;
989 
990  switch (select(0, &infd, NULL, NULL, &timeout)) {
991 #endif
992 
993  case 0:
994  ct->ct_error.re_status = RPC_TIMEDOUT;
995  return (-1);
996 
997  case SOCKET_ERROR:
999  if (errno == WSAEINTR)
1000  continue;
1001  ct->ct_error.re_status = RPC_CANTRECV;
1002  ct->ct_error.re_errno = errno;
1003  return (-2);
1004  }
1005  break;
1006  }
1007 
1008  len = recv(ct->ct_fd, buf, (size_t)len, 0);
1009  errno = WSAGetLastError();
1010 
1011  switch (len) {
1012  case 0:
1013  /* premature eof */
1014  ct->ct_error.re_errno = WSAECONNRESET;
1015  ct->ct_error.re_status = RPC_CANTRECV;
1016  len = -1; /* it's really an error */
1017  break;
1018 
1019  case SOCKET_ERROR:
1020  ct->ct_error.re_errno = errno;
1021  ct->ct_error.re_status = RPC_CANTRECV;
1022  break;
1023  }
1024  return (len);
1025 }
Definition: winsock.h:66
#define SOCKET_ERROR
Definition: winsock.h:333
struct timeval ct_wait
Definition: clnt_vc.c:135
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
struct rpc_err ct_error
Definition: clnt_vc.c:138
static int fd
Definition: io.c:51
Definition: dhcpd.h:245
int errno
#define FD_ZERO(set)
Definition: winsock.h:96
#define FD_SET(fd, set)
Definition: winsock.h:89
INT WSAAPI select(IN INT s, IN OUT LPFD_SET readfds, IN OUT LPFD_SET writefds, IN OUT LPFD_SET exceptfds, IN CONST struct timeval *timeout)
Definition: select.c:41
smooth NULL
Definition: ftsmooth.c:416
int ct_fd
Definition: clnt_vc.c:133
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
int poll(struct pollfd *ufds, int nfds, int timeout)
Definition: adnstest.c:68
#define POLLIN
Definition: linux.h:1853
Definition: linux.h:1867
GLenum GLsizei len
Definition: glext.h:6722
#define WSAECONNRESET
Definition: winerror.h:1967
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
Definition: recv.c:23
#define WSAEINTR
Definition: winerror.h:1942

Referenced by clnt_vc_create().

◆ time_not_ok()

static bool_t time_not_ok ( struct timeval t)
static

Definition at line 1091 of file clnt_vc.c.

1093 {
1094  return (t->tv_sec <= -1 || t->tv_sec > 100000000 ||
1095  t->tv_usec <= -1 || t->tv_usec > 1000000);
1096 }
GLdouble GLdouble t
Definition: gl.h:2047

Referenced by clnt_vc_control().

◆ write_vc() [1/2]

static int write_vc ( void ,
void ,
int   
)
static

Referenced by clnt_vc_create().

◆ write_vc() [2/2]

static int write_vc ( void ctp,
char buf,
int  len 
)
static

Definition at line 1029 of file clnt_vc.c.

1040 {
1041  struct ct_data *ct = (struct ct_data *)ctp;
1042  int i = 0, cnt;
1043 #ifdef __REACTOS__
1044  char *buf = ptr;
1045 #endif
1046 
1047  for (cnt = len; cnt > 0; cnt -= i, buf += i) {
1048  if ((i = send(ct->ct_fd, buf, (size_t)cnt, 0)) == SOCKET_ERROR) {
1049  ct->ct_error.re_errno = WSAGetLastError();
1050  ct->ct_error.re_status = RPC_CANTSEND;
1051  return (-1);
1052  }
1053  }
1054  return (len);
1055 }
#define SOCKET_ERROR
Definition: winsock.h:333
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
struct rpc_err ct_error
Definition: clnt_vc.c:138
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static PVOID ptr
Definition: dispmode.c:27
int ct_fd
Definition: clnt_vc.c:133
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23
GLenum GLsizei len
Definition: glext.h:6722

Variable Documentation

◆ __no_mem_str

const char __no_mem_str[] = "out of memory"
static

Definition at line 195 of file clnt_vc.c.

◆ clnt_fd_lock

mutex_t clnt_fd_lock

Definition at line 50 of file mt_misc.c.

Referenced by clnt_cb_thread(), clnt_vc_create(), clnt_vc_destroy(), and clnt_vc_freeres().

◆ clnt_read_vc_str

const char clnt_read_vc_str[] = "read_vc"
static

Definition at line 194 of file clnt_vc.c.

◆ clnt_vc_errstr

const char clnt_vc_errstr[] = "%s : %s"
static

Definition at line 192 of file clnt_vc.c.

◆ clnt_vc_str

const char clnt_vc_str[] = "clnt_vc_create"
static

Definition at line 193 of file clnt_vc.c.

◆ vc_cv

cond_t* vc_cv
static

Definition at line 163 of file clnt_vc.c.

Referenced by clnt_cb_thread(), clnt_vc_create(), clnt_vc_destroy(), and clnt_vc_freeres().

◆ vc_fd_locks

int* vc_fd_locks
static

Definition at line 161 of file clnt_vc.c.

Referenced by clnt_cb_thread(), clnt_vc_create(), clnt_vc_destroy(), and clnt_vc_freeres().