1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate * CDDL HEADER START
3*0Sstevel@tonic-gate *
4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
7*0Sstevel@tonic-gate * with the License.
8*0Sstevel@tonic-gate *
9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate * and limitations under the License.
13*0Sstevel@tonic-gate *
14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate *
20*0Sstevel@tonic-gate * CDDL HEADER END
21*0Sstevel@tonic-gate */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24*0Sstevel@tonic-gate * Use is subject to license terms.
25*0Sstevel@tonic-gate */
26*0Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
27*0Sstevel@tonic-gate /* All Rights Reserved */
28*0Sstevel@tonic-gate /*
29*0Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988
30*0Sstevel@tonic-gate * The Regents of the University of California
31*0Sstevel@tonic-gate * All Rights Reserved
32*0Sstevel@tonic-gate *
33*0Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from
34*0Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its
35*0Sstevel@tonic-gate * contributors.
36*0Sstevel@tonic-gate */
37*0Sstevel@tonic-gate
38*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
39*0Sstevel@tonic-gate
40*0Sstevel@tonic-gate /*
41*0Sstevel@tonic-gate * pmap_svc.c
42*0Sstevel@tonic-gate * The server procedure for the version 2 portmaper.
43*0Sstevel@tonic-gate * All the portmapper related interface from the portmap side.
44*0Sstevel@tonic-gate */
45*0Sstevel@tonic-gate
46*0Sstevel@tonic-gate #ifdef PORTMAP
47*0Sstevel@tonic-gate #include <stdio.h>
48*0Sstevel@tonic-gate #include <alloca.h>
49*0Sstevel@tonic-gate #include <ucred.h>
50*0Sstevel@tonic-gate #include <rpc/rpc.h>
51*0Sstevel@tonic-gate #include <rpc/pmap_prot.h>
52*0Sstevel@tonic-gate #include <rpc/rpcb_prot.h>
53*0Sstevel@tonic-gate #include "rpcbind.h"
54*0Sstevel@tonic-gate
55*0Sstevel@tonic-gate #ifdef RPCBIND_DEBUG
56*0Sstevel@tonic-gate #include <netdir.h>
57*0Sstevel@tonic-gate #endif
58*0Sstevel@tonic-gate
59*0Sstevel@tonic-gate static PMAPLIST *find_service_pmap();
60*0Sstevel@tonic-gate static bool_t pmapproc_change();
61*0Sstevel@tonic-gate static bool_t pmapproc_getport();
62*0Sstevel@tonic-gate static bool_t pmapproc_dump();
63*0Sstevel@tonic-gate
64*0Sstevel@tonic-gate /*
65*0Sstevel@tonic-gate * Called for all the version 2 inquiries.
66*0Sstevel@tonic-gate */
67*0Sstevel@tonic-gate void
pmap_service(rqstp,xprt)68*0Sstevel@tonic-gate pmap_service(rqstp, xprt)
69*0Sstevel@tonic-gate register struct svc_req *rqstp;
70*0Sstevel@tonic-gate register SVCXPRT *xprt;
71*0Sstevel@tonic-gate {
72*0Sstevel@tonic-gate rpcbs_procinfo(RPCBVERS_2_STAT, rqstp->rq_proc);
73*0Sstevel@tonic-gate switch (rqstp->rq_proc) {
74*0Sstevel@tonic-gate case PMAPPROC_NULL:
75*0Sstevel@tonic-gate /*
76*0Sstevel@tonic-gate * Null proc call
77*0Sstevel@tonic-gate */
78*0Sstevel@tonic-gate #ifdef RPCBIND_DEBUG
79*0Sstevel@tonic-gate fprintf(stderr, "PMAPPROC_NULL\n");
80*0Sstevel@tonic-gate #endif
81*0Sstevel@tonic-gate PMAP_CHECK(xprt, rqstp->rq_proc);
82*0Sstevel@tonic-gate
83*0Sstevel@tonic-gate if ((!svc_sendreply(xprt, (xdrproc_t)xdr_void, NULL)) &&
84*0Sstevel@tonic-gate debugging) {
85*0Sstevel@tonic-gate if (doabort) {
86*0Sstevel@tonic-gate rpcbind_abort();
87*0Sstevel@tonic-gate }
88*0Sstevel@tonic-gate }
89*0Sstevel@tonic-gate break;
90*0Sstevel@tonic-gate
91*0Sstevel@tonic-gate case PMAPPROC_SET:
92*0Sstevel@tonic-gate /*
93*0Sstevel@tonic-gate * Set a program, version to port mapping
94*0Sstevel@tonic-gate */
95*0Sstevel@tonic-gate pmapproc_change(rqstp, xprt, rqstp->rq_proc);
96*0Sstevel@tonic-gate break;
97*0Sstevel@tonic-gate
98*0Sstevel@tonic-gate case PMAPPROC_UNSET:
99*0Sstevel@tonic-gate /*
100*0Sstevel@tonic-gate * Remove a program, version to port mapping.
101*0Sstevel@tonic-gate */
102*0Sstevel@tonic-gate pmapproc_change(rqstp, xprt, rqstp->rq_proc);
103*0Sstevel@tonic-gate break;
104*0Sstevel@tonic-gate
105*0Sstevel@tonic-gate case PMAPPROC_GETPORT:
106*0Sstevel@tonic-gate /*
107*0Sstevel@tonic-gate * Lookup the mapping for a program, version and return its
108*0Sstevel@tonic-gate * port number.
109*0Sstevel@tonic-gate */
110*0Sstevel@tonic-gate pmapproc_getport(rqstp, xprt);
111*0Sstevel@tonic-gate break;
112*0Sstevel@tonic-gate
113*0Sstevel@tonic-gate case PMAPPROC_DUMP:
114*0Sstevel@tonic-gate /*
115*0Sstevel@tonic-gate * Return the current set of mapped program, version
116*0Sstevel@tonic-gate */
117*0Sstevel@tonic-gate #ifdef RPCBIND_DEBUG
118*0Sstevel@tonic-gate fprintf(stderr, "PMAPPROC_DUMP\n");
119*0Sstevel@tonic-gate #endif
120*0Sstevel@tonic-gate PMAP_CHECK(xprt, rqstp->rq_proc);
121*0Sstevel@tonic-gate pmapproc_dump(rqstp, xprt);
122*0Sstevel@tonic-gate break;
123*0Sstevel@tonic-gate
124*0Sstevel@tonic-gate case PMAPPROC_CALLIT:
125*0Sstevel@tonic-gate /*
126*0Sstevel@tonic-gate * Calls a procedure on the local machine. If the requested
127*0Sstevel@tonic-gate * procedure is not registered this procedure does not return
128*0Sstevel@tonic-gate * error information!!
129*0Sstevel@tonic-gate * This procedure is only supported on rpc/udp and calls via
130*0Sstevel@tonic-gate * rpc/udp. It passes null authentication parameters.
131*0Sstevel@tonic-gate */
132*0Sstevel@tonic-gate rpcbproc_callit_com(rqstp, xprt, PMAPPROC_CALLIT, PMAPVERS);
133*0Sstevel@tonic-gate break;
134*0Sstevel@tonic-gate
135*0Sstevel@tonic-gate default:
136*0Sstevel@tonic-gate PMAP_CHECK(xprt, rqstp->rq_proc);
137*0Sstevel@tonic-gate svcerr_noproc(xprt);
138*0Sstevel@tonic-gate break;
139*0Sstevel@tonic-gate }
140*0Sstevel@tonic-gate }
141*0Sstevel@tonic-gate
142*0Sstevel@tonic-gate /*
143*0Sstevel@tonic-gate * returns the item with the given program, version number. If that version
144*0Sstevel@tonic-gate * number is not found, it returns the item with that program number, so that
145*0Sstevel@tonic-gate * the port number is now returned to the caller. The caller when makes a
146*0Sstevel@tonic-gate * call to this program, version number, the call will fail and it will
147*0Sstevel@tonic-gate * return with PROGVERS_MISMATCH. The user can then determine the highest
148*0Sstevel@tonic-gate * and the lowest version number for this program using clnt_geterr() and
149*0Sstevel@tonic-gate * use those program version numbers.
150*0Sstevel@tonic-gate */
151*0Sstevel@tonic-gate static PMAPLIST *
find_service_pmap(prog,vers,prot)152*0Sstevel@tonic-gate find_service_pmap(prog, vers, prot)
153*0Sstevel@tonic-gate ulong_t prog;
154*0Sstevel@tonic-gate ulong_t vers;
155*0Sstevel@tonic-gate ulong_t prot;
156*0Sstevel@tonic-gate {
157*0Sstevel@tonic-gate register PMAPLIST *hit = NULL;
158*0Sstevel@tonic-gate register PMAPLIST *pml;
159*0Sstevel@tonic-gate
160*0Sstevel@tonic-gate for (pml = list_pml; pml != NULL; pml = pml->pml_next) {
161*0Sstevel@tonic-gate if ((pml->pml_map.pm_prog != prog) ||
162*0Sstevel@tonic-gate (pml->pml_map.pm_prot != prot))
163*0Sstevel@tonic-gate continue;
164*0Sstevel@tonic-gate hit = pml;
165*0Sstevel@tonic-gate if (pml->pml_map.pm_vers == vers)
166*0Sstevel@tonic-gate break;
167*0Sstevel@tonic-gate }
168*0Sstevel@tonic-gate return (hit);
169*0Sstevel@tonic-gate }
170*0Sstevel@tonic-gate
171*0Sstevel@tonic-gate extern char *getowner(SVCXPRT *xprt, char *);
172*0Sstevel@tonic-gate
173*0Sstevel@tonic-gate /*ARGSUSED*/
174*0Sstevel@tonic-gate static bool_t
pmapproc_change(rqstp,xprt,op)175*0Sstevel@tonic-gate pmapproc_change(rqstp, xprt, op)
176*0Sstevel@tonic-gate struct svc_req *rqstp;
177*0Sstevel@tonic-gate register SVCXPRT *xprt;
178*0Sstevel@tonic-gate unsigned long op;
179*0Sstevel@tonic-gate {
180*0Sstevel@tonic-gate PMAP reg;
181*0Sstevel@tonic-gate RPCB rpcbreg;
182*0Sstevel@tonic-gate int ans;
183*0Sstevel@tonic-gate struct sockaddr_in *who;
184*0Sstevel@tonic-gate extern bool_t map_set(), map_unset();
185*0Sstevel@tonic-gate char owner[64];
186*0Sstevel@tonic-gate
187*0Sstevel@tonic-gate if (!svc_getargs(xprt, (xdrproc_t)xdr_pmap, (char *)®)) {
188*0Sstevel@tonic-gate svcerr_decode(xprt);
189*0Sstevel@tonic-gate return (FALSE);
190*0Sstevel@tonic-gate }
191*0Sstevel@tonic-gate who = svc_getcaller(xprt);
192*0Sstevel@tonic-gate
193*0Sstevel@tonic-gate #ifdef RPCBIND_DEBUG
194*0Sstevel@tonic-gate fprintf(stderr, "%s request for (%lu, %lu) : ",
195*0Sstevel@tonic-gate op == PMAPPROC_SET ? "PMAP_SET" : "PMAP_UNSET",
196*0Sstevel@tonic-gate reg.pm_prog, reg.pm_vers);
197*0Sstevel@tonic-gate #endif
198*0Sstevel@tonic-gate
199*0Sstevel@tonic-gate /* Don't allow unset/set from remote. */
200*0Sstevel@tonic-gate if (!localxprt(xprt, B_TRUE)) {
201*0Sstevel@tonic-gate ans = FALSE;
202*0Sstevel@tonic-gate goto done_change;
203*0Sstevel@tonic-gate }
204*0Sstevel@tonic-gate
205*0Sstevel@tonic-gate rpcbreg.r_owner = getowner(xprt, owner);
206*0Sstevel@tonic-gate
207*0Sstevel@tonic-gate if ((op == PMAPPROC_SET) && (reg.pm_port < IPPORT_RESERVED) &&
208*0Sstevel@tonic-gate (ntohs(who->sin_port) >= IPPORT_RESERVED)) {
209*0Sstevel@tonic-gate ans = FALSE;
210*0Sstevel@tonic-gate goto done_change;
211*0Sstevel@tonic-gate }
212*0Sstevel@tonic-gate rpcbreg.r_prog = reg.pm_prog;
213*0Sstevel@tonic-gate rpcbreg.r_vers = reg.pm_vers;
214*0Sstevel@tonic-gate
215*0Sstevel@tonic-gate if (op == PMAPPROC_SET) {
216*0Sstevel@tonic-gate char buf[32];
217*0Sstevel@tonic-gate
218*0Sstevel@tonic-gate sprintf(buf, "0.0.0.0.%d.%d", (reg.pm_port >> 8) & 0xff,
219*0Sstevel@tonic-gate reg.pm_port & 0xff);
220*0Sstevel@tonic-gate rpcbreg.r_addr = buf;
221*0Sstevel@tonic-gate if (reg.pm_prot == IPPROTO_UDP) {
222*0Sstevel@tonic-gate rpcbreg.r_netid = udptrans;
223*0Sstevel@tonic-gate } else if (reg.pm_prot == IPPROTO_TCP) {
224*0Sstevel@tonic-gate rpcbreg.r_netid = tcptrans;
225*0Sstevel@tonic-gate } else {
226*0Sstevel@tonic-gate ans = FALSE;
227*0Sstevel@tonic-gate goto done_change;
228*0Sstevel@tonic-gate }
229*0Sstevel@tonic-gate ans = map_set(&rpcbreg, rpcbreg.r_owner);
230*0Sstevel@tonic-gate } else if (op == PMAPPROC_UNSET) {
231*0Sstevel@tonic-gate bool_t ans1, ans2;
232*0Sstevel@tonic-gate
233*0Sstevel@tonic-gate rpcbreg.r_addr = NULL;
234*0Sstevel@tonic-gate rpcbreg.r_netid = tcptrans;
235*0Sstevel@tonic-gate ans1 = map_unset(&rpcbreg, rpcbreg.r_owner);
236*0Sstevel@tonic-gate rpcbreg.r_netid = udptrans;
237*0Sstevel@tonic-gate ans2 = map_unset(&rpcbreg, rpcbreg.r_owner);
238*0Sstevel@tonic-gate ans = ans1 || ans2;
239*0Sstevel@tonic-gate } else {
240*0Sstevel@tonic-gate ans = FALSE;
241*0Sstevel@tonic-gate }
242*0Sstevel@tonic-gate done_change:
243*0Sstevel@tonic-gate PMAP_LOG(ans, xprt, op, reg.pm_prog);
244*0Sstevel@tonic-gate
245*0Sstevel@tonic-gate if ((!svc_sendreply(xprt, (xdrproc_t)xdr_long, (caddr_t)&ans)) &&
246*0Sstevel@tonic-gate debugging) {
247*0Sstevel@tonic-gate fprintf(stderr, "portmap: svc_sendreply\n");
248*0Sstevel@tonic-gate if (doabort) {
249*0Sstevel@tonic-gate rpcbind_abort();
250*0Sstevel@tonic-gate }
251*0Sstevel@tonic-gate }
252*0Sstevel@tonic-gate #ifdef RPCBIND_DEBUG
253*0Sstevel@tonic-gate fprintf(stderr, "%s\n", ans == TRUE ? "succeeded" : "failed");
254*0Sstevel@tonic-gate #endif
255*0Sstevel@tonic-gate if (op == PMAPPROC_SET)
256*0Sstevel@tonic-gate rpcbs_set(RPCBVERS_2_STAT, ans);
257*0Sstevel@tonic-gate else
258*0Sstevel@tonic-gate rpcbs_unset(RPCBVERS_2_STAT, ans);
259*0Sstevel@tonic-gate return (TRUE);
260*0Sstevel@tonic-gate }
261*0Sstevel@tonic-gate
262*0Sstevel@tonic-gate /* ARGSUSED */
263*0Sstevel@tonic-gate static bool_t
pmapproc_getport(rqstp,xprt)264*0Sstevel@tonic-gate pmapproc_getport(rqstp, xprt)
265*0Sstevel@tonic-gate struct svc_req *rqstp;
266*0Sstevel@tonic-gate register SVCXPRT *xprt;
267*0Sstevel@tonic-gate {
268*0Sstevel@tonic-gate PMAP reg;
269*0Sstevel@tonic-gate int port = 0;
270*0Sstevel@tonic-gate PMAPLIST *fnd;
271*0Sstevel@tonic-gate #ifdef RPCBIND_DEBUG
272*0Sstevel@tonic-gate char *uaddr;
273*0Sstevel@tonic-gate #endif
274*0Sstevel@tonic-gate
275*0Sstevel@tonic-gate if (!svc_getargs(xprt, (xdrproc_t)xdr_pmap, (char *)®)) {
276*0Sstevel@tonic-gate svcerr_decode(xprt);
277*0Sstevel@tonic-gate return (FALSE);
278*0Sstevel@tonic-gate }
279*0Sstevel@tonic-gate PMAP_CHECK_RET(xprt, rqstp->rq_proc, FALSE);
280*0Sstevel@tonic-gate
281*0Sstevel@tonic-gate #ifdef RPCBIND_DEBUG
282*0Sstevel@tonic-gate uaddr = taddr2uaddr(rpcbind_get_conf(xprt->xp_netid),
283*0Sstevel@tonic-gate svc_getrpccaller(xprt));
284*0Sstevel@tonic-gate fprintf(stderr, "PMAP_GETPORT request for (%lu, %lu, %s) from %s :",
285*0Sstevel@tonic-gate reg.pm_prog, reg.pm_vers,
286*0Sstevel@tonic-gate reg.pm_prot == IPPROTO_UDP ? "udp" : "tcp", uaddr);
287*0Sstevel@tonic-gate free(uaddr);
288*0Sstevel@tonic-gate #endif
289*0Sstevel@tonic-gate fnd = find_service_pmap(reg.pm_prog, reg.pm_vers, reg.pm_prot);
290*0Sstevel@tonic-gate if (fnd) {
291*0Sstevel@tonic-gate char serveuaddr[32], *ua;
292*0Sstevel@tonic-gate int h1, h2, h3, h4, p1, p2;
293*0Sstevel@tonic-gate char *netid;
294*0Sstevel@tonic-gate
295*0Sstevel@tonic-gate if (reg.pm_prot == IPPROTO_UDP) {
296*0Sstevel@tonic-gate ua = udp_uaddr;
297*0Sstevel@tonic-gate netid = udptrans;
298*0Sstevel@tonic-gate } else {
299*0Sstevel@tonic-gate ua = tcp_uaddr; /* To get the len */
300*0Sstevel@tonic-gate netid = tcptrans;
301*0Sstevel@tonic-gate }
302*0Sstevel@tonic-gate if (ua == NULL) {
303*0Sstevel@tonic-gate goto sendreply;
304*0Sstevel@tonic-gate }
305*0Sstevel@tonic-gate if (sscanf(ua, "%d.%d.%d.%d.%d.%d", &h1, &h2, &h3,
306*0Sstevel@tonic-gate &h4, &p1, &p2) == 6) {
307*0Sstevel@tonic-gate p1 = (fnd->pml_map.pm_port >> 8) & 0xff;
308*0Sstevel@tonic-gate p2 = (fnd->pml_map.pm_port) & 0xff;
309*0Sstevel@tonic-gate sprintf(serveuaddr, "%d.%d.%d.%d.%d.%d",
310*0Sstevel@tonic-gate h1, h2, h3, h4, p1, p2);
311*0Sstevel@tonic-gate if (is_bound(netid, serveuaddr)) {
312*0Sstevel@tonic-gate port = fnd->pml_map.pm_port;
313*0Sstevel@tonic-gate } else { /* this service is dead; delete it */
314*0Sstevel@tonic-gate delete_prog(reg.pm_prog);
315*0Sstevel@tonic-gate }
316*0Sstevel@tonic-gate }
317*0Sstevel@tonic-gate }
318*0Sstevel@tonic-gate sendreply:
319*0Sstevel@tonic-gate if ((!svc_sendreply(xprt, (xdrproc_t)xdr_long, (caddr_t)&port)) &&
320*0Sstevel@tonic-gate debugging) {
321*0Sstevel@tonic-gate (void) fprintf(stderr, "portmap: svc_sendreply\n");
322*0Sstevel@tonic-gate if (doabort) {
323*0Sstevel@tonic-gate rpcbind_abort();
324*0Sstevel@tonic-gate }
325*0Sstevel@tonic-gate }
326*0Sstevel@tonic-gate #ifdef RPCBIND_DEBUG
327*0Sstevel@tonic-gate fprintf(stderr, "port = %d\n", port);
328*0Sstevel@tonic-gate #endif
329*0Sstevel@tonic-gate rpcbs_getaddr(RPCBVERS_2_STAT, reg.pm_prog, reg.pm_vers,
330*0Sstevel@tonic-gate reg.pm_prot == IPPROTO_UDP ? udptrans : tcptrans,
331*0Sstevel@tonic-gate port ? udptrans : "");
332*0Sstevel@tonic-gate
333*0Sstevel@tonic-gate return (TRUE);
334*0Sstevel@tonic-gate }
335*0Sstevel@tonic-gate
336*0Sstevel@tonic-gate /* ARGSUSED */
337*0Sstevel@tonic-gate static bool_t
pmapproc_dump(rqstp,xprt)338*0Sstevel@tonic-gate pmapproc_dump(rqstp, xprt)
339*0Sstevel@tonic-gate struct svc_req *rqstp;
340*0Sstevel@tonic-gate register SVCXPRT *xprt;
341*0Sstevel@tonic-gate {
342*0Sstevel@tonic-gate if (!svc_getargs(xprt, (xdrproc_t)xdr_void, NULL)) {
343*0Sstevel@tonic-gate svcerr_decode(xprt);
344*0Sstevel@tonic-gate return (FALSE);
345*0Sstevel@tonic-gate }
346*0Sstevel@tonic-gate if ((!svc_sendreply(xprt, (xdrproc_t)xdr_pmaplist_ptr,
347*0Sstevel@tonic-gate (caddr_t)&list_pml)) && debugging) {
348*0Sstevel@tonic-gate (void) fprintf(stderr, "portmap: svc_sendreply\n");
349*0Sstevel@tonic-gate if (doabort) {
350*0Sstevel@tonic-gate rpcbind_abort();
351*0Sstevel@tonic-gate }
352*0Sstevel@tonic-gate }
353*0Sstevel@tonic-gate return (TRUE);
354*0Sstevel@tonic-gate }
355*0Sstevel@tonic-gate
356*0Sstevel@tonic-gate /*
357*0Sstevel@tonic-gate * Is the transport local? The original rpcbind code tried to
358*0Sstevel@tonic-gate * figure out all the network interfaces but there can be a nearly
359*0Sstevel@tonic-gate * infinite number of network interfaces. And the number of interfaces can
360*0Sstevel@tonic-gate * vary over time.
361*0Sstevel@tonic-gate *
362*0Sstevel@tonic-gate * Note that when we get here, we've already establised that we're
363*0Sstevel@tonic-gate * dealing with a TCP/IP endpoint.
364*0Sstevel@tonic-gate */
365*0Sstevel@tonic-gate boolean_t
localxprt(SVCXPRT * transp,boolean_t forceipv4)366*0Sstevel@tonic-gate localxprt(SVCXPRT *transp, boolean_t forceipv4)
367*0Sstevel@tonic-gate {
368*0Sstevel@tonic-gate struct sockaddr_gen *sgen = svc_getgencaller(transp);
369*0Sstevel@tonic-gate
370*0Sstevel@tonic-gate switch (SGFAM(sgen)) {
371*0Sstevel@tonic-gate case AF_INET:
372*0Sstevel@tonic-gate break;
373*0Sstevel@tonic-gate case AF_INET6:
374*0Sstevel@tonic-gate if (forceipv4)
375*0Sstevel@tonic-gate return (B_FALSE);
376*0Sstevel@tonic-gate break;
377*0Sstevel@tonic-gate default:
378*0Sstevel@tonic-gate return (B_FALSE);
379*0Sstevel@tonic-gate }
380*0Sstevel@tonic-gate
381*0Sstevel@tonic-gate /*
382*0Sstevel@tonic-gate * Get the peer's uid; if it is known it is sufficiently
383*0Sstevel@tonic-gate * authenticated and considered local. The magic behind this
384*0Sstevel@tonic-gate * call is all in libnsl.
385*0Sstevel@tonic-gate */
386*0Sstevel@tonic-gate return (rpcb_caller_uid(transp) != -1);
387*0Sstevel@tonic-gate }
388*0Sstevel@tonic-gate #endif /* PORTMAP */
389