dnl We do this in multiple stages, because unlike Linux all the other operating systems really suck and don't include their own dependencies.
AC_HEADER_STDC
-AC_CHECK_HEADERS([stdbool.h syslog.h sys/file.h sys/ioctl.h sys/mman.h sys/param.h sys/resource.h sys/socket.h sys/time.h sys/uio.h sys/un.h sys/wait.h netdb.h arpa/inet.h dirent.h])
-AC_CHECK_HEADERS([net/if.h net/if_types.h linux/if_tun.h net/if_tun.h net/tun/if_tun.h net/if_tap.h net/tap/if_tap.h net/ethernet.h net/if_arp.h netinet/in_systm.h netinet/in.h netinet/in6.h time.h netpacket/packet.h],
- [], [], [#include "src/have.h"]
-)
-AC_CHECK_HEADERS([netinet/if_ether.h netinet/ip.h netinet/ip6.h],
- [], [], [#include "src/have.h"]
-)
-AC_CHECK_HEADERS([netinet/tcp.h netinet/ip_icmp.h netinet/icmp6.h],
+AC_CHECK_HEADERS([stdbool.h syslog.h sys/file.h sys/param.h sys/resource.h sys/socket.h sys/time.h sys/un.h sys/wait.h netdb.h arpa/inet.h dirent.h])
+AC_CHECK_HEADERS([time.h],
[], [], [#include "src/have.h"]
)
MeshLink_ATTRIBUTE(__malloc__)
MeshLink_ATTRIBUTE(__warn_unused_result__)
-AC_CHECK_TYPES([socklen_t, struct ether_header, struct arphdr, struct ether_arp, struct in_addr, struct addrinfo, struct ip, struct icmp, struct in6_addr, struct sockaddr_in6, struct ip6_hdr, struct icmp6_hdr, struct nd_neighbor_solicit, struct nd_opt_hdr], , ,
+AC_CHECK_TYPES([socklen_t, struct addrinfo, struct sockaddr_in6], , ,
[#include "src/have.h"]
)
dnl Checks for library functions.
AC_TYPE_SIGNAL
-AC_CHECK_FUNCS([asprintf daemon fchmod flock ftime fork get_current_dir_name gettimeofday mlockall putenv random select strdup strerror strsignal strtol system time usleep unsetenv vsyslog writev],
+AC_CHECK_FUNCS([asprintf fchmod fork get_current_dir_name gettimeofday random select strdup strerror time usleep],
[], [], [#include "src/have.h"]
)
#include "xalloc.h"
-#ifndef HAVE_DAEMON
-/*
- Replacement for the daemon() function.
-
- The daemon() function is for programs wishing to detach themselves
- from the controlling terminal and run in the background as system
- daemons.
-
- Unless the argument nochdir is non-zero, daemon() changes the
- current working directory to the root (``/'').
-
- Unless the argument noclose is non-zero, daemon() will redirect
- standard input, standard output and standard error to /dev/null.
-*/
-int daemon(int nochdir, int noclose) {
-#ifdef HAVE_FORK
- pid_t pid;
- int fd;
-
- pid = fork();
-
- /* Check if forking failed */
- if(pid < 0) {
- perror("fork");
- exit(-1);
- }
-
- /* If we are the parent, terminate */
- if(pid)
- exit(0);
-
- /* Detach by becoming the new process group leader */
- if(setsid() < 0) {
- perror("setsid");
- return -1;
- }
-
- /* Change working directory to the root (to avoid keeping mount
- points busy) */
- if(!nochdir) {
- chdir("/");
- }
-
- /* Redirect stdin/out/err to /dev/null */
- if(!noclose) {
- fd = open("/dev/null", O_RDWR);
-
- if(fd < 0) {
- perror("opening /dev/null");
- return -1;
- } else {
- dup2(fd, 0);
- dup2(fd, 1);
- dup2(fd, 2);
- }
- }
-
- return 0;
-#else
- return -1;
-#endif
-}
-#endif
-
#ifndef HAVE_GET_CURRENT_DIR_NAME
/*
Replacement for the GNU get_current_dir_name function:
#include "fake-getaddrinfo.h"
#include "fake-getnameinfo.h"
-#ifndef HAVE_DAEMON
-extern int daemon(int, int);
-#endif
-
#ifndef HAVE_GET_CURRENT_DIR_NAME
extern char *get_current_dir_name(void);
#endif
#include <sys/wait.h>
#endif
-#ifdef HAVE_SYS_IOCTL_H
-#include <sys/ioctl.h>
-#endif
-
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#include <sys/resource.h>
#endif
-#ifdef HAVE_SYS_UIO_H
-#include <sys/uio.h>
-#endif
-
#ifdef HAVE_SYS_UN_H
#include <sys/un.h>
#endif
#include <sys/socket.h>
#endif
-#ifdef HAVE_NET_IF_H
-#include <net/if.h>
-#endif
-
-#ifdef HAVE_NET_IF_TYPES_H
-#include <net/if_types.h>
-#endif
-
-#ifdef HAVE_NETINET_IN_SYSTM_H
-#include <netinet/in_systm.h>
-#endif
-
-#ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif
-
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
-#ifdef HAVE_NETINET_IP_H
-#include <netinet/ip.h>
-#endif
-
-#ifdef HAVE_NETINET_TCP_H
-#include <netinet/tcp.h>
-#endif
-
-#ifdef HAVE_NETINET_IN6_H
-#include <netinet/in6.h>
-#endif
-
-#ifdef HAVE_NETINET_IP6_H
-#include <netinet/ip6.h>
-#endif
-
#ifdef HAVE_MINGW
#define SLASH "\\"
#else
#include "system.h"
#ifdef HAVE_LINUX
+#include <sys/ioctl.h>
+#include <linux/if.h>
#include <linux/if_tun.h>
#endif