]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - utils/statd/rmtcall.c
Detect if glibc provides socklen_t and use that instead
[nfs-utils.git] / utils / statd / rmtcall.c
index a45705b02433aa900e2be558e11fa6f151f4c5bf..35cbccb54029fabdbb068a366c7d25000bbc4212 100644 (file)
@@ -20,7 +20,9 @@
  * it won't if it's worth its money).
  */
 
-#include "config.h"
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netdb.h>
 #include <string.h>
 #include <unistd.h>
+#ifdef HAVE_IFADDRS_H
 #include <ifaddrs.h>
+#endif /* HAVE_IFADDRS_H */
 #include "sm_inter.h"
 #include "statd.h"
 #include "notlist.h"
 #include "log.h"
 #include "ha-callout.h"
 
+#if SIZEOF_SOCKLEN_T - 0 == 0
+#define socklen_t int
+#endif
+
 #define MAXMSGSIZE     (2048 / sizeof(unsigned int))
 
 static unsigned long   xid = 0;        /* RPC XID counter */
@@ -92,6 +100,8 @@ statd_get_socket(int port)
 out_success:
        return sockfd;
 }
+
+#ifdef HAVE_IFADDRS_H
 /*
  * Using the NL_ADDR(lp), reset (if needed) the hostname
  * that will be put in the SM_NOTIFY to the hostname
@@ -136,6 +146,7 @@ reset_my_name(notify_list *lp)
        }
        return;
 }
+#endif /* HAVE_IFADDRS_H */
 /*
  * Try to resolve host name for notify/callback request
  *
@@ -271,7 +282,7 @@ recv_rply(int sockfd, struct sockaddr_in *sin, u_long *portp)
        struct rpc_msg          mesg;
        notify_list             *lp = NULL;
        XDR                     xdr, *xdrs = &xdr;
-       int                     alen = sizeof(*sin);
+       socklen_t               alen = sizeof(*sin);
 
        /* Receive message */
        if ((msglen = recvfrom(sockfd, msgbuf, sizeof(msgbuf), 0,
@@ -377,9 +388,10 @@ process_entry(int sockfd, notify_list *lp)
                 * set the NL_MY_NAME(lp) hostname to the 
                 * one associated with the network interface
                 */
+#ifdef HAVE_IFADDRS_H
                if (!(run_mode & STATIC_HOSTNAME))
                        reset_my_name(lp);
-
+#endif /* HAVE_IFADDRS_H */
                func = (xdrproc_t) xdr_stat_chge;
                new_stat.state = MY_STATE;
                new_stat.mon_name = NL_MY_NAME(lp);