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