static const struct timeval TIMEOUT = { 20, 0 };
static const struct timeval RETRY_TIMEOUT = { 3, 0 };
-int clnt_ping(struct sockaddr_in *, const u_long, const u_long, const u_int,
- struct sockaddr_in *);
int get_socket(struct sockaddr_in *, u_int, int, int);
#endif /* _CONN_H */
}
return so;
}
-
-/*
- * Sigh... getport() doesn't actually check the version number.
- * In order to make sure that the server actually supports the service
- * we're requesting, we open and RPC client, and fire off a NULL
- * RPC call.
- */
-int
-clnt_ping(struct sockaddr_in *saddr, const u_long prog, const u_long vers,
- const u_int prot, struct sockaddr_in *caddr)
-{
- CLIENT *clnt=NULL;
- int sock, stat;
- static char clnt_res;
- struct sockaddr dissolve;
-
- rpc_createerr.cf_stat = stat = errno = 0;
- sock = get_socket(saddr, prot, FALSE, TRUE);
- if (sock == RPC_ANYSOCK) {
- if (errno == ETIMEDOUT) {
- /*
- * TCP timeout. Bubble up the error to see
- * how it should be handled.
- */
- rpc_createerr.cf_stat = RPC_TIMEDOUT;
- }
- return 0;
- }
-
- if (caddr) {
- /* Get the address of our end of this connection */
- socklen_t len = sizeof(*caddr);
- if (getsockname(sock, caddr, &len) != 0)
- caddr->sin_family = 0;
- }
-
- switch(prot) {
- case IPPROTO_UDP:
- /* The socket is connected (so we could getsockname successfully),
- * but some servers on multi-homed hosts reply from
- * the wrong address, so if we stay connected, we lose the reply.
- */
- dissolve.sa_family = AF_UNSPEC;
- connect(sock, &dissolve, sizeof(dissolve));
-
- clnt = clntudp_bufcreate(saddr, prog, vers,
- RETRY_TIMEOUT, &sock,
- RPCSMALLMSGSIZE, RPCSMALLMSGSIZE);
- break;
- case IPPROTO_TCP:
- clnt = clnttcp_create(saddr, prog, vers, &sock,
- RPCSMALLMSGSIZE, RPCSMALLMSGSIZE);
- break;
- }
- if (!clnt) {
- close(sock);
- return 0;
- }
- memset(&clnt_res, 0, sizeof(clnt_res));
- stat = clnt_call(clnt, NULLPROC,
- (xdrproc_t)xdr_void, (caddr_t)NULL,
- (xdrproc_t)xdr_void, (caddr_t)&clnt_res,
- TIMEOUT);
- if (stat) {
- clnt_geterr(clnt, &rpc_createerr.cf_error);
- rpc_createerr.cf_stat = stat;
- }
- clnt_destroy(clnt);
- close(sock);
-
- if (stat == RPC_SUCCESS)
- return 1;
- else
- return 0;
-}
#define NFS_PORT 2049
#endif
+#if SIZEOF_SOCKLEN_T - 0 == 0
+#define socklen_t unsigned int
+#endif
+
extern int nfs_mount_data_version;
extern char *progname;
extern int verbose;
clnt_destroy(clnt);
close(msock);
}
+
+/*
+ * Sigh... getport() doesn't actually check the version number.
+ * In order to make sure that the server actually supports the service
+ * we're requesting, we open and RPC client, and fire off a NULL
+ * RPC call.
+ */
+int clnt_ping(struct sockaddr_in *saddr, const unsigned long prog,
+ const unsigned long vers, const unsigned int prot,
+ struct sockaddr_in *caddr)
+{
+ CLIENT *clnt = NULL;
+ int sock, stat;
+ static char clnt_res;
+ struct sockaddr dissolve;
+
+ rpc_createerr.cf_stat = stat = errno = 0;
+ sock = get_socket(saddr, prot, FALSE, TRUE);
+ if (sock == RPC_ANYSOCK) {
+ if (errno == ETIMEDOUT) {
+ /*
+ * TCP timeout. Bubble up the error to see
+ * how it should be handled.
+ */
+ rpc_createerr.cf_stat = RPC_TIMEDOUT;
+ }
+ return 0;
+ }
+
+ if (caddr) {
+ /* Get the address of our end of this connection */
+ socklen_t len = sizeof(*caddr);
+ if (getsockname(sock, caddr, &len) != 0)
+ caddr->sin_family = 0;
+ }
+
+ switch(prot) {
+ case IPPROTO_UDP:
+ /* The socket is connected (so we could getsockname successfully),
+ * but some servers on multi-homed hosts reply from
+ * the wrong address, so if we stay connected, we lose the reply.
+ */
+ dissolve.sa_family = AF_UNSPEC;
+ connect(sock, &dissolve, sizeof(dissolve));
+
+ clnt = clntudp_bufcreate(saddr, prog, vers,
+ RETRY_TIMEOUT, &sock,
+ RPCSMALLMSGSIZE, RPCSMALLMSGSIZE);
+ break;
+ case IPPROTO_TCP:
+ clnt = clnttcp_create(saddr, prog, vers, &sock,
+ RPCSMALLMSGSIZE, RPCSMALLMSGSIZE);
+ break;
+ }
+ if (!clnt) {
+ close(sock);
+ return 0;
+ }
+ memset(&clnt_res, 0, sizeof(clnt_res));
+ stat = clnt_call(clnt, NULLPROC,
+ (xdrproc_t)xdr_void, (caddr_t)NULL,
+ (xdrproc_t)xdr_void, (caddr_t)&clnt_res,
+ TIMEOUT);
+ if (stat) {
+ clnt_geterr(clnt, &rpc_createerr.cf_error);
+ rpc_createerr.cf_stat = stat;
+ }
+ clnt_destroy(clnt);
+ close(sock);
+
+ if (stat == RPC_SUCCESS)
+ return 1;
+ else
+ return 0;
+}
int probe_bothports(clnt_addr_t *, clnt_addr_t *);
int nfs_gethostbyname(const char *, struct sockaddr_in *);
int nfs_call_umount(clnt_addr_t *, dirpath *);
+int clnt_ping(struct sockaddr_in *, const unsigned long,
+ const unsigned long, const unsigned int,
+ struct sockaddr_in *);
int start_statd(void);
#include "nfs4_mount.h"
#include "nfs_mount.h"
#include "error.h"
+#include "network.h"
#if defined(VAR_LOCK_DIR)
#define DEFAULT_DIR VAR_LOCK_DIR