xref: /freebsd/usr.sbin/rpcbind/rpcbind.h (revision 97cb52fa9aefd90fad38790fded50905aeeb9b9e)
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 #ifdef PORTMAP
48 #include <rpc/pmap_prot.h>
49 #endif
50 #include <rpc/rpcb_prot.h>
51 
52 /*
53  * Stuff for the rmtcall service
54  */
55 struct encap_parms {
56 	u_int32_t arglen;
57 	char *args;
58 };
59 
60 struct r_rmtcall_args {
61 	u_int32_t  rmt_prog;
62 	u_int32_t  rmt_vers;
63 	u_int32_t  rmt_proc;
64 	int     rmt_localvers;  /* whether to send port # or uaddr */
65 	char    *rmt_uaddr;
66 	struct encap_parms rmt_args;
67 };
68 
69 extern int debugging;
70 extern int doabort;
71 #ifdef LIBWRAP
72 extern int libwrap;
73 #endif
74 extern int verboselog;
75 extern int insecure;
76 extern int oldstyle_local;
77 extern rpcblist_ptr list_rbl;	/* A list of version 3 & 4 rpcbind services */
78 
79 #ifdef PORTMAP
80 extern struct pmaplist *list_pml; /* A list of version 2 rpcbind services */
81 extern char *udptrans;		/* Name of UDP transport */
82 extern char *tcptrans;		/* Name of TCP transport */
83 extern char *udp_uaddr;		/* Universal UDP address */
84 extern char *tcp_uaddr;		/* Universal TCP address */
85 #endif
86 
87 int add_bndlist(struct netconfig *, struct netbuf *);
88 bool_t is_bound(char *, char *);
89 char *mergeaddr(SVCXPRT *, char *, char *, char *);
90 struct netconfig *rpcbind_get_conf(const char *);
91 
92 void rpcbs_init(void);
93 void rpcbs_procinfo(rpcvers_t, rpcproc_t);
94 void rpcbs_set(rpcvers_t, bool_t);
95 void rpcbs_unset(rpcvers_t, bool_t);
96 void rpcbs_getaddr(rpcvers_t, rpcprog_t, rpcvers_t, char *, char *);
97 void rpcbs_rmtcall(rpcvers_t, rpcproc_t, rpcprog_t, rpcvers_t, rpcproc_t,
98 			char *, rpcblist_ptr);
99 void *rpcbproc_getstat(void *, struct svc_req *, SVCXPRT *, rpcvers_t);
100 
101 void rpcb_service_3(struct svc_req *, SVCXPRT *);
102 void rpcb_service_4(struct svc_req *, SVCXPRT *);
103 
104 /* Common functions shared between versions */
105 void *rpcbproc_set_com(void *, struct svc_req *, SVCXPRT *, rpcvers_t);
106 void *rpcbproc_unset_com(void *, struct svc_req *, SVCXPRT *, rpcvers_t);
107 bool_t map_set(RPCB *, char *);
108 bool_t map_unset(RPCB *, char *);
109 void delete_prog(unsigned int);
110 void *rpcbproc_getaddr_com(RPCB *, struct svc_req *, SVCXPRT *, rpcvers_t,
111 				 rpcvers_t);
112 void *rpcbproc_gettime_com(void *, struct svc_req *, SVCXPRT *,
113 				rpcvers_t);
114 void *rpcbproc_uaddr2taddr_com(void *, struct svc_req *,
115 					     SVCXPRT *, rpcvers_t);
116 void *rpcbproc_taddr2uaddr_com(void *, struct svc_req *, SVCXPRT *,
117 				    rpcvers_t);
118 int create_rmtcall_fd(struct netconfig *);
119 void rpcbproc_callit_com(struct svc_req *, SVCXPRT *, rpcvers_t,
120 			      rpcvers_t);
121 void my_svc_run(void);
122 
123 void rpcbind_abort(void);
124 void reap(int);
125 void toggle_verboselog(int);
126 
127 int check_access(SVCXPRT *, rpcproc_t, void *, unsigned int);
128 int check_callit(SVCXPRT *, struct r_rmtcall_args *, int);
129 void logit(int, struct sockaddr *, rpcproc_t, rpcprog_t, const char *);
130 int is_loopback(struct netbuf *);
131 
132 #ifdef PORTMAP
133 extern void pmap_service(struct svc_req *, SVCXPRT *);
134 #endif
135 
136 void write_warmstart(void);
137 void read_warmstart(void);
138 
139 char *addrmerge(struct netbuf *caller, const char *serv_uaddr,
140 		const char *clnt_uaddr, char const *netid);
141 int listen_addr(const struct sockaddr *sa);
142 void network_init(void);
143 struct sockaddr *local_sa(int);
144 
145 /* For different getaddr semantics */
146 #define	RPCB_ALLVERS 0
147 #define	RPCB_ONEVERS 1
148 
149 /* To convert a struct sockaddr to IPv4 or IPv6 address */
150 #define	SA2SIN(sa)	((struct sockaddr_in *)(sa))
151 #define	SA2SINADDR(sa)	(SA2SIN(sa)->sin_addr)
152 #ifdef INET6
153 #define	SA2SIN6(sa)	((struct sockaddr_in6 *)(sa))
154 #define	SA2SIN6ADDR(sa)	(SA2SIN6(sa)->sin6_addr)
155 #endif
156 
157 #endif /* rpcbind_h */
158