X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=support%2Fnfs%2Fconn.c;h=89f767676b2aeb5f85d0b485c6865b6f5837c2bb;hb=b0c3cbfee702c019dab0a22557bbf38e24dfcee1;hp=a020394c86b7dc1541b58b3dcd823eaeefe8d6ff;hpb=4e2bae795e5eaf9922f0b966ab5df64994c836a2;p=nfs-utils.git diff --git a/support/nfs/conn.c b/support/nfs/conn.c index a020394..89f7676 100644 --- a/support/nfs/conn.c +++ b/support/nfs/conn.c @@ -6,7 +6,9 @@ * */ +#include "config.h" #include +#include #include #include #include @@ -17,6 +19,10 @@ #include "conn.h" +#if SIZEOF_SOCKLEN_T - 0 == 0 +#define socklen_t int +#endif + extern int verbose; /* Map an NFS version into the corresponding Mountd version */ @@ -92,7 +98,7 @@ int get_socket(struct sockaddr_in *saddr, u_int p_prot, int resvp) return RPC_ANYSOCK; } } - if (type == SOCK_STREAM) { + if (type == SOCK_STREAM || type == SOCK_DGRAM) { cc = connect(so, (struct sockaddr *)saddr, namelen); if (cc < 0) { rpc_createerr.cf_stat = RPC_SYSTEMERROR; @@ -118,7 +124,7 @@ int get_socket(struct sockaddr_in *saddr, u_int p_prot, int resvp) */ int clnt_ping(struct sockaddr_in *saddr, const u_long prog, const u_long vers, - const u_int prot) + const u_int prot, struct sockaddr_in *caddr) { CLIENT *clnt=NULL; int sock, stat; @@ -160,8 +166,15 @@ clnt_ping(struct sockaddr_in *saddr, const u_long prog, const u_long vers, rpc_createerr.cf_stat = stat; } clnt_destroy(clnt); - if (sock != -1) + if (sock != -1) { + 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; + } close(sock); + } if (stat == RPC_SUCCESS) return 1;