]> git.decadent.org.uk Git - nfs-utils.git/blob - support/include/nfsrpc.h
543c35bc9fdc8901395c6ae378b46ec182ab8bc9
[nfs-utils.git] / support / include / nfsrpc.h
1 /*
2  * nfsrpc.h -- RPC client APIs provided by support/nfs
3  *
4  * Copyright (C) 2008 Oracle Corporation.  All rights reserved.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public
17  * License along with this program; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 021110-1307, USA.
20  *
21  */
22
23 #ifndef __NFS_UTILS_NFSRPC_H
24 #define __NFS_UTILS_NFSRPC_H
25
26 #include <rpc/types.h>
27 #include <rpc/clnt.h>
28
29 /*
30  * Conventional RPC program numbers
31  */
32 #ifndef RPCBPROG
33 #define RPCBPROG        ((rpcprog_t)100000)
34 #endif
35 #ifndef PMAPPROG
36 #define PMAPPROG        ((rpcprog_t)100000)
37 #endif
38
39 #ifndef NFSPROG
40 #define NFSPROG         ((rpcprog_t)100003)
41 #endif
42 #ifndef MOUNTPROG
43 #define MOUNTPROG       ((rpcprog_t)100005)
44 #endif
45 #ifndef NLMPROG
46 #define NLMPROG         ((rpcprog_t)100021)
47 #endif
48 #ifndef NSMPROG
49 #define NSMPROG         ((rpcprog_t)100024)
50 #endif
51
52 /*
53  * Look up an RPC program name in /etc/rpc
54  */
55 extern rpcprog_t        nfs_getrpcbyname(const rpcprog_t, const char *table[]);
56
57 /*
58  * Acquire an RPC CLIENT * with an ephemeral source port
59  */
60 extern CLIENT           *nfs_get_rpcclient(const struct sockaddr *,
61                                 const socklen_t, const unsigned short,
62                                 const rpcprog_t, const rpcvers_t,
63                                 struct timeval *);
64
65 /*
66  * Acquire an RPC CLIENT * with a privileged source port
67  */
68 extern CLIENT           *nfs_get_priv_rpcclient( const struct sockaddr *,
69                                 const socklen_t, const unsigned short,
70                                 const rpcprog_t, const rpcvers_t,
71                                 struct timeval *);
72
73 /*
74  * Convert a socket address to a universal address
75  */
76 extern char             *nfs_sockaddr2universal(const struct sockaddr *,
77                                 const socklen_t);
78
79 /*
80  * Extract port number from a universal address
81  */
82 extern int              nfs_universal2port(const char *);
83
84 /*
85  * Generic function that maps an RPC service tuple to an IP port
86  * number of the service on a remote post, and sends a NULL
87  * request to determine if the service is responding to requests
88  */
89 extern int              nfs_getport_ping(struct sockaddr *sap,
90                                 const socklen_t salen,
91                                 const rpcprog_t program,
92                                 const rpcvers_t version,
93                                 const unsigned short protocol);
94
95 /*
96  * Generic function that maps an RPC service tuple to an IP port
97  * number of the service on a remote host
98  */
99 extern unsigned short   nfs_getport(const struct sockaddr *,
100                                 const socklen_t, const rpcprog_t,
101                                 const rpcvers_t, const unsigned short);
102
103 /*
104  * Generic function that maps an RPC service tuple to an IP port
105  * number of the service on the local host
106  */
107 extern unsigned short   nfs_getlocalport(const rpcprot_t,
108                                 const rpcvers_t, const unsigned short);
109
110 /*
111  * Function to invoke an rpcbind v3/v4 GETADDR request
112  */
113 extern unsigned short   nfs_rpcb_getaddr(const struct sockaddr *,
114                                 const socklen_t,
115                                 const unsigned short,
116                                 const struct sockaddr *,
117                                 const socklen_t,
118                                 const rpcprog_t,
119                                 const rpcvers_t,
120                                 const unsigned short,
121                                 const struct timeval *);
122
123 /*
124  * Function to invoke a portmap GETPORT request
125  */
126 extern unsigned long    nfs_pmap_getport(const struct sockaddr_in *,
127                                 const unsigned short,
128                                 const unsigned long,
129                                 const unsigned long,
130                                 const unsigned long,
131                                 const struct timeval *);
132
133 /*
134  * Contact a remote RPC service to discover whether it is responding
135  * to requests.
136  */
137 extern int              nfs_rpc_ping(const struct sockaddr *sap,
138                                 const socklen_t salen,
139                                 const rpcprog_t program,
140                                 const rpcvers_t version,
141                                 const unsigned short protocol,
142                                 const struct timeval *timeout);
143
144 #endif  /* __NFS_UTILS_NFSRPC_H */