2 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
3 * unrestricted use provided that this legend is included on all tape
4 * media and as a part of the software program in whole or part. Users
5 * may copy or modify Sun RPC without charge, but are not authorized
6 * to license or distribute it to anyone else except as part of a product or
7 * program developed by the user.
9 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
10 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
11 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
13 * Sun RPC is provided with no support and without any obligation on the
14 * part of Sun Microsystems, Inc. to assist in its use, correction,
15 * modification or enhancement.
17 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
18 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
19 * OR ANY PART THEREOF.
21 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
22 * or profits or other special, indirect and consequential damages, even if
23 * Sun has been advised of the possibility of such damages.
25 * Sun Microsystems, Inc.
27 * Mountain View, California 94043
29 * @(#)rpcb_svc.c 1.16 93/07/05 SMI"
30 * $NetBSD: rpcb_svc.c,v 1.1 2000/06/02 23:15:41 fvdl Exp $
31 * $FreeBSD: src/usr.sbin/rpcbind/rpcb_svc.c,v 1.3 2007/11/07 10:53:39 kevlo Exp $
35 * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc.
40 * The server procedure for the version 3 rpcbind (TLI).
42 * It maintains a separate list of all the registered services with the
43 * version 3 of rpcbind.
45 #include <sys/types.h>
47 #include <rpc/rpcb_prot.h>
48 #include <netconfig.h>
56 static void *rpcbproc_getaddr_3_local(void *, struct svc_req
*, SVCXPRT
*,
58 static void *rpcbproc_dump_3_local(void *, struct svc_req
*, SVCXPRT
*,
62 * Called by svc_getreqset. There is a separate server handle for
63 * every transport that it waits on.
66 rpcb_service_3(struct svc_req
*rqstp
, SVCXPRT
*transp
)
69 RPCB rpcbproc_set_3_arg
;
70 RPCB rpcbproc_unset_3_arg
;
71 RPCB rpcbproc_getaddr_3_local_arg
;
72 struct rpcb_rmtcallargs rpcbproc_callit_3_arg
;
73 char *rpcbproc_uaddr2taddr_3_arg
;
74 struct netbuf rpcbproc_taddr2uaddr_3_arg
;
77 xdrproc_t xdr_argument
, xdr_result
;
78 void *(*local
)(void *, struct svc_req
*, SVCXPRT
*, rpcvers_t
);
80 rpcbs_procinfo(RPCBVERS_3_STAT
, rqstp
->rq_proc
);
82 switch (rqstp
->rq_proc
) {
89 fprintf(stderr
, "RPCBPROC_NULL\n");
91 /* This call just logs, no actual checks */
92 check_access(transp
, rqstp
->rq_proc
, NULL
, RPCBVERS
);
93 svc_sendreply(transp
, (xdrproc_t
)xdr_void
, NULL
);
97 xdr_argument
= (xdrproc_t
)xdr_rpcb
;
98 xdr_result
= (xdrproc_t
)xdr_bool
;
99 local
= rpcbproc_set_com
;
103 xdr_argument
= (xdrproc_t
)xdr_rpcb
;
104 xdr_result
= (xdrproc_t
)xdr_bool
;
105 local
= rpcbproc_unset_com
;
108 case RPCBPROC_GETADDR
:
109 xdr_argument
= (xdrproc_t
)xdr_rpcb
;
110 xdr_result
= (xdrproc_t
)xdr_wrapstring
;
111 local
= rpcbproc_getaddr_3_local
;
117 fprintf(stderr
, "RPCBPROC_DUMP\n");
119 xdr_argument
= (xdrproc_t
)xdr_void
;
120 xdr_result
= (xdrproc_t
)xdr_rpcblist_ptr
;
121 local
= rpcbproc_dump_3_local
;
124 case RPCBPROC_CALLIT
:
125 rpcbproc_callit_com(rqstp
, transp
, rqstp
->rq_proc
, RPCBVERS
);
128 case RPCBPROC_GETTIME
:
131 fprintf(stderr
, "RPCBPROC_GETTIME\n");
133 xdr_argument
= (xdrproc_t
)xdr_void
;
134 xdr_result
= (xdrproc_t
)xdr_u_long
;
135 local
= rpcbproc_gettime_com
;
138 case RPCBPROC_UADDR2TADDR
:
141 fprintf(stderr
, "RPCBPROC_UADDR2TADDR\n");
143 xdr_argument
= (xdrproc_t
)xdr_wrapstring
;
144 xdr_result
= (xdrproc_t
)xdr_netbuf
;
145 local
= rpcbproc_uaddr2taddr_com
;
148 case RPCBPROC_TADDR2UADDR
:
151 fprintf(stderr
, "RPCBPROC_TADDR2UADDR\n");
153 xdr_argument
= (xdrproc_t
)xdr_netbuf
;
154 xdr_result
= (xdrproc_t
)xdr_wrapstring
;
155 local
= rpcbproc_taddr2uaddr_com
;
159 svcerr_noproc(transp
);
162 memset((char *)&argument
, 0, sizeof (argument
));
163 if (!svc_getargs(transp
, (xdrproc_t
) xdr_argument
,
164 (char *) &argument
)) {
165 svcerr_decode(transp
);
167 fprintf(stderr
, "rpcbind: could not decode\n");
170 if (!check_access(transp
, rqstp
->rq_proc
, &argument
, RPCBVERS
)) {
171 svcerr_weakauth(transp
);
174 result
= (*local
)(&argument
, rqstp
, transp
, RPCBVERS
);
175 if (result
!= NULL
&& !svc_sendreply(transp
, (xdrproc_t
)xdr_result
,
177 svcerr_systemerr(transp
);
179 fprintf(stderr
, "rpcbind: svc_sendreply\n");
186 if (!svc_freeargs(transp
, (xdrproc_t
)xdr_argument
, (char *)
189 fprintf(stderr
, "unable to free arguments\n");
198 * Lookup the mapping for a program, version and return its
199 * address. Assuming that the caller wants the address of the
200 * server running on the transport on which the request came.
202 * We also try to resolve the universal address in terms of
203 * address of the caller.
207 rpcbproc_getaddr_3_local(void *arg
, struct svc_req
*rqstp __unused
,
208 SVCXPRT
*transp __unused
, rpcvers_t versnum __unused
)
210 RPCB
*regp
= (RPCB
*)arg
;
215 uaddr
= taddr2uaddr(rpcbind_get_conf(transp
->xp_netid
),
216 svc_getrpccaller(transp
));
217 fprintf(stderr
, "RPCB_GETADDR req for (%lu, %lu, %s) from %s: ",
218 (unsigned long)regp
->r_prog
, (unsigned long)regp
->r_vers
,
219 regp
->r_netid
, uaddr
);
223 return (rpcbproc_getaddr_com(regp
, rqstp
, transp
, RPCBVERS
,
229 rpcbproc_dump_3_local(void *arg __unused
, struct svc_req
*rqstp __unused
,
230 SVCXPRT
*transp __unused
, rpcvers_t versnum __unused
)
232 return ((void *)&list_rbl
);