xref: /freebsd/usr.sbin/rpcbind/rpcbind.h (revision 19fae0f66023a97a9b464b3beeeabb2081f575b3)
1 /*	$NetBSD: rpcbind.h,v 1.1 2000/06/03 00:47:21 fvdl Exp $	*/
2 /*	$FreeBSD$ */
3 
4 /*-
5  * SPDX-License-Identifier: BSD-3-Clause
6  *
7  * Copyright (c) 2009, Sun Microsystems, Inc.
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions are met:
12  * - Redistributions of source code must retain the above copyright notice,
13  *   this list of conditions and the following disclaimer.
14  * - Redistributions in binary form must reproduce the above copyright notice,
15  *   this list of conditions and the following disclaimer in the documentation
16  *   and/or other materials provided with the distribution.
17  * - Neither the name of Sun Microsystems, Inc. nor the names of its
18  *   contributors may be used to endorse or promote products derived
19  *   from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 /*
34  * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc.
35  */
36 
37 /* #ident	"@(#)rpcbind.h 1.4 90/04/12 SMI" */
38 
39 /*
40  * rpcbind.h
41  * The common header declarations
42  */
43 
44 #ifndef rpcbind_h
45 #define	rpcbind_h
46 
47 #include <signal.h>
48 
49 #ifdef PORTMAP
50 #include <rpc/pmap_prot.h>
51 #endif
52 #include <rpc/rpcb_prot.h>
53 
54 /*
55  * Stuff for the rmtcall service
56  */
57 struct encap_parms {
58 	u_int32_t arglen;
59 	char *args;
60 };
61 
62 struct r_rmtcall_args {
63 	u_int32_t  rmt_prog;
64 	u_int32_t  rmt_vers;
65 	u_int32_t  rmt_proc;
66 	int     rmt_localvers;  /* whether to send port # or uaddr */
67 	char    *rmt_uaddr;
68 	struct encap_parms rmt_args;
69 };
70 
71 extern int debugging;
72 extern int doabort;
73 extern int terminate_rfd;
74 extern volatile sig_atomic_t doterminate;
75 #ifdef LIBWRAP
76 extern int libwrap;
77 #endif
78 extern int verboselog;
79 extern int insecure;
80 extern int oldstyle_local;
81 extern rpcblist_ptr list_rbl;	/* A list of version 3 & 4 rpcbind services */
82 extern int rpcbindlockfd;
83 
84 #ifdef PORTMAP
85 extern struct pmaplist *list_pml; /* A list of version 2 rpcbind services */
86 extern char *udptrans;		/* Name of UDP transport */
87 extern char *tcptrans;		/* Name of TCP transport */
88 extern char *udp_uaddr;		/* Universal UDP address */
89 extern char *tcp_uaddr;		/* Universal TCP address */
90 #endif
91 
92 int add_bndlist(struct netconfig *, struct netbuf *);
93 bool_t is_bound(char *, char *);
94 char *mergeaddr(SVCXPRT *, char *, char *, char *);
95 struct netconfig *rpcbind_get_conf(const char *);
96 
97 void rpcbs_init(void);
98 void rpcbs_procinfo(rpcvers_t, rpcproc_t);
99 void rpcbs_set(rpcvers_t, bool_t);
100 void rpcbs_unset(rpcvers_t, bool_t);
101 void rpcbs_getaddr(rpcvers_t, rpcprog_t, rpcvers_t, char *, char *);
102 void rpcbs_rmtcall(rpcvers_t, rpcproc_t, rpcprog_t, rpcvers_t, rpcproc_t,
103 			char *, rpcblist_ptr);
104 void *rpcbproc_getstat(void *, struct svc_req *, SVCXPRT *, rpcvers_t);
105 
106 void rpcb_service_3(struct svc_req *, SVCXPRT *);
107 void rpcb_service_4(struct svc_req *, SVCXPRT *);
108 
109 /* Common functions shared between versions */
110 void *rpcbproc_set_com(void *, struct svc_req *, SVCXPRT *, rpcvers_t);
111 void *rpcbproc_unset_com(void *, struct svc_req *, SVCXPRT *, rpcvers_t);
112 bool_t map_set(RPCB *, char *);
113 bool_t map_unset(RPCB *, char *);
114 void delete_prog(unsigned int);
115 void *rpcbproc_getaddr_com(RPCB *, struct svc_req *, SVCXPRT *, rpcvers_t,
116 				 rpcvers_t);
117 void *rpcbproc_gettime_com(void *, struct svc_req *, SVCXPRT *,
118 				rpcvers_t);
119 void *rpcbproc_uaddr2taddr_com(void *, struct svc_req *,
120 					     SVCXPRT *, rpcvers_t);
121 void *rpcbproc_taddr2uaddr_com(void *, struct svc_req *, SVCXPRT *,
122 				    rpcvers_t);
123 int create_rmtcall_fd(struct netconfig *);
124 void rpcbproc_callit_com(struct svc_req *, SVCXPRT *, rpcvers_t,
125 			      rpcvers_t);
126 void my_svc_run(void);
127 
128 void rpcbind_abort(void);
129 void reap(int);
130 void toggle_verboselog(int);
131 
132 int check_access(SVCXPRT *, rpcproc_t, void *, unsigned int);
133 int check_callit(SVCXPRT *, struct r_rmtcall_args *, int);
134 void logit(int, struct sockaddr *, rpcproc_t, rpcprog_t, const char *);
135 int is_loopback(struct netbuf *);
136 
137 #ifdef PORTMAP
138 extern void pmap_service(struct svc_req *, SVCXPRT *);
139 #endif
140 
141 void write_warmstart(void);
142 void read_warmstart(void);
143 
144 char *addrmerge(struct netbuf *caller, const char *serv_uaddr,
145 		const char *clnt_uaddr, char const *netid);
146 int listen_addr(const struct sockaddr *sa);
147 void network_init(void);
148 struct sockaddr *local_sa(int);
149 
150 /* For different getaddr semantics */
151 #define	RPCB_ALLVERS 0
152 #define	RPCB_ONEVERS 1
153 
154 /* To convert a struct sockaddr to IPv4 or IPv6 address */
155 #define	SA2SIN(sa)	((struct sockaddr_in *)(sa))
156 #define	SA2SINADDR(sa)	(SA2SIN(sa)->sin_addr)
157 #ifdef INET6
158 #define	SA2SIN6(sa)	((struct sockaddr_in6 *)(sa))
159 #define	SA2SIN6ADDR(sa)	(SA2SIN6(sa)->sin6_addr)
160 #endif
161 
162 #endif /* rpcbind_h */
163