xref: /titanic_50/usr/src/cmd/rpcbind/rpcbind.h (revision c77a61a72b5ecdc507d6cf104142edd371a16c84)
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 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
25 /* All Rights Reserved */
26 /*
27  * University Copyright- Copyright (c) 1982, 1986, 1988
28  * The Regents of the University of California
29  * All Rights Reserved
30  *
31  * University Acknowledgment- Portions of this document are derived from
32  * software developed by the University of California, Berkeley, and its
33  * contributors.
34  */
35 
36 /*
37  * rpcbind.h
38  * The common header declarations
39  */
40 
41 #ifndef _RPCBIND_H
42 #define	_RPCBIND_H
43 
44 #pragma ident	"%Z%%M%	%I%	%E% SMI"
45 
46 #ifdef PORTMAP
47 #include <rpc/pmap_prot.h>
48 #endif
49 #include <rpc/rpcb_prot.h>
50 #include <signal.h>
51 
52 #include <tcpd.h>
53 
54 #ifdef	__cplusplus
55 extern "C" {
56 #endif
57 
58 extern int debugging;
59 extern int doabort;
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 extern volatile sig_atomic_t sigrefresh; /* Did we receive a SIGHUP recently? */
65 
66 #ifdef PORTMAP
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 extern char *mergeaddr();
75 extern int add_bndlist();
76 extern int create_rmtcall_fd();
77 extern bool_t is_bound();
78 extern void my_svc_run();
79 extern void rpcb_check_init(void);
80 
81 /* TCP wrapper functions and variables. */
82 extern boolean_t localxprt(SVCXPRT *, boolean_t);
83 extern void qsyslog(int pri, const char *fmt, ...);
84 extern boolean_t rpcb_check(SVCXPRT *, rpcproc_t, boolean_t);
85 extern void rpcb_log(boolean_t, SVCXPRT *, rpcproc_t, rpcprog_t, boolean_t);
86 extern boolean_t allow_indirect, wrap_enabled, verboselog, local_only;
87 
88 #define	svc_getgencaller(transp) \
89 	((struct sockaddr_gen *)svc_getrpccaller((transp))->buf)
90 
91 #define	RPCB_CHECK(xprt, proc) \
92 	if ((wrap_enabled || local_only) && \
93 	    !rpcb_check((xprt), (proc), B_FALSE)) \
94 		return
95 
96 #define	PMAP_CHECK(xprt, proc) \
97 	if ((wrap_enabled || local_only) && \
98 	    !rpcb_check((xprt), (proc), B_TRUE)) \
99 		return
100 
101 #define	PMAP_CHECK_RET(xprt, proc, ret) \
102 	if ((wrap_enabled || local_only) && \
103 	    !rpcb_check((xprt), (proc), B_TRUE)) \
104 		return (ret)
105 
106 #define	RPCB_LOG(xprt, proc, prog) \
107 	if (wrap_enabled) \
108 	    rpcb_log(B_TRUE, (xprt), (proc), (prog), B_FALSE)
109 
110 #define	PMAP_LOG(ans, xprt, proc, prog) \
111 	if (wrap_enabled) \
112 	    rpcb_log(ans, (xprt), (proc), (prog), B_TRUE)
113 
114 extern bool_t map_set(), map_unset();
115 
116 /* Statistics gathering functions */
117 extern void rpcbs_procinfo();
118 extern void rpcbs_set();
119 extern void rpcbs_unset();
120 extern void rpcbs_getaddr();
121 extern void rpcbs_rmtcall();
122 extern rpcb_stat_byvers *rpcbproc_getstat();
123 
124 extern struct netconfig *rpcbind_get_conf();
125 extern void rpcbind_abort() __NORETURN;
126 
127 /* Common functions shared between versions */
128 extern void rpcbproc_callit_com();
129 extern bool_t *rpcbproc_set_com();
130 extern bool_t *rpcbproc_unset_com();
131 extern ulong_t *rpcbproc_gettime_com();
132 extern struct netbuf *rpcbproc_uaddr2taddr_com();
133 extern char **rpcbproc_taddr2uaddr_com();
134 extern char **rpcbproc_getaddr_com();
135 extern void delete_prog();
136 
137 extern uid_t rpcb_caller_uid(SVCXPRT *);
138 
139 /* For different getaddr semantics */
140 #define	RPCB_ALLVERS 0
141 #define	RPCB_ONEVERS 1
142 
143 #ifdef	__cplusplus
144 }
145 #endif
146 
147 #endif /* _RPCBIND_H */
148