xref: /illumos-gate/usr/src/cmd/rpcbind/rpcbind.h (revision 8f6d9dae)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
50ea5e3a5Sjjj  * Common Development and Distribution License (the "License").
60ea5e3a5Sjjj  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
200ea5e3a5Sjjj  *
210ea5e3a5Sjjj  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
227c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
237c478bd9Sstevel@tonic-gate  */
24*8f6d9daeSMarcel Telka /*
25*8f6d9daeSMarcel Telka  * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
26*8f6d9daeSMarcel Telka  */
277c478bd9Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
287c478bd9Sstevel@tonic-gate /* All Rights Reserved */
297c478bd9Sstevel@tonic-gate /*
307c478bd9Sstevel@tonic-gate  * University Copyright- Copyright (c) 1982, 1986, 1988
317c478bd9Sstevel@tonic-gate  * The Regents of the University of California
327c478bd9Sstevel@tonic-gate  * All Rights Reserved
337c478bd9Sstevel@tonic-gate  *
347c478bd9Sstevel@tonic-gate  * University Acknowledgment- Portions of this document are derived from
357c478bd9Sstevel@tonic-gate  * software developed by the University of California, Berkeley, and its
367c478bd9Sstevel@tonic-gate  * contributors.
377c478bd9Sstevel@tonic-gate  */
397c478bd9Sstevel@tonic-gate /*
407c478bd9Sstevel@tonic-gate  * rpcbind.h
417c478bd9Sstevel@tonic-gate  * The common header declarations
427c478bd9Sstevel@tonic-gate  */
447c478bd9Sstevel@tonic-gate #ifndef _RPCBIND_H
457c478bd9Sstevel@tonic-gate #define	_RPCBIND_H
477c478bd9Sstevel@tonic-gate #ifdef PORTMAP
487c478bd9Sstevel@tonic-gate #include <rpc/pmap_prot.h>
497c478bd9Sstevel@tonic-gate #endif
507c478bd9Sstevel@tonic-gate #include <rpc/rpcb_prot.h>
51*8f6d9daeSMarcel Telka #include <synch.h>
537c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
547c478bd9Sstevel@tonic-gate extern "C" {
557c478bd9Sstevel@tonic-gate #endif
577c478bd9Sstevel@tonic-gate extern int debugging;
587c478bd9Sstevel@tonic-gate extern int doabort;
59*8f6d9daeSMarcel Telka extern rwlock_t list_rbl_lock;	/* Protects list_rbl */
607c478bd9Sstevel@tonic-gate extern rpcblist_ptr list_rbl;	/* A list of version 3 & 4 rpcbind services */
617c478bd9Sstevel@tonic-gate extern char *loopback_dg;	/* CLTS loopback transport, for set/unset */
627c478bd9Sstevel@tonic-gate extern char *loopback_vc;	/* COTS loopback transport, for set/unset */
637c478bd9Sstevel@tonic-gate extern char *loopback_vc_ord;	/* COTS_ORD loopback transport, for set/unset */
657c478bd9Sstevel@tonic-gate #ifdef PORTMAP
66*8f6d9daeSMarcel Telka extern rwlock_t list_pml_lock;	/* Protects list_pml */
677c478bd9Sstevel@tonic-gate extern pmaplist *list_pml;	/* A list of version 2 rpcbind services */
687c478bd9Sstevel@tonic-gate extern char *udptrans;		/* Name of UDP transport */
697c478bd9Sstevel@tonic-gate extern char *tcptrans;		/* Name of TCP transport */
707c478bd9Sstevel@tonic-gate extern char *udp_uaddr;		/* Universal UDP address */
717c478bd9Sstevel@tonic-gate extern char *tcp_uaddr;		/* Universal TCP address */
727c478bd9Sstevel@tonic-gate #endif
74*8f6d9daeSMarcel Telka char *mergeaddr(SVCXPRT *, char *, char *, char *);
75*8f6d9daeSMarcel Telka int add_bndlist(struct netconfig *, struct t_bind *, struct t_bind *);
76*8f6d9daeSMarcel Telka int create_rmtcall_fd(struct netconfig *);
77*8f6d9daeSMarcel Telka bool_t is_bound(char *, char *);
78*8f6d9daeSMarcel Telka void set_rpcb_rmtcalls_max(int);
807c478bd9Sstevel@tonic-gate /* TCP wrapper functions and variables. */
81*8f6d9daeSMarcel Telka boolean_t localxprt(SVCXPRT *, boolean_t);
82*8f6d9daeSMarcel Telka void qsyslog(int pri, const char *fmt, ...);
83*8f6d9daeSMarcel Telka boolean_t rpcb_check(SVCXPRT *, rpcproc_t, boolean_t);
84*8f6d9daeSMarcel Telka void rpcb_log(boolean_t, SVCXPRT *, rpcproc_t, rpcprog_t, boolean_t);
85*8f6d9daeSMarcel Telka extern volatile boolean_t allow_indirect;
86*8f6d9daeSMarcel Telka extern volatile boolean_t wrap_enabled;
87*8f6d9daeSMarcel Telka extern volatile boolean_t verboselog;
88*8f6d9daeSMarcel Telka extern volatile boolean_t local_only;
907c478bd9Sstevel@tonic-gate #define	svc_getgencaller(transp) \
917c478bd9Sstevel@tonic-gate 	((struct sockaddr_gen *)svc_getrpccaller((transp))->buf)
937c478bd9Sstevel@tonic-gate #define	RPCB_CHECK(xprt, proc) \
940ea5e3a5Sjjj 	if ((wrap_enabled || local_only) && \
950ea5e3a5Sjjj 	    !rpcb_check((xprt), (proc), B_FALSE)) \
967c478bd9Sstevel@tonic-gate 		return
987c478bd9Sstevel@tonic-gate #define	PMAP_CHECK(xprt, proc) \
990ea5e3a5Sjjj 	if ((wrap_enabled || local_only) && \
1000ea5e3a5Sjjj 	    !rpcb_check((xprt), (proc), B_TRUE)) \
1017c478bd9Sstevel@tonic-gate 		return
1037c478bd9Sstevel@tonic-gate #define	PMAP_CHECK_RET(xprt, proc, ret) \
1040ea5e3a5Sjjj 	if ((wrap_enabled || local_only) && \
1050ea5e3a5Sjjj 	    !rpcb_check((xprt), (proc), B_TRUE)) \
1067c478bd9Sstevel@tonic-gate 		return (ret)
1087c478bd9Sstevel@tonic-gate #define	RPCB_LOG(xprt, proc, prog) \
1097c478bd9Sstevel@tonic-gate 	if (wrap_enabled) \
1107c478bd9Sstevel@tonic-gate 	    rpcb_log(B_TRUE, (xprt), (proc), (prog), B_FALSE)
1127c478bd9Sstevel@tonic-gate #define	PMAP_LOG(ans, xprt, proc, prog) \
1137c478bd9Sstevel@tonic-gate 	if (wrap_enabled) \
1147c478bd9Sstevel@tonic-gate 	    rpcb_log(ans, (xprt), (proc), (prog), B_TRUE)
116*8f6d9daeSMarcel Telka bool_t map_set(RPCB *, char *);
117*8f6d9daeSMarcel Telka bool_t map_unset(RPCB *, char *);
1197c478bd9Sstevel@tonic-gate /* Statistics gathering functions */
120*8f6d9daeSMarcel Telka void rpcbs_procinfo(int, rpcproc_t);
121*8f6d9daeSMarcel Telka void rpcbs_set(int, bool_t);
122*8f6d9daeSMarcel Telka void rpcbs_unset(int, bool_t);
123*8f6d9daeSMarcel Telka void rpcbs_getaddr(int, rpcprog_t, rpcvers_t, char *, char *);
124*8f6d9daeSMarcel Telka void rpcbs_rmtcall(int, rpcproc_t, rpcprog_t, rpcvers_t, rpcproc_t, char *,
125*8f6d9daeSMarcel Telka     rpcblist_ptr);
126*8f6d9daeSMarcel Telka bool_t rpcbproc_getstat(void *, rpcb_stat_byvers **);
127*8f6d9daeSMarcel Telka bool_t xdr_rpcb_stat_byvers_ptr(XDR *, rpcb_stat_byvers **);
128*8f6d9daeSMarcel Telka 
129*8f6d9daeSMarcel Telka struct netconfig *rpcbind_get_conf();
130*8f6d9daeSMarcel Telka void rpcbind_abort() __NORETURN;
131*8f6d9daeSMarcel Telka 
132*8f6d9daeSMarcel Telka #ifdef PORTMAP
133*8f6d9daeSMarcel Telka void pmap_service(struct svc_req *, SVCXPRT *xprt);
134*8f6d9daeSMarcel Telka #endif
135*8f6d9daeSMarcel Telka void rpcb_service_3(struct svc_req *, SVCXPRT *xprt);
136*8f6d9daeSMarcel Telka void rpcb_service_4(struct svc_req *, SVCXPRT *xprt);
137*8f6d9daeSMarcel Telka void read_warmstart(void);
138*8f6d9daeSMarcel Telka void write_warmstart(void);
139*8f6d9daeSMarcel Telka int Is_ipv6present(void);
141*8f6d9daeSMarcel Telka extern zoneid_t myzone;
1437c478bd9Sstevel@tonic-gate /* Common functions shared between versions */
144*8f6d9daeSMarcel Telka void rpcbproc_callit_com(struct svc_req *, SVCXPRT *, ulong_t, int);
145*8f6d9daeSMarcel Telka bool_t rpcbproc_set_com(RPCB *, bool_t *, struct svc_req *, int);
146*8f6d9daeSMarcel Telka bool_t rpcbproc_unset_com(RPCB *, bool_t *, struct svc_req *, int);
147*8f6d9daeSMarcel Telka bool_t rpcbproc_gettime_com(void *, ulong_t *);
148*8f6d9daeSMarcel Telka bool_t rpcbproc_uaddr2taddr_com(char **, struct netbuf *, struct svc_req *);
149*8f6d9daeSMarcel Telka bool_t rpcbproc_taddr2uaddr_com(struct netbuf *, char **, struct svc_req *);
150*8f6d9daeSMarcel Telka bool_t rpcbproc_getaddr_com(RPCB *, char **, struct svc_req *, ulong_t);
151*8f6d9daeSMarcel Telka void delete_prog(rpcprog_t);
152*8f6d9daeSMarcel Telka bool_t rpcbproc_dump_com(void *, rpcblist_ptr **);
153*8f6d9daeSMarcel Telka char *getowner(SVCXPRT *, char *);
154*8f6d9daeSMarcel Telka 
155*8f6d9daeSMarcel Telka int del_pmaplist(RPCB *);
156*8f6d9daeSMarcel Telka void delete_rbl(rpcblist_ptr);
157*8f6d9daeSMarcel Telka 
158*8f6d9daeSMarcel Telka uid_t rpcb_caller_uid(SVCXPRT *);
159*8f6d9daeSMarcel Telka 
160*8f6d9daeSMarcel Telka /* XDR functions */
161*8f6d9daeSMarcel Telka bool_t xdr_rpcblist_ptr_ptr(XDR *, rpcblist_ptr **);
1637c478bd9Sstevel@tonic-gate /* For different getaddr semantics */
1647c478bd9Sstevel@tonic-gate #define	RPCB_ALLVERS 0
1657c478bd9Sstevel@tonic-gate #define	RPCB_ONEVERS 1
1677c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1687c478bd9Sstevel@tonic-gate }
1697c478bd9Sstevel@tonic-gate #endif
1717c478bd9Sstevel@tonic-gate #endif /* _RPCBIND_H */