X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=support%2Fnfs%2Fconn.c;h=89f767676b2aeb5f85d0b485c6865b6f5837c2bb;hb=b0c3cbfee702c019dab0a22557bbf38e24dfcee1;hp=bf2afad678c71ad3b6e39b740f8745e09d387af8;hpb=93608a52655abf5ac23404c4b5cc05fe575a9c04;p=nfs-utils.git diff --git a/support/nfs/conn.c b/support/nfs/conn.c index bf2afad..89f7676 100644 --- a/support/nfs/conn.c +++ b/support/nfs/conn.c @@ -6,6 +6,7 @@ * */ +#include "config.h" #include #include #include @@ -18,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 */ @@ -93,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; @@ -119,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; @@ -161,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;