1 /* $NetBSD: rpcb_svc.c,v 1.1 2000/06/02 23:15:41 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 * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc.
35 /* #ident "@(#)rpcb_svc.c 1.16 93/07/05 SMI" */
39 * The server procedure for the version 3 rpcbind (TLI).
41 * It maintains a separate list of all the registered services with the
42 * version 3 of rpcbind.
44 #include <sys/types.h>
46 #include <rpc/rpcb_prot.h>
47 #include <netconfig.h>
55 static void *rpcbproc_getaddr_3_local(void *, struct svc_req
*, SVCXPRT
*,
57 static void *rpcbproc_dump_3_local(void *, struct svc_req
*, SVCXPRT
*,
61 * Called by svc_getreqset. There is a separate server handle for
62 * every transport that it waits on.
65 rpcb_service_3(struct svc_req
*rqstp
, SVCXPRT
*transp
)
68 RPCB rpcbproc_set_3_arg
;
69 RPCB rpcbproc_unset_3_arg
;
70 RPCB rpcbproc_getaddr_3_local_arg
;
71 struct rpcb_rmtcallargs rpcbproc_callit_3_arg
;
72 char *rpcbproc_uaddr2taddr_3_arg
;
73 struct netbuf rpcbproc_taddr2uaddr_3_arg
;
76 xdrproc_t xdr_argument
, xdr_result
;
77 void *(*local
)(void *, struct svc_req
*, SVCXPRT
*, rpcvers_t
);
79 rpcbs_procinfo(RPCBVERS_3_STAT
, rqstp
->rq_proc
);
81 switch (rqstp
->rq_proc
) {
88 fprintf(stderr
, "RPCBPROC_NULL\n");
90 /* This call just logs, no actual checks */
91 check_access(transp
, rqstp
->rq_proc
, NULL
, RPCBVERS
);
92 (void) svc_sendreply(transp
, (xdrproc_t
)xdr_void
, (char *)NULL
);
96 xdr_argument
= (xdrproc_t
)xdr_rpcb
;
97 xdr_result
= (xdrproc_t
)xdr_bool
;
98 local
= rpcbproc_set_com
;
102 xdr_argument
= (xdrproc_t
)xdr_rpcb
;
103 xdr_result
= (xdrproc_t
)xdr_bool
;
104 local
= rpcbproc_unset_com
;
107 case RPCBPROC_GETADDR
:
108 xdr_argument
= (xdrproc_t
)xdr_rpcb
;
109 xdr_result
= (xdrproc_t
)xdr_wrapstring
;
110 local
= rpcbproc_getaddr_3_local
;
116 fprintf(stderr
, "RPCBPROC_DUMP\n");
118 xdr_argument
= (xdrproc_t
)xdr_void
;
119 xdr_result
= (xdrproc_t
)xdr_rpcblist_ptr
;
120 local
= rpcbproc_dump_3_local
;
123 case RPCBPROC_CALLIT
:
124 rpcbproc_callit_com(rqstp
, transp
, rqstp
->rq_proc
, RPCBVERS
);
127 case RPCBPROC_GETTIME
:
130 fprintf(stderr
, "RPCBPROC_GETTIME\n");
132 xdr_argument
= (xdrproc_t
)xdr_void
;
133 xdr_result
= (xdrproc_t
)xdr_u_long
;
134 local
= rpcbproc_gettime_com
;
137 case RPCBPROC_UADDR2TADDR
:
140 fprintf(stderr
, "RPCBPROC_UADDR2TADDR\n");
142 xdr_argument
= (xdrproc_t
)xdr_wrapstring
;
143 xdr_result
= (xdrproc_t
)xdr_netbuf
;
144 local
= rpcbproc_uaddr2taddr_com
;
147 case RPCBPROC_TADDR2UADDR
:
150 fprintf(stderr
, "RPCBPROC_TADDR2UADDR\n");
152 xdr_argument
= (xdrproc_t
)xdr_netbuf
;
153 xdr_result
= (xdrproc_t
)xdr_wrapstring
;
154 local
= rpcbproc_taddr2uaddr_com
;
158 svcerr_noproc(transp
);
161 (void) memset((char *)&argument
, 0, sizeof (argument
));
162 if (!svc_getargs(transp
, (xdrproc_t
) xdr_argument
,
163 (char *) &argument
)) {
164 svcerr_decode(transp
);
166 (void) fprintf(stderr
, "rpcbind: could not decode\n");
169 if (!check_access(transp
, rqstp
->rq_proc
, &argument
, RPCBVERS
)) {
170 svcerr_weakauth(transp
);
173 result
= (*local
)(&argument
, rqstp
, transp
, RPCBVERS
);
174 if (result
!= NULL
&& !svc_sendreply(transp
, (xdrproc_t
)xdr_result
,
176 svcerr_systemerr(transp
);
178 (void) fprintf(stderr
, "rpcbind: svc_sendreply\n");
185 if (!svc_freeargs(transp
, (xdrproc_t
)xdr_argument
, (char *)
188 (void) fprintf(stderr
, "unable to free arguments\n");
197 * Lookup the mapping for a program, version and return its
198 * address. Assuming that the caller wants the address of the
199 * server running on the transport on which the request came.
201 * We also try to resolve the universal address in terms of
202 * address of the caller.
206 rpcbproc_getaddr_3_local(void *arg
, struct svc_req
*rqstp
, SVCXPRT
*transp
,
209 RPCB
*regp
= (RPCB
*)arg
;
214 uaddr
= taddr2uaddr(rpcbind_get_conf(transp
->xp_netid
),
215 svc_getrpccaller(transp
));
216 fprintf(stderr
, "RPCB_GETADDR req for (%lu, %lu, %s) from %s: ",
217 (unsigned long)regp
->r_prog
, (unsigned long)regp
->r_vers
,
218 regp
->r_netid
, uaddr
);
222 return (rpcbproc_getaddr_com(regp
, rqstp
, transp
, RPCBVERS
,
228 rpcbproc_dump_3_local(void *arg
, struct svc_req
*rqstp
, SVCXPRT
*transp
,
231 return ((void *)&list_rbl
);