xref: /titanic_50/usr/src/cmd/rpcbind/rpcbind.h (revision b3700b074e637f8c6991b70754c88a2cfffb246b)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  *
21  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
22  * Use is subject to license terms.
23  */
24 /*
25  * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
26  */
27 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
29 /*
30  * University Copyright- Copyright (c) 1982, 1986, 1988
31  * The Regents of the University of California
32  * All Rights Reserved
33  *
34  * University Acknowledgment- Portions of this document are derived from
35  * software developed by the University of California, Berkeley, and its
36  * contributors.
37  */
38 
39 /*
40  * rpcbind.h
41  * The common header declarations
42  */
43 
44 #ifndef _RPCBIND_H
45 #define	_RPCBIND_H
46 
47 #ifdef PORTMAP
48 #include <rpc/pmap_prot.h>
49 #endif
50 #include <rpc/rpcb_prot.h>
51 #include <synch.h>
52 
53 #ifdef	__cplusplus
54 extern "C" {
55 #endif
56 
57 extern int debugging;
58 extern int doabort;
59 extern rwlock_t list_rbl_lock;	/* Protects list_rbl */
60 extern rpcblist_ptr list_rbl;	/* A list of version 3 & 4 rpcbind services */
61 extern char *loopback_dg;	/* CLTS loopback transport, for set/unset */
62 extern char *loopback_vc;	/* COTS loopback transport, for set/unset */
63 extern char *loopback_vc_ord;	/* COTS_ORD loopback transport, for set/unset */
64 
65 #ifdef PORTMAP
66 extern rwlock_t list_pml_lock;	/* Protects list_pml */
67 extern pmaplist *list_pml;	/* A list of version 2 rpcbind services */
68 extern char *udptrans;		/* Name of UDP transport */
69 extern char *tcptrans;		/* Name of TCP transport */
70 extern char *udp_uaddr;		/* Universal UDP address */
71 extern char *tcp_uaddr;		/* Universal TCP address */
72 #endif
73 
74 char *mergeaddr(SVCXPRT *, char *, char *, char *);
75 int add_bndlist(struct netconfig *, struct t_bind *, struct t_bind *);
76 int create_rmtcall_fd(struct netconfig *);
77 bool_t is_bound(char *, char *);
78 void set_rpcb_rmtcalls_max(int);
79 
80 /* TCP wrapper functions and variables. */
81 boolean_t localxprt(SVCXPRT *, boolean_t);
82 void qsyslog(int pri, const char *fmt, ...);
83 boolean_t rpcb_check(SVCXPRT *, rpcproc_t, boolean_t);
84 void rpcb_log(boolean_t, SVCXPRT *, rpcproc_t, rpcprog_t, boolean_t);
85 extern volatile boolean_t allow_indirect;
86 extern volatile boolean_t wrap_enabled;
87 extern volatile boolean_t verboselog;
88 extern volatile boolean_t local_only;
89 
90 #define	svc_getgencaller(transp) \
91 	((struct sockaddr_gen *)svc_getrpccaller((transp))->buf)
92 
93 #define	RPCB_CHECK(xprt, proc) \
94 	if ((wrap_enabled || local_only) && \
95 	    !rpcb_check((xprt), (proc), B_FALSE)) \
96 		return
97 
98 #define	PMAP_CHECK(xprt, proc) \
99 	if ((wrap_enabled || local_only) && \
100 	    !rpcb_check((xprt), (proc), B_TRUE)) \
101 		return
102 
103 #define	PMAP_CHECK_RET(xprt, proc, ret) \
104 	if ((wrap_enabled || local_only) && \
105 	    !rpcb_check((xprt), (proc), B_TRUE)) \
106 		return (ret)
107 
108 #define	RPCB_LOG(xprt, proc, prog) \
109 	if (wrap_enabled) \
110 	    rpcb_log(B_TRUE, (xprt), (proc), (prog), B_FALSE)
111 
112 #define	PMAP_LOG(ans, xprt, proc, prog) \
113 	if (wrap_enabled) \
114 	    rpcb_log(ans, (xprt), (proc), (prog), B_TRUE)
115 
116 bool_t map_set(RPCB *, char *);
117 bool_t map_unset(RPCB *, char *);
118 
119 /* Statistics gathering functions */
120 void rpcbs_procinfo(int, rpcproc_t);
121 void rpcbs_set(int, bool_t);
122 void rpcbs_unset(int, bool_t);
123 void rpcbs_getaddr(int, rpcprog_t, rpcvers_t, char *, char *);
124 void rpcbs_rmtcall(int, rpcproc_t, rpcprog_t, rpcvers_t, rpcproc_t, char *,
125     rpcblist_ptr);
126 bool_t rpcbproc_getstat(void *, rpcb_stat_byvers **);
127 bool_t xdr_rpcb_stat_byvers_ptr(XDR *, rpcb_stat_byvers **);
128 
129 struct netconfig *rpcbind_get_conf();
130 void rpcbind_abort() __NORETURN;
131 
132 #ifdef PORTMAP
133 void pmap_service(struct svc_req *, SVCXPRT *xprt);
134 #endif
135 void rpcb_service_3(struct svc_req *, SVCXPRT *xprt);
136 void rpcb_service_4(struct svc_req *, SVCXPRT *xprt);
137 void read_warmstart(void);
138 void write_warmstart(void);
139 int Is_ipv6present(void);
140 
141 extern zoneid_t myzone;
142 
143 /* Common functions shared between versions */
144 void rpcbproc_callit_com(struct svc_req *, SVCXPRT *, ulong_t, int);
145 bool_t rpcbproc_set_com(RPCB *, bool_t *, struct svc_req *, int);
146 bool_t rpcbproc_unset_com(RPCB *, bool_t *, struct svc_req *, int);
147 bool_t rpcbproc_gettime_com(void *, ulong_t *);
148 bool_t rpcbproc_uaddr2taddr_com(char **, struct netbuf *, struct svc_req *);
149 bool_t rpcbproc_taddr2uaddr_com(struct netbuf *, char **, struct svc_req *);
150 bool_t rpcbproc_getaddr_com(RPCB *, char **, struct svc_req *, ulong_t);
151 void delete_prog(rpcprog_t);
152 bool_t rpcbproc_dump_com(void *, rpcblist_ptr **);
153 char *getowner(SVCXPRT *, char *);
154 
155 int del_pmaplist(RPCB *);
156 void delete_rbl(rpcblist_ptr);
157 
158 uid_t rpcb_caller_uid(SVCXPRT *);
159 
160 /* XDR functions */
161 bool_t xdr_rpcblist_ptr_ptr(XDR *, rpcblist_ptr **);
162 
163 /* For different getaddr semantics */
164 #define	RPCB_ALLVERS 0
165 #define	RPCB_ONEVERS 1
166 
167 #ifdef	__cplusplus
168 }
169 #endif
170 
171 #endif /* _RPCBIND_H */
172