]> git.decadent.org.uk Git - nfs-utils.git/blob - support/include/nfsrpc.h
Merge branch 'upstream'
[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.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 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  * IANA does not define an IP protocol number for RDMA transports.
31  * Choose an arbitrary value we can use locally.
32  */
33 #define NFSPROTO_RDMA           (3939)
34
35 /*
36  * Conventional RPC program numbers
37  */
38 #ifndef RPCBPROG
39 #define RPCBPROG        ((rpcprog_t)100000)
40 #endif
41 #ifndef PMAPPROG
42 #define PMAPPROG        ((rpcprog_t)100000)
43 #endif
44
45 #ifndef NFSPROG
46 #define NFSPROG         ((rpcprog_t)100003)
47 #endif
48 #ifndef MOUNTPROG
49 #define MOUNTPROG       ((rpcprog_t)100005)
50 #endif
51 #ifndef NLMPROG
52 #define NLMPROG         ((rpcprog_t)100021)
53 #endif
54 #ifndef NSMPROG
55 #define NSMPROG         ((rpcprog_t)100024)
56 #endif
57
58 /**
59  * nfs_clear_rpc_createerr - zap all error reporting fields
60  *
61  */
62 static inline void nfs_clear_rpc_createerr(void)
63 {
64         memset(&rpc_createerr, 0, sizeof(rpc_createerr));
65 }
66
67 /*
68  * Look up an RPC program name in /etc/rpc
69  */
70 extern rpcprog_t        nfs_getrpcbyname(const rpcprog_t, const char *table[]);
71
72 /*
73  * Acquire an RPC CLIENT * with an ephemeral source port
74  */
75 extern CLIENT           *nfs_get_rpcclient(const struct sockaddr *,
76                                 const socklen_t, const unsigned short,
77                                 const rpcprog_t, const rpcvers_t,
78                                 struct timeval *);
79
80 /*
81  * Acquire an RPC CLIENT * with a privileged source port
82  */
83 extern CLIENT           *nfs_get_priv_rpcclient( const struct sockaddr *,
84                                 const socklen_t, const unsigned short,
85                                 const rpcprog_t, const rpcvers_t,
86                                 struct timeval *);
87
88 /*
89  * Convert a netid to a protocol number and protocol family
90  */
91 extern int              nfs_get_proto(const char *netid, sa_family_t *family,
92                                 unsigned long *protocol);
93
94 /*
95  * Convert a protocol family and protocol name to a netid
96  */
97 extern char             *nfs_get_netid(const sa_family_t family,
98                                 const unsigned long protocol);
99
100 /*
101  * Convert a socket address to a universal address
102  */
103 extern char             *nfs_sockaddr2universal(const struct sockaddr *);
104
105 /*
106  * Extract port number from a universal address
107  */
108 extern int              nfs_universal2port(const char *);
109
110 /*
111  * Generic function that maps an RPC service tuple to an IP port
112  * number of the service on a remote post, and sends a NULL
113  * request to determine if the service is responding to requests
114  */
115 extern int              nfs_getport_ping(struct sockaddr *sap,
116                                 const socklen_t salen,
117                                 const rpcprog_t program,
118                                 const rpcvers_t version,
119                                 const unsigned short protocol);
120
121 /*
122  * Generic function that maps an RPC service tuple to an IP port
123  * number of the service on a remote host
124  */
125 extern unsigned short   nfs_getport(const struct sockaddr *,
126                                 const socklen_t, const rpcprog_t,
127                                 const rpcvers_t, const unsigned short);
128
129 /*
130  * Generic function that maps an RPC service tuple to an IP port
131  * number of the service on the local host
132  */
133 extern unsigned short   nfs_getlocalport(const rpcprot_t,
134                                 const rpcvers_t, const unsigned short);
135
136 /*
137  * Function to invoke an rpcbind v3/v4 GETADDR request
138  */
139 extern unsigned short   nfs_rpcb_getaddr(const struct sockaddr *,
140                                 const socklen_t,
141                                 const unsigned short,
142                                 const struct sockaddr *,
143                                 const rpcprog_t,
144                                 const rpcvers_t,
145                                 const unsigned short,
146                                 const struct timeval *);
147
148 /*
149  * Function to invoke a portmap GETPORT request
150  */
151 extern unsigned long    nfs_pmap_getport(const struct sockaddr_in *,
152                                 const unsigned short,
153                                 const unsigned long,
154                                 const unsigned long,
155                                 const unsigned long,
156                                 const struct timeval *);
157
158 /*
159  * Contact a remote RPC service to discover whether it is responding
160  * to requests.
161  */
162 extern int              nfs_rpc_ping(const struct sockaddr *sap,
163                                 const socklen_t salen,
164                                 const rpcprog_t program,
165                                 const rpcvers_t version,
166                                 const unsigned short protocol,
167                                 const struct timeval *timeout);
168
169 /* create AUTH_SYS handle with no supplemental groups */
170 extern AUTH *                    nfs_authsys_create(void);
171
172 #endif  /* !__NFS_UTILS_NFSRPC_H */