xref: /trueos/usr.sbin/rpcbind/rpcbind.h (revision 91ec1b5825a6de71aaafbd9eb6ce89022e60e29a)
1 /*	$NetBSD: rpcbind.h,v 1.1 2000/06/03 00:47:21 fvdl Exp $	*/
2 /*	$FreeBSD$ */
3 
4 /*
5  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
6  * unrestricted use provided that this legend is included on all tape
7  * media and as a part of the software program in whole or part.  Users
8  * may copy or modify Sun RPC without charge, but are not authorized
9  * to license or distribute it to anyone else except as part of a product or
10  * program developed by the user.
11  *
12  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
13  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
14  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
15  *
16  * Sun RPC is provided with no support and without any obligation on the
17  * part of Sun Microsystems, Inc. to assist in its use, correction,
18  * modification or enhancement.
19  *
20  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
21  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
22  * OR ANY PART THEREOF.
23  *
24  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
25  * or profits or other special, indirect and consequential damages, even if
26  * Sun has been advised of the possibility of such damages.
27  *
28  * Sun Microsystems, Inc.
29  * 2550 Garcia Avenue
30  * Mountain View, California  94043
31  */
32 /*
33  * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc.
34  */
35 
36 /* #ident	"@(#)rpcbind.h 1.4 90/04/12 SMI" */
37 
38 /*
39  * rpcbind.h
40  * The common header declarations
41  */
42 
43 #ifndef rpcbind_h
44 #define	rpcbind_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 #ifdef LIBWRAP
71 extern int libwrap;
72 #endif
73 extern int verboselog;
74 extern int insecure;
75 extern int oldstyle_local;
76 extern rpcblist_ptr list_rbl;	/* A list of version 3 & 4 rpcbind services */
77 
78 #ifdef PORTMAP
79 extern struct pmaplist *list_pml; /* A list of version 2 rpcbind services */
80 extern char *udptrans;		/* Name of UDP transport */
81 extern char *tcptrans;		/* Name of TCP transport */
82 extern char *udp_uaddr;		/* Universal UDP address */
83 extern char *tcp_uaddr;		/* Universal TCP address */
84 #endif
85 
86 int add_bndlist(struct netconfig *, struct netbuf *);
87 bool_t is_bound(char *, char *);
88 char *mergeaddr(SVCXPRT *, char *, char *, char *);
89 struct netconfig *rpcbind_get_conf(char *);
90 
91 void rpcbs_init(void);
92 void rpcbs_procinfo(rpcvers_t, rpcproc_t);
93 void rpcbs_set(rpcvers_t, bool_t);
94 void rpcbs_unset(rpcvers_t, bool_t);
95 void rpcbs_getaddr(rpcvers_t, rpcprog_t, rpcvers_t, char *, char *);
96 void rpcbs_rmtcall(rpcvers_t, rpcproc_t, rpcprog_t, rpcvers_t, rpcproc_t,
97 			char *, rpcblist_ptr);
98 void *rpcbproc_getstat(void *, struct svc_req *, SVCXPRT *, rpcvers_t);
99 
100 void rpcb_service_3(struct svc_req *, SVCXPRT *);
101 void rpcb_service_4(struct svc_req *, SVCXPRT *);
102 
103 /* Common functions shared between versions */
104 void *rpcbproc_set_com(void *, struct svc_req *, SVCXPRT *, rpcvers_t);
105 void *rpcbproc_unset_com(void *, struct svc_req *, SVCXPRT *, rpcvers_t);
106 bool_t map_set(RPCB *, char *);
107 bool_t map_unset(RPCB *, char *);
108 void delete_prog(unsigned int);
109 void *rpcbproc_getaddr_com(RPCB *, struct svc_req *, SVCXPRT *, rpcvers_t,
110 				 rpcvers_t);
111 void *rpcbproc_gettime_com(void *, struct svc_req *, SVCXPRT *,
112 				rpcvers_t);
113 void *rpcbproc_uaddr2taddr_com(void *, struct svc_req *,
114 					     SVCXPRT *, rpcvers_t);
115 void *rpcbproc_taddr2uaddr_com(void *, struct svc_req *, SVCXPRT *,
116 				    rpcvers_t);
117 int create_rmtcall_fd(struct netconfig *);
118 void rpcbproc_callit_com(struct svc_req *, SVCXPRT *, rpcvers_t,
119 			      rpcvers_t);
120 void my_svc_run(void);
121 
122 void rpcbind_abort(void);
123 void reap(int);
124 void toggle_verboselog(int);
125 
126 int check_access(SVCXPRT *, rpcproc_t, void *, unsigned int);
127 int check_callit(SVCXPRT *, struct r_rmtcall_args *, int);
128 void logit(int, struct sockaddr *, rpcproc_t, rpcprog_t, const char *);
129 int is_loopback(struct netbuf *);
130 
131 #ifdef PORTMAP
132 extern void pmap_service(struct svc_req *, SVCXPRT *);
133 #endif
134 
135 void write_warmstart(void);
136 void read_warmstart(void);
137 
138 char *addrmerge(struct netbuf *caller, char *serv_uaddr, char *clnt_uaddr,
139 		     char *netid);
140 int listen_addr(const struct sockaddr *sa);
141 void network_init(void);
142 struct sockaddr *local_sa(int);
143 
144 /* For different getaddr semantics */
145 #define	RPCB_ALLVERS 0
146 #define	RPCB_ONEVERS 1
147 
148 /* To convert a struct sockaddr to IPv4 or IPv6 address */
149 #define	SA2SIN(sa)	((struct sockaddr_in *)(sa))
150 #define	SA2SINADDR(sa)	(SA2SIN(sa)->sin_addr)
151 #ifdef INET6
152 #define	SA2SIN6(sa)	((struct sockaddr_in6 *)(sa))
153 #define	SA2SIN6ADDR(sa)	(SA2SIN6(sa)->sin6_addr)
154 #endif
155 
156 #endif /* rpcbind_h */
157