*
*/
+#include "config.h"
#include <errno.h>
#include <unistd.h>
#include <rpc/rpc.h>
#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 */
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;
*/
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;
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;