rpcbind.h revision 258564
174462Salfred/*	$NetBSD: rpcbind.h,v 1.1 2000/06/03 00:47:21 fvdl Exp $	*/
274462Salfred/*	$FreeBSD: head/usr.sbin/rpcbind/rpcbind.h 258564 2013-11-25 16:44:02Z hrs $ */
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;
6974462Salfredextern int verboselog;
7074462Salfredextern int insecure;
7174462Salfredextern int oldstyle_local;
7274462Salfredextern rpcblist_ptr list_rbl;	/* A list of version 3 & 4 rpcbind services */
7374462Salfred
7474462Salfred#ifdef PORTMAP
7574462Salfredextern struct pmaplist *list_pml; /* A list of version 2 rpcbind services */
7674462Salfredextern char *udptrans;		/* Name of UDP transport */
7774462Salfredextern char *tcptrans;		/* Name of TCP transport */
7874462Salfredextern char *udp_uaddr;		/* Universal UDP address */
7974462Salfredextern char *tcp_uaddr;		/* Universal TCP address */
8074462Salfred#endif
8174462Salfred
82173412Skevloint add_bndlist(struct netconfig *, struct netbuf *);
83173412Skevlobool_t is_bound(char *, char *);
84173412Skevlochar *mergeaddr(SVCXPRT *, char *, char *, char *);
85173412Skevlostruct netconfig *rpcbind_get_conf(char *);
8674462Salfred
87173412Skevlovoid rpcbs_init(void);
88173412Skevlovoid rpcbs_procinfo(rpcvers_t, rpcproc_t);
89173412Skevlovoid rpcbs_set(rpcvers_t, bool_t);
90173412Skevlovoid rpcbs_unset(rpcvers_t, bool_t);
91173412Skevlovoid rpcbs_getaddr(rpcvers_t, rpcprog_t, rpcvers_t, char *, char *);
92173412Skevlovoid rpcbs_rmtcall(rpcvers_t, rpcproc_t, rpcprog_t, rpcvers_t, rpcproc_t,
93173412Skevlo			char *, rpcblist_ptr);
94173412Skevlovoid *rpcbproc_getstat(void *, struct svc_req *, SVCXPRT *, rpcvers_t);
9574462Salfred
96173412Skevlovoid rpcb_service_3(struct svc_req *, SVCXPRT *);
97173412Skevlovoid rpcb_service_4(struct svc_req *, SVCXPRT *);
9874462Salfred
9974462Salfred/* Common functions shared between versions */
100173412Skevlovoid *rpcbproc_set_com(void *, struct svc_req *, SVCXPRT *, rpcvers_t);
101173412Skevlovoid *rpcbproc_unset_com(void *, struct svc_req *, SVCXPRT *, rpcvers_t);
102173412Skevlobool_t map_set(RPCB *, char *);
103173412Skevlobool_t map_unset(RPCB *, char *);
104173412Skevlovoid delete_prog(unsigned int);
105173412Skevlovoid *rpcbproc_getaddr_com(RPCB *, struct svc_req *, SVCXPRT *, rpcvers_t,
106173412Skevlo				 rpcvers_t);
107173412Skevlovoid *rpcbproc_gettime_com(void *, struct svc_req *, SVCXPRT *,
108173412Skevlo				rpcvers_t);
109173412Skevlovoid *rpcbproc_uaddr2taddr_com(void *, struct svc_req *,
110173412Skevlo					     SVCXPRT *, rpcvers_t);
111173412Skevlovoid *rpcbproc_taddr2uaddr_com(void *, struct svc_req *, SVCXPRT *,
112173412Skevlo				    rpcvers_t);
113173412Skevloint create_rmtcall_fd(struct netconfig *);
114173412Skevlovoid rpcbproc_callit_com(struct svc_req *, SVCXPRT *, rpcvers_t,
115173412Skevlo			      rpcvers_t);
116173412Skevlovoid my_svc_run(void);
11774462Salfred
118173412Skevlovoid rpcbind_abort(void);
119173412Skevlovoid reap(int);
120173412Skevlovoid toggle_verboselog(int);
12174462Salfred
122173412Skevloint check_access(SVCXPRT *, rpcproc_t, void *, unsigned int);
123173412Skevloint check_callit(SVCXPRT *, struct r_rmtcall_args *, int);
124173412Skevlovoid logit(int, struct sockaddr *, rpcproc_t, rpcprog_t, const char *);
125173412Skevloint is_loopback(struct netbuf *);
12674462Salfred
12774462Salfred#ifdef PORTMAP
128173412Skevloextern void pmap_service(struct svc_req *, SVCXPRT *);
12974462Salfred#endif
13074462Salfred
131173412Skevlovoid write_warmstart(void);
132173412Skevlovoid read_warmstart(void);
13374462Salfred
134173412Skevlochar *addrmerge(struct netbuf *caller, char *serv_uaddr, char *clnt_uaddr,
135173412Skevlo		     char *netid);
136203710Simpint listen_addr(const struct sockaddr *sa);
137173412Skevlovoid network_init(void);
138173412Skevlostruct sockaddr *local_sa(int);
13974462Salfred
14074462Salfred/* For different getaddr semantics */
14174462Salfred#define	RPCB_ALLVERS 0
14274462Salfred#define	RPCB_ONEVERS 1
14374462Salfred
144203710Simp/* To convert a struct sockaddr to IPv4 or IPv6 address */
145203710Simp#define	SA2SIN(sa)	((struct sockaddr_in *)(sa))
146203710Simp#define	SA2SINADDR(sa)	(SA2SIN(sa)->sin_addr)
147203710Simp#ifdef INET6
148203710Simp#define	SA2SIN6(sa)	((struct sockaddr_in6 *)(sa))
149203710Simp#define	SA2SIN6ADDR(sa)	(SA2SIN6(sa)->sin6_addr)
150203710Simp#endif
151203710Simp
15274462Salfred#endif /* rpcbind_h */
153