ReactOS 0.4.16-dev-88-ga65b6ae
svc.h File Reference
#include <rpc/svc_soc.h>
Include dependency graph for svc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  __rpc_svcxprt
 
struct  __rpc_svcxprt::xp_ops
 
struct  __rpc_svcxprt::xp_ops2
 
struct  svc_req
 

Macros

#define SVCGET_VERSQUIET   1
 
#define SVCSET_VERSQUIET   2
 
#define SVCGET_CONNMAXREC   3
 
#define SVCSET_CONNMAXREC   4
 
#define RPC_SVC_CONNMAXREC_SET   0 /* set max rec size, enable nonblock */
 
#define RPC_SVC_CONNMAXREC_GET   1
 
#define svc_getrpccaller(x)   (&(x)->xp_rtaddr)
 
#define SVC_RECV(xprt, msg)    (*(xprt)->xp_ops->xp_recv)((xprt), (msg))
 
#define svc_recv(xprt, msg)    (*(xprt)->xp_ops->xp_recv)((xprt), (msg))
 
#define SVC_STAT(xprt)    (*(xprt)->xp_ops->xp_stat)(xprt)
 
#define svc_stat(xprt)    (*(xprt)->xp_ops->xp_stat)(xprt)
 
#define SVC_GETARGS(xprt, xargs, argsp)    (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
 
#define svc_getargs(xprt, xargs, argsp)    (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
 
#define SVC_REPLY(xprt, msg)    (*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
 
#define svc_reply(xprt, msg)    (*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
 
#define SVC_FREEARGS(xprt, xargs, argsp)    (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
 
#define svc_freeargs(xprt, xargs, argsp)    (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
 
#define SVC_DESTROY(xprt)    (*(xprt)->xp_ops->xp_destroy)(xprt)
 
#define svc_destroy(xprt)    (*(xprt)->xp_ops->xp_destroy)(xprt)
 
#define SVC_CONTROL(xprt, rq, in)    (*(xprt)->xp_ops2->xp_control)((xprt), (rq), (in))
 
#define RPC_ANYSOCK   INVALID_SOCKET /* -1 */
 
#define RPC_ANYFD   RPC_ANYSOCK
 

Typedefs

typedef struct __rpc_svcxprt SVCXPRT
 

Enumerations

enum  xprt_stat { XPRT_DIED , XPRT_MOREREQS , XPRT_IDLE }
 

Functions

__BEGIN_DECLS bool_t svc_reg (SVCXPRT *, const rpcprog_t, const rpcvers_t, void(*)(struct svc_req *, SVCXPRT *), const struct netconfig *)
 
__END_DECLS __BEGIN_DECLS void svc_unreg (const rpcprog_t, const rpcvers_t)
 
__END_DECLS __BEGIN_DECLS void xprt_register (SVCXPRT *)
 
__END_DECLS __BEGIN_DECLS void xprt_unregister (SVCXPRT *)
 
__END_DECLS __BEGIN_DECLS bool_t svc_sendreply (SVCXPRT *, xdrproc_t, void *)
 
void svcerr_decode (SVCXPRT *)
 
void svcerr_weakauth (SVCXPRT *)
 
void svcerr_noproc (SVCXPRT *)
 
void svcerr_progvers (SVCXPRT *, rpcvers_t, rpcvers_t)
 
void svcerr_auth (SVCXPRT *, enum auth_stat)
 
void svcerr_noprog (SVCXPRT *)
 
void svcerr_systemerr (SVCXPRT *)
 
int rpc_reg (rpcprog_t, rpcvers_t, rpcproc_t, char *(*)(char *), xdrproc_t, xdrproc_t, char *)
 
__BEGIN_DECLS void rpctest_service (void)
 
__END_DECLS __BEGIN_DECLS void svc_getreq (int)
 
void svc_getreqset (fd_set *)
 
void svc_getreq_common (SOCKET)
 
void svc_getreq_poll (struct pollfd *, int)
 
void svc_run (void)
 
void svc_exit (void)
 
__BEGIN_DECLS int svc_create (void(*)(struct svc_req *, SVCXPRT *), const rpcprog_t, const rpcvers_t, const char *)
 
SVCXPRTsvc_tp_create (void(*)(struct svc_req *, SVCXPRT *), const rpcprog_t, const rpcvers_t, const struct netconfig *)
 
SVCXPRTsvc_tli_create (const SOCKET, const struct netconfig *, const struct t_bind *, const u_int, const u_int)
 
SVCXPRTsvc_vc_create (const SOCKET, const u_int, const u_int)
 
SVCXPRTsvcunix_create (int, u_int, u_int, char *)
 
SVCXPRTsvc_dg_create (const SOCKET, const u_int, const u_int)
 
SVCXPRTsvc_fd_create (const SOCKET, const u_int, const u_int)
 
SVCXPRTsvcunixfd_create (int, u_int, u_int)
 
SVCXPRTsvc_raw_create (void)
 
int svc_dg_enablecache (SVCXPRT *, const u_int)
 
int __rpc_get_local_uid (SVCXPRT *_transp, uid_t *_uid)
 

Variables

__END_DECLS int svc_maxfd
 
int svc_fds
 

Macro Definition Documentation

◆ RPC_ANYFD

#define RPC_ANYFD   RPC_ANYSOCK

Definition at line 328 of file svc.h.

◆ RPC_ANYSOCK

#define RPC_ANYSOCK   INVALID_SOCKET /* -1 */

Definition at line 327 of file svc.h.

◆ RPC_SVC_CONNMAXREC_GET

#define RPC_SVC_CONNMAXREC_GET   1

Definition at line 79 of file svc.h.

◆ RPC_SVC_CONNMAXREC_SET

#define RPC_SVC_CONNMAXREC_SET   0 /* set max rec size, enable nonblock */

Definition at line 78 of file svc.h.

◆ SVC_CONTROL

#define SVC_CONTROL (   xprt,
  rq,
  in 
)     (*(xprt)->xp_ops2->xp_control)((xprt), (rq), (in))

Definition at line 189 of file svc.h.

◆ SVC_DESTROY

#define SVC_DESTROY (   xprt)     (*(xprt)->xp_ops->xp_destroy)(xprt)

Definition at line 184 of file svc.h.

◆ svc_destroy

#define svc_destroy (   xprt)     (*(xprt)->xp_ops->xp_destroy)(xprt)

Definition at line 186 of file svc.h.

◆ SVC_FREEARGS

#define SVC_FREEARGS (   xprt,
  xargs,
  argsp 
)     (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))

Definition at line 179 of file svc.h.

◆ svc_freeargs

#define svc_freeargs (   xprt,
  xargs,
  argsp 
)     (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))

Definition at line 181 of file svc.h.

◆ SVC_GETARGS

#define SVC_GETARGS (   xprt,
  xargs,
  argsp 
)     (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))

Definition at line 169 of file svc.h.

◆ svc_getargs

#define svc_getargs (   xprt,
  xargs,
  argsp 
)     (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))

Definition at line 171 of file svc.h.

◆ svc_getrpccaller

#define svc_getrpccaller (   x)    (&(x)->xp_rtaddr)

Definition at line 149 of file svc.h.

◆ SVC_RECV

#define SVC_RECV (   xprt,
  msg 
)     (*(xprt)->xp_ops->xp_recv)((xprt), (msg))

Definition at line 159 of file svc.h.

◆ svc_recv

#define svc_recv (   xprt,
  msg 
)     (*(xprt)->xp_ops->xp_recv)((xprt), (msg))

Definition at line 161 of file svc.h.

◆ SVC_REPLY

#define SVC_REPLY (   xprt,
  msg 
)     (*(xprt)->xp_ops->xp_reply) ((xprt), (msg))

Definition at line 174 of file svc.h.

◆ svc_reply

#define svc_reply (   xprt,
  msg 
)     (*(xprt)->xp_ops->xp_reply) ((xprt), (msg))

Definition at line 176 of file svc.h.

◆ SVC_STAT

#define SVC_STAT (   xprt)     (*(xprt)->xp_ops->xp_stat)(xprt)

Definition at line 164 of file svc.h.

◆ svc_stat

#define svc_stat (   xprt)     (*(xprt)->xp_ops->xp_stat)(xprt)

Definition at line 166 of file svc.h.

◆ SVCGET_CONNMAXREC

#define SVCGET_CONNMAXREC   3

Definition at line 72 of file svc.h.

◆ SVCGET_VERSQUIET

#define SVCGET_VERSQUIET   1

Definition at line 70 of file svc.h.

◆ SVCSET_CONNMAXREC

#define SVCSET_CONNMAXREC   4

Definition at line 73 of file svc.h.

◆ SVCSET_VERSQUIET

#define SVCSET_VERSQUIET   2

Definition at line 71 of file svc.h.

Typedef Documentation

◆ SVCXPRT

Enumeration Type Documentation

◆ xprt_stat

Enumerator
XPRT_DIED 
XPRT_MOREREQS 
XPRT_IDLE 

Definition at line 81 of file svc.h.

81 {
85};
@ XPRT_IDLE
Definition: svc.h:84
@ XPRT_DIED
Definition: svc.h:82
@ XPRT_MOREREQS
Definition: svc.h:83

Function Documentation

◆ __rpc_get_local_uid()

int __rpc_get_local_uid ( SVCXPRT _transp,
uid_t _uid 
)

Definition at line 783 of file svc_vc.c.

783 {
784 SOCKET sock;
785 int ret;
786 gid_t egid;
787 uid_t euid;
788 struct sockaddr *sa;
789
790 sock = transp->xp_fd;
791 sa = (struct sockaddr *)transp->xp_rtaddr.buf;
792 if (sa->sa_family == AF_UNIX) {
793 ret = getpeereid(sock, &euid, &egid);
794 if (ret == 0)
795 *uid = euid;
796 return (ret);
797 } else
798 return (-1);
799}
static struct sockaddr_in sa
Definition: adnsresfilter.c:69
long uid_t
Definition: various.h:8
UINT gid_t
Definition: types.h:89
int getpeereid(int s, uid_t *euid, gid_t *egid)
Definition: getpeereid.c:46
if(dx< 0)
Definition: linetemp.h:194
Definition: tcpcore.h:1455
int ret
#define AF_UNIX
Definition: winsock.h:345
UINT_PTR SOCKET
Definition: winsock.h:47

◆ rpc_reg()

int rpc_reg ( rpcprog_t  ,
rpcvers_t  ,
rpcproc_t  ,
char *)(char *,
xdrproc_t  ,
xdrproc_t  ,
char  
)

◆ rpctest_service()

__BEGIN_DECLS void rpctest_service ( void  )

◆ svc_create()

__BEGIN_DECLS int svc_create ( void(*)(struct svc_req *, SVCXPRT *)  ,
const  rpcprog_t,
const  rpcvers_t,
const char  
)

◆ svc_dg_create()

SVCXPRT * svc_dg_create ( const  SOCKET,
const  u_int,
const  u_int 
)

◆ svc_dg_enablecache()

int svc_dg_enablecache ( SVCXPRT transp,
const  u_int 
)

Definition at line 386 of file svc_dg.c.

389{
390 struct svc_dg_data *su = su_data(transp);
391 struct cl_cache *uc;
392
394 if (su->su_cache != NULL) {
395 // XXX (void) warnx(cache_enable_str, enable_err, " ");
397 return (0);
398 }
399 uc = ALLOC(struct cl_cache, 1);
400 if (uc == NULL) {
401 // XXX warnx(cache_enable_str, alloc_err, " ");
403 return (0);
404 }
405 uc->uc_size = size;
406 uc->uc_nextvictim = 0;
408 if (uc->uc_entries == NULL) {
409 // XXX warnx(cache_enable_str, alloc_err, "data");
410 FREE(uc, struct cl_cache, 1);
412 return (0);
413 }
415 uc->uc_fifo = ALLOC(cache_ptr, size);
416 if (uc->uc_fifo == NULL) {
417 // XXX warnx(cache_enable_str, alloc_err, "fifo");
419 FREE(uc, struct cl_cache, 1);
421 return (0);
422 }
424 su->su_cache = (char *)(void *)uc;
426 return (1);
427}
#define NULL
Definition: types.h:112
GLsizeiptr size
Definition: glext.h:5919
#define mutex_lock(m)
Definition: reentrant.h:128
#define mutex_unlock(m)
Definition: reentrant.h:129
cache_ptr * uc_fifo
Definition: svc_dg.c:360
u_int uc_size
Definition: svc_dg.c:358
u_int uc_nextvictim
Definition: svc_dg.c:361
cache_ptr * uc_entries
Definition: svc_dg.c:359
void * su_cache
Definition: svc_dg.h:47
#define FREE(addr, type, size)
Definition: svc_dg.c:327
mutex_t dupreq_lock
Definition: mt_misc.c:59
#define MEMZERO(addr, type, size)
Definition: svc_dg.c:324
#define su_data(xprt)
Definition: svc_dg.c:61
#define ALLOC(type, size)
Definition: svc_dg.c:321
#define SPARSENESS
Definition: svc_dg.c:319

◆ svc_exit()

void svc_exit ( void  )

Definition at line 84 of file svc_run.c.

85{
86 extern rwlock_t svc_fd_lock;
87
91}
rwlock_t svc_fd_lock
Definition: mt_misc.c:22
#define rwlock_wrlock(l)
Definition: reentrant.h:140
#define rwlock_unlock(l)
Definition: reentrant.h:142
fd_set svc_fdset
#define FD_ZERO(set)
Definition: winsock.h:96

◆ svc_fd_create()

SVCXPRT * svc_fd_create ( const  SOCKET,
const  u_int,
const  u_int 
)

Definition at line 204 of file svc_vc.c.

208{
209 struct sockaddr_storage ss;
210 socklen_t slen;
211 SVCXPRT *ret;
212
213 assert(fd != -1);
214
215 ret = makefd_xprt(fd, sendsize, recvsize);
216 if (ret == NULL)
217 return NULL;
218
219 slen = sizeof (struct sockaddr_storage);
220 if (getsockname(fd, (struct sockaddr *)(void *)&ss, &slen) == SOCKET_ERROR) {
221 // XXX warnx("svc_fd_create: could not retrieve local addr");
222 goto freedata;
223 }
224 if (!__rpc_set_netbuf(&ret->xp_ltaddr, &ss, sizeof(ss))) {
225 // XXX warnx("svc_fd_create: no mem for local addr");
226 goto freedata;
227 }
228
229 slen = sizeof (struct sockaddr_storage);
230 if (getpeername(fd, (struct sockaddr *)(void *)&ss, &slen) == SOCKET_ERROR) {
231 // XXX warnx("svc_fd_create: could not retrieve remote addr");
232 goto freedata;
233 }
234 if (!__rpc_set_netbuf(&ret->xp_rtaddr, &ss, sizeof(ss))) {
235 // XXX warnx("svc_fd_create: no mem for local addr");
236 goto freedata;
237 }
238
239 /* Set xp_raddr for compatibility */
241
242 return ret;
243
244freedata:
245 if (ret->xp_ltaddr.buf != NULL)
246 mem_free(ret->xp_ltaddr.buf, rep->xp_ltaddr.maxlen);
247
248 return NULL;
249}
#define mem_free(ptr, bsize)
Definition: types.h:124
#define assert(x)
Definition: debug.h:53
#define ss
Definition: i386-dis.c:441
int socklen_t
Definition: tcp.c:35
static int fd
Definition: io.c:51
INT WSAAPI getpeername(IN SOCKET s, OUT LPSOCKADDR name, IN OUT INT FAR *namelen)
Definition: sockctrl.c:167
INT WSAAPI getsockname(IN SOCKET s, OUT LPSOCKADDR name, IN OUT INT FAR *namelen)
Definition: sockctrl.c:213
struct netbuf * __rpc_set_netbuf(struct netbuf *, const void *, size_t)
Definition: rpc_generic.c:951
static SVCXPRT * makefd_xprt(SOCKET, u_int, u_int)
Definition: svc_vc.c:252
void __xprt_set_raddr(SVCXPRT *xprt, const struct sockaddr_storage *ss)
Definition: svc_vc.c:111
#define SOCKET_ERROR
Definition: winsock.h:333

Referenced by svc_tli_create().

◆ svc_getreq()

__END_DECLS __BEGIN_DECLS void svc_getreq ( int  rdfds)

Definition at line 604 of file svc.c.

606{
607 fd_set readfds;
608
609 FD_ZERO (&readfds);
610 //XXX Windows!! readfds.fds_bits[0] = rdfds;
611 svc_getreqset (&readfds);
612}
Definition: winsock.h:66
void svc_getreqset(fd_set *readfds)
Definition: svc.c:615

◆ svc_getreq_common()

void svc_getreq_common ( SOCKET  fd)

Definition at line 641 of file svc.c.

642{
643 SVCXPRT *xprt;
644 struct svc_req r;
645 struct rpc_msg msg;
646 int prog_found;
647 rpcvers_t low_vers;
648 rpcvers_t high_vers;
649 enum xprt_stat stat;
650 char cred_area[2 * MAX_AUTH_BYTES + RQCRED_SIZE];
651
652 msg.rm_call.cb_cred.oa_base = cred_area;
653 msg.rm_call.cb_verf.oa_base = &(cred_area[MAX_AUTH_BYTES]);
654 r.rq_clntcred = &(cred_area[2 * MAX_AUTH_BYTES]);
655
657 xprt = __svc_xports[fd];
659 if (xprt == NULL)
660 /* But do we control sock? */
661 return;
662 /* now receive msgs from xprtprt (support batch calls) */
663 do
664 {
665 if (SVC_RECV (xprt, &msg))
666 {
667
668 /* now find the exported program and call it */
669 struct svc_callout *s;
670 enum auth_stat why;
671
672 r.rq_xprt = xprt;
673 r.rq_prog = msg.rm_call.cb_prog;
674 r.rq_vers = msg.rm_call.cb_vers;
675 r.rq_proc = msg.rm_call.cb_proc;
676 r.rq_cred = msg.rm_call.cb_cred;
677 /* first authenticate the message */
678 if ((why = _authenticate (&r, &msg)) != AUTH_OK)
679 {
680 svcerr_auth (xprt, why);
681 goto call_done;
682 }
683 /* now match message with a registered service */
684 prog_found = FALSE;
685 low_vers = (rpcvers_t) - 1L;
686 high_vers = (rpcvers_t) 0L;
687 for (s = svc_head; s != NULL; s = s->sc_next)
688 {
689 if (s->sc_prog == r.rq_prog)
690 {
691 if (s->sc_vers == r.rq_vers)
692 {
693 (*s->sc_dispatch) (&r, xprt);
694 goto call_done;
695 } /* found correct version */
696 prog_found = TRUE;
697 if (s->sc_vers < low_vers)
698 low_vers = s->sc_vers;
699 if (s->sc_vers > high_vers)
700 high_vers = s->sc_vers;
701 } /* found correct program */
702 }
703 /*
704 * if we got here, the program or version
705 * is not served ...
706 */
707 if (prog_found)
708 svcerr_progvers (xprt, low_vers, high_vers);
709 else
710 svcerr_noprog (xprt);
711 /* Fall through to ... */
712 }
713 /*
714 * Check if the xprt has been disconnected in a
715 * recursive call in the service dispatch routine.
716 * If so, then break.
717 */
719
720 if (xprt != __svc_xports[fd])
721 {
723 break;
724 }
726 call_done:
727 if ((stat = SVC_STAT (xprt)) == XPRT_DIED)
728 {
729 SVC_DESTROY (xprt);
730 break;
731 }
732 else if ((xprt->xp_auth != NULL)
733#ifdef HAVE_LIBGSSAPI
734 && (xprt->xp_auth->svc_ah_ops != &svc_auth_gss_ops)
735#endif
736 ) {
737 xprt->xp_auth = NULL;
738 }
739 }
740 while (stat == XPRT_MOREREQS);
741}
#define stat
Definition: acwin.h:99
#define msg(x)
Definition: auth_time.c:54
auth_stat
Definition: auth.h:144
@ AUTH_OK
Definition: auth.h:145
#define MAX_AUTH_BYTES
Definition: auth.h:77
#define SVC_STAT(xprt)
Definition: svc.h:164
#define SVC_RECV(xprt, msg)
Definition: svc.h:159
xprt_stat
Definition: svc.h:81
#define SVC_DESTROY(xprt)
Definition: svc.h:184
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
u_int32_t rpcvers_t
Definition: types.h:105
GLdouble s
Definition: gl.h:2039
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define L(x)
Definition: ntvdm.h:50
#define rwlock_rdlock(l)
Definition: reentrant.h:139
SVCXPRT ** __svc_xports
SVCAUTH * xp_auth
Definition: svc.h:122
struct __svcauth::svc_auth_ops * svc_ah_ops
Definition: stat.h:55
Definition: svc.h:132
void svcerr_progvers(SVCXPRT *xprt, rpcvers_t low_vers, rpcvers_t high_vers)
Definition: svc.c:567
static struct svc_callout * svc_head
void svcerr_noprog(SVCXPRT *xprt)
Definition: svc.c:549
void svcerr_auth(SVCXPRT *xprt, enum auth_stat why)
Definition: svc.c:517
#define RQCRED_SIZE
Definition: svc.c:57
rwlock_t svc_fd_lock
Definition: mt_misc.c:22
enum auth_stat _authenticate(struct svc_req *rqst, struct rpc_msg *msg)
Definition: svc_auth.c:86
struct svc_auth_ops svc_auth_gss_ops
Definition: svc_auth_gss.c:60

Referenced by svc_getreq_poll(), and svc_getreqset().

◆ svc_getreq_poll()

void svc_getreq_poll ( struct pollfd pfdp,
int  pollretval 
)

Definition at line 745 of file svc.c.

748{
749 int i;
750 int fds_found;
751
752 for (i = fds_found = 0; fds_found < pollretval; i++)
753 {
754 struct pollfd *p = &pfdp[i];
755
756 if (p->revents)
757 {
758 /* fd has input waiting */
759 fds_found++;
760 /*
761 * We assume that this function is only called
762 * via someone _select()ing from svc_fdset or
763 * _poll()ing from svc_pollset[]. Thus it's safe
764 * to handle the POLLNVAL event by simply turning
765 * the corresponding bit off in svc_fdset. The
766 * svc_pollset[] array is derived from svc_fdset
767 * and so will also be updated eventually.
768 *
769 * XXX Should we do an xprt_unregister() instead?
770 */
771 if (p->revents & POLLNVAL)
772 {
774 FD_CLR (p->fd, &svc_fdset);
776 }
777 else
778 svc_getreq_common (p->fd);
779 }
780 }
781}
#define POLLNVAL
Definition: linux.h:1858
GLfloat GLfloat p
Definition: glext.h:8902
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
Definition: linux.h:1867
void svc_getreq_common(SOCKET fd)
Definition: svc.c:641
#define FD_CLR(fd, set)
Definition: winsock.h:74

◆ svc_getreqset()

void svc_getreqset ( fd_set readfds)

Definition at line 615 of file svc.c.

617{
618#ifndef _WIN32
619 int bit, fd;
620 fd_mask mask, *maskp;
621 int sock;
622
623 assert (readfds != NULL);
624
625 maskp = readfds->fds_bits;
626 for (sock = 0; sock < FD_SETSIZE; sock += NFDBITS)
627 {
628 for (mask = *maskp++; (bit = ffs (mask)) != 0; mask ^= (1 << (bit - 1)))
629 {
630 /* sock has input waiting */
631 fd = sock + bit - 1;
633 }
634 }
635#else
636 fprintf(stderr, "%s: Yikes!\n", __FUNCTION__);
637#endif
638}
#define __FUNCTION__
Definition: types.h:116
GLenum GLint GLuint mask
Definition: glext.h:6028
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
#define ffs
Definition: port.h:359
#define FD_SETSIZE
Definition: winsock.h:50

Referenced by svc_getreq(), and svc_run().

◆ svc_raw_create()

SVCXPRT * svc_raw_create ( void  )

Definition at line 76 of file svc_raw.c.

77{
78 struct svc_raw_private *srp;
79/* VARIABLES PROTECTED BY svcraw_lock: svc_raw_private, srp */
80
82 srp = svc_raw_private;
83 if (srp == NULL) {
84 srp = (struct svc_raw_private *)calloc(1, sizeof (*srp));
85 if (srp == NULL) {
87 return (NULL);
88 }
89 if (__rpc_rawcombuf == NULL)
90 __rpc_rawcombuf = calloc(UDPMSGSIZE, sizeof (char));
91 srp->raw_buf = __rpc_rawcombuf; /* Share it with the client */
92 svc_raw_private = srp;
93 }
94 srp->server.xp_fd = FD_SETSIZE;
95 srp->server.xp_port = 0;
96 srp->server.xp_p3 = NULL;
97 svc_raw_ops(&srp->server);
98 srp->server.xp_verf.oa_base = srp->verf_body;
100 xprt_register(&srp->server);
102 return (&srp->server);
103}
#define calloc
Definition: rosglue.h:14
void * xp_p3
Definition: svc.h:125
u_short xp_port
Definition: svc.h:92
SOCKET xp_fd
Definition: svc.h:91
struct opaque_auth xp_verf
Definition: svc.h:121
char verf_body[MAX_AUTH_BYTES]
Definition: svc_raw.c:59
char * raw_buf
Definition: svc_raw.c:56
SVCXPRT server
Definition: svc_raw.c:57
XDR xdr_stream
Definition: svc_raw.c:58
void xprt_register(SVCXPRT *xprt)
Definition: svc.c:97
char * __rpc_rawcombuf
Definition: svc_raw.c:73
static void svc_raw_ops(SVCXPRT *)
Definition: svc_raw.c:226
mutex_t svcraw_lock
Definition: mt_misc.c:83
#define UDPMSGSIZE
Definition: svc_raw.c:49
@ XDR_DECODE
Definition: xdr.h:86
void xdrmem_create(XDR *xdrs, char *addr, u_int size, enum xdr_op op)
Definition: xdr_mem.c:94

◆ svc_reg()

__BEGIN_DECLS bool_t svc_reg ( SVCXPRT ,
const  rpcprog_t,
const  rpcvers_t,
void(*)(struct svc_req *, SVCXPRT *)  ,
const struct netconfig  
)

◆ svc_run()

void svc_run ( void  )

Definition at line 48 of file svc_run.c.

49{
50 fd_set readfds, cleanfds;
51 struct timeval timeout;
52 extern rwlock_t svc_fd_lock;
53
54
55 for (;;) {
57 readfds = svc_fdset;
58 cleanfds = svc_fdset;
60 timeout.tv_sec = 30;
61 timeout.tv_usec = 0;
62 switch (select(svc_maxfd+1, &readfds, NULL, NULL, &timeout)) {
63 case SOCKET_ERROR:
64 FD_ZERO(&readfds);
65 if (WSAGetLastError() == WSAEINTR) {
66 continue;
67 }
68 // XXX warn("svc_run: - select failed");
69 return;
70 case 0:
71 __svc_clean_idle(&cleanfds, 30, FALSE);
72 continue;
73 default:
74 svc_getreqset(&readfds);
75 }
76 }
77}
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
int svc_maxfd
bool_t __svc_clean_idle(fd_set *, int, bool_t)
Definition: svc_vc.c:820
Definition: dhcpd.h:245
#define WSAEINTR
Definition: winerror.h:1942
int PASCAL FAR WSAGetLastError(void)
Definition: dllmain.c:112

◆ svc_sendreply()

__END_DECLS __BEGIN_DECLS bool_t svc_sendreply ( SVCXPRT xprt,
xdrproc_t  xdr_results,
void xdr_location 
)

Definition at line 399 of file svc.c.

403{
404 struct rpc_msg rply;
405
406 assert (xprt != NULL);
407
408 rply.rm_direction = REPLY;
409 rply.rm_reply.rp_stat = MSG_ACCEPTED;
410 rply.acpted_rply.ar_verf = xprt->xp_verf;
411 rply.acpted_rply.ar_stat = SUCCESS;
412 rply.acpted_rply.ar_results.where = xdr_location;
413 rply.acpted_rply.ar_results.proc = xdr_results;
414 return (SVC_REPLY (xprt, &rply));
415}
#define SVC_REPLY(xprt, msg)
Definition: svc.h:174
#define REPLY
Definition: port.c:108
#define SUCCESS
Definition: regproc.h:26
@ MSG_ACCEPTED
Definition: rpc_msg.h:83

Referenced by _svcauth_gss(), and universal().

◆ svc_tli_create()

SVCXPRT * svc_tli_create ( const  SOCKET,
const struct netconfig nconf,
const struct t_bind bindaddr,
const  u_int,
const  u_int 
)

Definition at line 182 of file svc_generic.c.

188{
189 SVCXPRT *xprt = NULL; /* service handle */
190 bool_t madefd = FALSE; /* whether fd opened here */
191 struct __rpc_sockinfo si;
192 struct sockaddr_storage ss;
193 socklen_t slen;
194
195 if (fd == RPC_ANYFD) {
196 if (nconf == NULL) {
197 // XXX warnx("svc_tli_create: invalid netconfig");
198 return (NULL);
199 }
200 fd = __rpc_nconf2fd(nconf);
201 if (fd == -1) {
202 // XXX warnx(
203// "svc_tli_create: could not open connection for %s",
204// nconf->nc_netid);
205 return (NULL);
206 }
207 __rpc_nconf2sockinfo(nconf, &si);
208 madefd = TRUE;
209 } else {
210 /*
211 * It is an open descriptor. Get the transport info.
212 */
213 if (!__rpc_fd2sockinfo(fd, &si)) {
214 // XXX warnx(
215// "svc_tli_create: could not get transport information");
216 return (NULL);
217 }
218 }
219
220 /*
221 * If the fd is unbound, try to bind it.
222 */
223 if (madefd || !__rpc_sockisbound(fd)) {
224 if (bindaddr == NULL) {
225 if (bindresvport(fd, NULL) < 0) {
226 memset(&ss, 0, sizeof ss);
227 ss.ss_family = si.si_af;
228 if (bind(fd, (struct sockaddr *)(void *)&ss,
229 (socklen_t)si.si_alen) == SOCKET_ERROR) {
230 // XXX warnx(
231// "svc_tli_create: could not bind to anonymous port");
232 goto freedata;
233 }
234 }
236 } else {
237 if (bind(fd,
238 (struct sockaddr *)bindaddr->addr.buf,
239 (socklen_t)si.si_alen) == SOCKET_ERROR) {
240 // XXX warnx(
241// "svc_tli_create: could not bind to requested address");
242 goto freedata;
243 }
244 listen(fd, (int)bindaddr->qlen);
245 }
246
247 }
248 /*
249 * call transport specific function.
250 */
251 switch (si.si_socktype) {
252 case SOCK_STREAM:
253 slen = sizeof ss;
254 if (getpeername(fd, (struct sockaddr *)(void *)&ss, &slen)
255 == 0) {
256 /* accepted socket */
257 xprt = svc_fd_create(fd, sendsz, recvsz);
258 } else
259 xprt = svc_vc_create(fd, sendsz, recvsz);
260 if (!nconf || !xprt)
261 break;
262#if 0
263 /* XXX fvdl */
264 if (strcmp(nconf->nc_protofmly, "inet") == 0 ||
265 strcmp(nconf->nc_protofmly, "inet6") == 0)
266 (void) __svc_vc_setflag(xprt, TRUE);
267#endif
268 break;
269 case SOCK_DGRAM:
270 xprt = svc_dg_create(fd, sendsz, recvsz);
271 break;
272 default:
273 // XXX warnx("svc_tli_create: bad service type");
274 goto freedata;
275 }
276
277 if (xprt == NULL)
278 /*
279 * The error messages here are spitted out by the lower layers:
280 * svc_vc_create(), svc_fd_create() and svc_dg_create().
281 */
282 goto freedata;
283
284 /* Fill in type of service */
285 xprt->xp_type = __rpc_socktype2seman(si.si_socktype);
286
287 if (nconf) {
288 xprt->xp_netid = strdup(nconf->nc_netid);
289 xprt->xp_tp = strdup(nconf->nc_device);
290 }
291 return (xprt);
292
293freedata:
294 if (madefd)
296 if (xprt) {
297 if (!madefd) /* so that svc_destroy doesnt close fd */
298 xprt->xp_fd = RPC_ANYFD;
299 SVC_DESTROY(xprt);
300 }
301 return (NULL);
302}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
int bindresvport(SOCKET sd, struct sockaddr_in *sin)
Definition: bindresvport.c:53
#define RPC_ANYFD
Definition: svc.h:328
int32_t bool_t
Definition: types.h:101
#define SOCK_STREAM
Definition: tcpip.h:118
#define closesocket
Definition: ncftp.h:477
int __rpc_fd2sockinfo(SOCKET fd, struct __rpc_sockinfo *sip)
Definition: rpc_generic.c:481
int __rpc_nconf2sockinfo(const struct netconfig *nconf, struct __rpc_sockinfo *sip)
Definition: rpc_generic.c:540
SOCKET __rpc_nconf2fd(const struct netconfig *nconf)
Definition: rpc_generic.c:562
_Check_return_ _CRTIMP char *__cdecl strdup(_In_opt_z_ const char *_Src)
#define memset(x, y, z)
Definition: compat.h:39
INT WSAAPI listen(IN SOCKET s, IN INT backlog)
Definition: sockctrl.c:123
INT WSAAPI bind(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: socklife.c:36
int __rpc_sockisbound(SOCKET)
Definition: rpc_generic.c:909
int __rpc_socktype2seman(int)
Definition: rpc_generic.c:859
char * xp_netid
Definition: svc.h:118
char * xp_tp
Definition: svc.h:117
int xp_type
Definition: svc.h:126
char * nc_netid
Definition: netconfig.h:16
char * nc_protofmly
Definition: netconfig.h:19
char * nc_device
Definition: netconfig.h:21
unsigned int qlen
Definition: types.h:157
struct netbuf addr
Definition: types.h:156
SVCXPRT * svc_dg_create(int fd, u_int sendsize, u_int recvsize)
Definition: svc_dg.c:95
int __svc_vc_setflag(SVCXPRT *, int)
SVCXPRT * svc_fd_create(SOCKET fd, u_int sendsize, u_int recvsize)
Definition: svc_vc.c:204
SVCXPRT * svc_vc_create(int fd, u_int sendsize, u_int recvsize)
Definition: svc_vc.c:146
#define SOMAXCONN
Definition: winsock.h:399
#define SOCK_DGRAM
Definition: winsock.h:336

Referenced by rpc_reg(), and svc_tp_create().

◆ svc_tp_create()

SVCXPRT * svc_tp_create ( void(*)(struct svc_req *, SVCXPRT *)  ,
const  rpcprog_t,
const  rpcvers_t,
const struct netconfig  
)

◆ svc_unreg()

__END_DECLS __BEGIN_DECLS void svc_unreg ( const  rpcprog_t,
const  rpcvers_t 
)

◆ svc_vc_create()

SVCXPRT * svc_vc_create ( const  SOCKET,
const  u_int,
const  u_int 
)

◆ svcerr_auth()

void svcerr_auth ( SVCXPRT xprt,
enum  auth_stat 
)

Definition at line 517 of file svc.c.

520{
521 struct rpc_msg rply;
522
523 assert (xprt != NULL);
524
525 rply.rm_direction = REPLY;
526 rply.rm_reply.rp_stat = MSG_DENIED;
527 rply.rjcted_rply.rj_stat = AUTH_ERROR;
528 rply.rjcted_rply.rj_why = why;
529 SVC_REPLY (xprt, &rply);
530}
@ MSG_DENIED
Definition: rpc_msg.h:84
@ AUTH_ERROR
Definition: rpc_msg.h:98

Referenced by svc_getreq_common(), and svcerr_weakauth().

◆ svcerr_decode()

void svcerr_decode ( SVCXPRT xprt)

Definition at line 439 of file svc.c.

441{
442 struct rpc_msg rply;
443
444 assert (xprt != NULL);
445
446 rply.rm_direction = REPLY;
447 rply.rm_reply.rp_stat = MSG_ACCEPTED;
448 rply.acpted_rply.ar_verf = xprt->xp_verf;
449 rply.acpted_rply.ar_stat = GARBAGE_ARGS;
450 SVC_REPLY (xprt, &rply);
451}
@ GARBAGE_ARGS
Definition: rpc_msg.h:92

Referenced by universal().

◆ svcerr_noproc()

void svcerr_noproc ( SVCXPRT xprt)

Definition at line 421 of file svc.c.

423{
424 struct rpc_msg rply;
425
426 assert (xprt != NULL);
427
428 rply.rm_direction = REPLY;
429 rply.rm_reply.rp_stat = MSG_ACCEPTED;
430 rply.acpted_rply.ar_verf = xprt->xp_verf;
431 rply.acpted_rply.ar_stat = PROC_UNAVAIL;
432 SVC_REPLY (xprt, &rply);
433}
@ PROC_UNAVAIL
Definition: rpc_msg.h:91

◆ svcerr_noprog()

void svcerr_noprog ( SVCXPRT xprt)

Definition at line 549 of file svc.c.

551{
552 struct rpc_msg rply;
553
554 assert (xprt != NULL);
555
556 rply.rm_direction = REPLY;
557 rply.rm_reply.rp_stat = MSG_ACCEPTED;
558 rply.acpted_rply.ar_verf = xprt->xp_verf;
559 rply.acpted_rply.ar_stat = PROG_UNAVAIL;
560 SVC_REPLY (xprt, &rply);
561}
@ PROG_UNAVAIL
Definition: rpc_msg.h:89

Referenced by svc_getreq_common().

◆ svcerr_progvers()

void svcerr_progvers ( SVCXPRT xprt,
rpcvers_t  low_vers,
rpcvers_t  high_vers 
)

Definition at line 567 of file svc.c.

571{
572 struct rpc_msg rply;
573
574 assert (xprt != NULL);
575
576 rply.rm_direction = REPLY;
577 rply.rm_reply.rp_stat = MSG_ACCEPTED;
578 rply.acpted_rply.ar_verf = xprt->xp_verf;
579 rply.acpted_rply.ar_stat = PROG_MISMATCH;
580 rply.acpted_rply.ar_vers.low = (u_int32_t) low_vers;
581 rply.acpted_rply.ar_vers.high = (u_int32_t) high_vers;
582 SVC_REPLY (xprt, &rply);
583}
unsigned int u_int32_t
Definition: rosdhcp.h:35
@ PROG_MISMATCH
Definition: rpc_msg.h:90

Referenced by svc_getreq_common().

◆ svcerr_systemerr()

void svcerr_systemerr ( SVCXPRT xprt)

Definition at line 457 of file svc.c.

459{
460 struct rpc_msg rply;
461
462 assert (xprt != NULL);
463
464 rply.rm_direction = REPLY;
465 rply.rm_reply.rp_stat = MSG_ACCEPTED;
466 rply.acpted_rply.ar_verf = xprt->xp_verf;
467 rply.acpted_rply.ar_stat = SYSTEM_ERR;
468 SVC_REPLY (xprt, &rply);
469}
@ SYSTEM_ERR
Definition: rpc_msg.h:93

◆ svcerr_weakauth()

void svcerr_weakauth ( SVCXPRT xprt)

Definition at line 536 of file svc.c.

538{
539
540 assert (xprt != NULL);
541
543}
@ AUTH_TOOWEAK
Definition: auth.h:153

◆ svcunix_create()

SVCXPRT * svcunix_create ( int  ,
u_int  ,
u_int  ,
char  
)

◆ svcunixfd_create()

SVCXPRT * svcunixfd_create ( int  ,
u_int  ,
u_int   
)

◆ xprt_register()

__END_DECLS __BEGIN_DECLS void xprt_register ( SVCXPRT xprt)

Definition at line 97 of file svc.c.

99{
100 SOCKET sock;
101
102 assert (xprt != NULL);
103
104 sock = xprt->xp_fd;
105
107 if (__svc_xports == NULL) {
108 __svc_xports = (SVCXPRT **) mem_alloc (FD_SETSIZE * sizeof (SVCXPRT *));
109 if (__svc_xports == NULL) {
110 // XXX Give an error indication?
111 return;
112 }
113 memset (__svc_xports, 0, FD_SETSIZE * sizeof (SVCXPRT *));
114 }
115#ifndef _WIN32
116 if (sock < FD_SETSIZE) {
117 __svc_xports[sock] = xprt;
120 }
121#else
122 fprintf(stderr, "%s: Yikes! Figure out __svc_xports[] issue!!\n", __FUNCTION__);
123#endif
125}
#define mem_alloc(bsize)
Definition: types.h:123
#define max(a, b)
Definition: svc.c:63
#define FD_SET(fd, set)
Definition: winsock.h:89

Referenced by makefd_xprt(), svc_dg_create(), svc_raw_create(), and svc_vc_create().

◆ xprt_unregister()

__END_DECLS __BEGIN_DECLS void xprt_unregister ( SVCXPRT xprt)

Definition at line 128 of file svc.c.

129{
131}
static void __xprt_do_unregister(SVCXPRT *xprt, bool_t dolock)
Definition: svc.c:143

Referenced by svc_dg_destroy(), and svc_vc_destroy().

Variable Documentation

◆ svc_fds

int svc_fds
extern

◆ svc_maxfd

__END_DECLS int svc_maxfd
extern

Definition at line 39 of file rpc_commondata.c.

Referenced by __svc_clean_idle(), __xprt_do_unregister(), svc_run(), and xprt_register().