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