174462Salfred/*	$NetBSD: rpcbind.h,v 1.1 2000/06/03 00:47:21 fvdl Exp $	*/
274462Salfred/*	$FreeBSD$ */
374462Salfred
4258564Shrs/*-
5258564Shrs * Copyright (c) 2009, Sun Microsystems, Inc.
6258564Shrs * All rights reserved.
7258564Shrs *
8258564Shrs * Redistribution and use in source and binary forms, with or without
9258564Shrs * modification, are permitted provided that the following conditions are met:
10258564Shrs * - Redistributions of source code must retain the above copyright notice,
11258564Shrs *   this list of conditions and the following disclaimer.
12258564Shrs * - Redistributions in binary form must reproduce the above copyright notice,
13258564Shrs *   this list of conditions and the following disclaimer in the documentation
14258564Shrs *   and/or other materials provided with the distribution.
15258564Shrs * - Neither the name of Sun Microsystems, Inc. nor the names of its
16258564Shrs *   contributors may be used to endorse or promote products derived
17258564Shrs *   from this software without specific prior written permission.
18258564Shrs *
19258564Shrs * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20258564Shrs * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21258564Shrs * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22258564Shrs * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23258564Shrs * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24258564Shrs * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25258564Shrs * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26258564Shrs * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27258564Shrs * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28258564Shrs * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29258564Shrs * POSSIBILITY OF SUCH DAMAGE.
3074462Salfred */
3174462Salfred/*
3274462Salfred * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc.
3374462Salfred */
3474462Salfred
3574462Salfred/* #ident	"@(#)rpcbind.h 1.4 90/04/12 SMI" */
3674462Salfred
3774462Salfred/*
3874462Salfred * rpcbind.h
3974462Salfred * The common header declarations
4074462Salfred */
4174462Salfred
4274462Salfred#ifndef rpcbind_h
4374462Salfred#define	rpcbind_h
4474462Salfred
4574462Salfred#ifdef PORTMAP
4674462Salfred#include <rpc/pmap_prot.h>
4774462Salfred#endif
4874462Salfred#include <rpc/rpcb_prot.h>
4974462Salfred
5074462Salfred/*
5174462Salfred * Stuff for the rmtcall service
5274462Salfred */
5374462Salfredstruct encap_parms {
5474462Salfred	u_int32_t arglen;
5574462Salfred	char *args;
5674462Salfred};
5774462Salfred
5874462Salfredstruct r_rmtcall_args {
5974462Salfred	u_int32_t  rmt_prog;
6074462Salfred	u_int32_t  rmt_vers;
6174462Salfred	u_int32_t  rmt_proc;
6274462Salfred	int     rmt_localvers;  /* whether to send port # or uaddr */
6374462Salfred	char    *rmt_uaddr;
6474462Salfred	struct encap_parms rmt_args;
6574462Salfred};
6674462Salfred
6774462Salfredextern int debugging;
6874462Salfredextern int doabort;
69262860Smav#ifdef LIBWRAP
70262860Smavextern int libwrap;
71262860Smav#endif
7274462Salfredextern int verboselog;
7374462Salfredextern int insecure;
7474462Salfredextern int oldstyle_local;
7574462Salfredextern rpcblist_ptr list_rbl;	/* A list of version 3 & 4 rpcbind services */
7674462Salfred
7774462Salfred#ifdef PORTMAP
7874462Salfredextern struct pmaplist *list_pml; /* A list of version 2 rpcbind services */
7974462Salfredextern char *udptrans;		/* Name of UDP transport */
8074462Salfredextern char *tcptrans;		/* Name of TCP transport */
8174462Salfredextern char *udp_uaddr;		/* Universal UDP address */
8274462Salfredextern char *tcp_uaddr;		/* Universal TCP address */
8374462Salfred#endif
8474462Salfred
85173412Skevloint add_bndlist(struct netconfig *, struct netbuf *);
86173412Skevlobool_t is_bound(char *, char *);
87173412Skevlochar *mergeaddr(SVCXPRT *, char *, char *, char *);
88293229Sasomersstruct netconfig *rpcbind_get_conf(const char *);
8974462Salfred
90173412Skevlovoid rpcbs_init(void);
91173412Skevlovoid rpcbs_procinfo(rpcvers_t, rpcproc_t);
92173412Skevlovoid rpcbs_set(rpcvers_t, bool_t);
93173412Skevlovoid rpcbs_unset(rpcvers_t, bool_t);
94173412Skevlovoid rpcbs_getaddr(rpcvers_t, rpcprog_t, rpcvers_t, char *, char *);
95173412Skevlovoid rpcbs_rmtcall(rpcvers_t, rpcproc_t, rpcprog_t, rpcvers_t, rpcproc_t,
96173412Skevlo			char *, rpcblist_ptr);
97173412Skevlovoid *rpcbproc_getstat(void *, struct svc_req *, SVCXPRT *, rpcvers_t);
9874462Salfred
99173412Skevlovoid rpcb_service_3(struct svc_req *, SVCXPRT *);
100173412Skevlovoid rpcb_service_4(struct svc_req *, SVCXPRT *);
10174462Salfred
10274462Salfred/* Common functions shared between versions */
103173412Skevlovoid *rpcbproc_set_com(void *, struct svc_req *, SVCXPRT *, rpcvers_t);
104173412Skevlovoid *rpcbproc_unset_com(void *, struct svc_req *, SVCXPRT *, rpcvers_t);
105173412Skevlobool_t map_set(RPCB *, char *);
106173412Skevlobool_t map_unset(RPCB *, char *);
107173412Skevlovoid delete_prog(unsigned int);
108173412Skevlovoid *rpcbproc_getaddr_com(RPCB *, struct svc_req *, SVCXPRT *, rpcvers_t,
109173412Skevlo				 rpcvers_t);
110173412Skevlovoid *rpcbproc_gettime_com(void *, struct svc_req *, SVCXPRT *,
111173412Skevlo				rpcvers_t);
112173412Skevlovoid *rpcbproc_uaddr2taddr_com(void *, struct svc_req *,
113173412Skevlo					     SVCXPRT *, rpcvers_t);
114173412Skevlovoid *rpcbproc_taddr2uaddr_com(void *, struct svc_req *, SVCXPRT *,
115173412Skevlo				    rpcvers_t);
116173412Skevloint create_rmtcall_fd(struct netconfig *);
117173412Skevlovoid rpcbproc_callit_com(struct svc_req *, SVCXPRT *, rpcvers_t,
118173412Skevlo			      rpcvers_t);
119173412Skevlovoid my_svc_run(void);
12074462Salfred
121173412Skevlovoid rpcbind_abort(void);
122173412Skevlovoid reap(int);
123173412Skevlovoid toggle_verboselog(int);
12474462Salfred
125173412Skevloint check_access(SVCXPRT *, rpcproc_t, void *, unsigned int);
126173412Skevloint check_callit(SVCXPRT *, struct r_rmtcall_args *, int);
127173412Skevlovoid logit(int, struct sockaddr *, rpcproc_t, rpcprog_t, const char *);
128173412Skevloint is_loopback(struct netbuf *);
12974462Salfred
13074462Salfred#ifdef PORTMAP
131173412Skevloextern void pmap_service(struct svc_req *, SVCXPRT *);
13274462Salfred#endif
13374462Salfred
134173412Skevlovoid write_warmstart(void);
135173412Skevlovoid read_warmstart(void);
13674462Salfred
137293229Sasomerschar *addrmerge(struct netbuf *caller, const char *serv_uaddr,
138293229Sasomers		const char *clnt_uaddr, char const *netid);
139203710Simpint listen_addr(const struct sockaddr *sa);
140173412Skevlovoid network_init(void);
141173412Skevlostruct sockaddr *local_sa(int);
14274462Salfred
14374462Salfred/* For different getaddr semantics */
14474462Salfred#define	RPCB_ALLVERS 0
14574462Salfred#define	RPCB_ONEVERS 1
14674462Salfred
147203710Simp/* To convert a struct sockaddr to IPv4 or IPv6 address */
148203710Simp#define	SA2SIN(sa)	((struct sockaddr_in *)(sa))
149203710Simp#define	SA2SINADDR(sa)	(SA2SIN(sa)->sin_addr)
150203710Simp#ifdef INET6
151203710Simp#define	SA2SIN6(sa)	((struct sockaddr_in6 *)(sa))
152203710Simp#define	SA2SIN6ADDR(sa)	(SA2SIN6(sa)->sin6_addr)
153203710Simp#endif
154203710Simp
15574462Salfred#endif /* rpcbind_h */
156