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