]> git.decadent.org.uk Git - nfs-utils.git/blob - support/include/nfsrpc.h
1529d447d28dcadb5294e8c85c1fcdfa77c61d31
[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
28 /*
29  * Conventional RPC program numbers
30  */
31 #ifndef RPCBPROG
32 #define RPCBPROG        ((rpcprog_t)100000)
33 #endif
34 #ifndef PMAPPROG
35 #define PMAPPROG        ((rpcprog_t)100000)
36 #endif
37
38 #ifndef NFSPROG
39 #define NFSPROG         ((rpcprog_t)100003)
40 #endif
41 #ifndef MOUNTPROG
42 #define MOUNTPROG       ((rpcprog_t)100005)
43 #endif
44 #ifndef NLMPROG
45 #define NLMPROG         ((rpcprog_t)100021)
46 #endif
47 #ifndef NSMPROG
48 #define NSMPROG         ((rpcprog_t)100024)
49 #endif
50
51 /*
52  * Look up an RPC program name in /etc/rpc
53  */
54 extern rpcprog_t        nfs_getrpcbyname(const rpcprog_t, const char *table[]);
55
56 /*
57  * Look up a port number in /etc/services for an RPC program
58  */
59 extern unsigned short   nfs_getportbynumber(const rpcprog_t program,
60                                 const unsigned short transport);
61
62 /*
63  * Acquire an RPC CLIENT *
64  */
65 extern CLIENT           *nfs_get_rpcclient(const struct sockaddr *,
66                                 const socklen_t, const unsigned short,
67                                 const rpcprog_t, const rpcvers_t,
68                                 struct timeval *);
69
70 /*
71  * Convert a socket address to a universal address
72  */
73 extern char             *nfs_sockaddr2universal(const struct sockaddr *,
74                                 const socklen_t);
75
76 /*
77  * Extract port number from a universal address
78  */
79 extern int              nfs_universal2port(const char *);
80
81 /*
82  * Generic function that maps an RPC service tuple to an IP port
83  * number of the service on a remote post, and sends a NULL
84  * request to determine if the service is responding to requests
85  */
86 extern int              nfs_getport_ping(struct sockaddr *sap,
87                                 const socklen_t salen,
88                                 const rpcprog_t program,
89                                 const rpcvers_t version,
90                                 const unsigned short protocol);
91
92 /*
93  * Generic function that maps an RPC service tuple to an IP port
94  * number of the service on a remote host
95  */
96 extern unsigned short   nfs_getport(const struct sockaddr *,
97                                 const socklen_t, const rpcprog_t,
98                                 const rpcvers_t, const unsigned short);
99
100 /*
101  * Generic function that maps an RPC service tuple to an IP port
102  * number of the service on the local host
103  */
104 extern unsigned short   nfs_getlocalport(const rpcprot_t,
105                                 const rpcvers_t, const unsigned short);
106
107 /*
108  * Function to invoke an rpcbind v3/v4 GETADDR request
109  */
110 extern unsigned short   nfs_rpcb_getaddr(const struct sockaddr *,
111                                 const socklen_t,
112                                 const unsigned short,
113                                 const struct sockaddr *,
114                                 const socklen_t,
115                                 const rpcprog_t,
116                                 const rpcvers_t,
117                                 const unsigned short,
118                                 const struct timeval *);
119
120 /*
121  * Function to invoke a portmap GETPORT request
122  */
123 extern unsigned long    nfs_pmap_getport(const struct sockaddr_in *,
124                                 const unsigned short,
125                                 const unsigned long,
126                                 const unsigned long,
127                                 const unsigned long,
128                                 const struct timeval *);
129
130 /*
131  * Contact a remote RPC service to discover whether it is responding
132  * to requests.
133  */
134 extern int              nfs_rpc_ping(const struct sockaddr *sap,
135                                 const socklen_t salen,
136                                 const rpcprog_t program,
137                                 const rpcvers_t version,
138                                 const unsigned short protocol,
139                                 const struct timeval *timeout);
140
141 #endif  /* __NFS_UTILS_NFSRPC_H */