1 /* $NetBSD: rpcbind.h,v 1.1 2000/06/03 00:47:21 fvdl Exp $ */
5 * SPDX-License-Identifier: BSD-3-Clause
7 * Copyright (c) 2009, Sun Microsystems, Inc.
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.
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.
34 * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc.
37 /* #ident "@(#)rpcbind.h 1.4 90/04/12 SMI" */
41 * The common header declarations
50 #include <rpc/pmap_prot.h>
52 #include <rpc/rpcb_prot.h>
55 * Stuff for the rmtcall service
62 struct r_rmtcall_args {
66 int rmt_localvers; /* whether to send port # or uaddr */
68 struct encap_parms rmt_args;
73 extern int terminate_rfd;
74 extern volatile sig_atomic_t doterminate;
78 extern int verboselog;
80 extern int oldstyle_local;
81 extern rpcblist_ptr list_rbl; /* A list of version 3 & 4 rpcbind services */
82 extern int rpcbindlockfd;
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 */
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 *);
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);
106 void rpcb_service_3(struct svc_req *, SVCXPRT *);
107 void rpcb_service_4(struct svc_req *, SVCXPRT *);
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,
117 void *rpcbproc_gettime_com(void *, struct svc_req *, SVCXPRT *,
119 void *rpcbproc_uaddr2taddr_com(void *, struct svc_req *,
120 SVCXPRT *, rpcvers_t);
121 void *rpcbproc_taddr2uaddr_com(void *, struct svc_req *, SVCXPRT *,
123 int create_rmtcall_fd(struct netconfig *);
124 void rpcbproc_callit_com(struct svc_req *, SVCXPRT *, rpcvers_t,
126 void my_svc_run(void);
128 void rpcbind_abort(void);
130 void toggle_verboselog(int);
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 *);
138 extern void pmap_service(struct svc_req *, SVCXPRT *);
141 void write_warmstart(void);
142 void read_warmstart(void);
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);
150 /* For different getaddr semantics */
151 #define RPCB_ALLVERS 0
152 #define RPCB_ONEVERS 1
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)
158 #define SA2SIN6(sa) ((struct sockaddr_in6 *)(sa))
159 #define SA2SIN6ADDR(sa) (SA2SIN6(sa)->sin6_addr)
162 #endif /* rpcbind_h */