2 * nfsrpc.h -- RPC client APIs provided by support/nfs
4 * Copyright (C) 2008 Oracle Corporation. All rights reserved.
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.
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.
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.
23 #ifndef __NFS_UTILS_NFSRPC_H
24 #define __NFS_UTILS_NFSRPC_H
26 #include <rpc/types.h>
30 * Conventional RPC program numbers
33 #define RPCBPROG ((rpcprog_t)100000)
36 #define PMAPPROG ((rpcprog_t)100000)
40 #define NFSPROG ((rpcprog_t)100003)
43 #define MOUNTPROG ((rpcprog_t)100005)
46 #define NLMPROG ((rpcprog_t)100021)
49 #define NSMPROG ((rpcprog_t)100024)
53 * nfs_clear_rpc_createerr - zap all error reporting fields
56 static inline void nfs_clear_rpc_createerr(void)
58 memset(&rpc_createerr, 0, sizeof(rpc_createerr));
62 * Extract port value from a socket address
64 extern uint16_t nfs_get_port(const struct sockaddr *);
67 * Set port value in a socket address
69 extern void nfs_set_port(struct sockaddr *, const uint16_t);
72 * Look up an RPC program name in /etc/rpc
74 extern rpcprog_t nfs_getrpcbyname(const rpcprog_t, const char *table[]);
77 * Acquire an RPC CLIENT * with an ephemeral source port
79 extern CLIENT *nfs_get_rpcclient(const struct sockaddr *,
80 const socklen_t, const unsigned short,
81 const rpcprog_t, const rpcvers_t,
85 * Acquire an RPC CLIENT * with a privileged source port
87 extern CLIENT *nfs_get_priv_rpcclient( const struct sockaddr *,
88 const socklen_t, const unsigned short,
89 const rpcprog_t, const rpcvers_t,
93 * Convert a socket address to a universal address
95 extern char *nfs_sockaddr2universal(const struct sockaddr *);
98 * Extract port number from a universal address
100 extern int nfs_universal2port(const char *);
103 * Generic function that maps an RPC service tuple to an IP port
104 * number of the service on a remote post, and sends a NULL
105 * request to determine if the service is responding to requests
107 extern int nfs_getport_ping(struct sockaddr *sap,
108 const socklen_t salen,
109 const rpcprog_t program,
110 const rpcvers_t version,
111 const unsigned short protocol);
114 * Generic function that maps an RPC service tuple to an IP port
115 * number of the service on a remote host
117 extern unsigned short nfs_getport(const struct sockaddr *,
118 const socklen_t, const rpcprog_t,
119 const rpcvers_t, const unsigned short);
122 * Generic function that maps an RPC service tuple to an IP port
123 * number of the service on the local host
125 extern unsigned short nfs_getlocalport(const rpcprot_t,
126 const rpcvers_t, const unsigned short);
129 * Function to invoke an rpcbind v3/v4 GETADDR request
131 extern unsigned short nfs_rpcb_getaddr(const struct sockaddr *,
133 const unsigned short,
134 const struct sockaddr *,
137 const unsigned short,
138 const struct timeval *);
141 * Function to invoke a portmap GETPORT request
143 extern unsigned long nfs_pmap_getport(const struct sockaddr_in *,
144 const unsigned short,
148 const struct timeval *);
151 * Contact a remote RPC service to discover whether it is responding
154 extern int nfs_rpc_ping(const struct sockaddr *sap,
155 const socklen_t salen,
156 const rpcprog_t program,
157 const rpcvers_t version,
158 const unsigned short protocol,
159 const struct timeval *timeout);
161 #endif /* __NFS_UTILS_NFSRPC_H */