From: Ted Lemon Date: Fri, 19 Feb 1999 18:17:34 +0000 (+0000) Subject: - Move tests for constants defined in O.S. headers into osdep.h - test X-Git-Tag: V2-BETA-1-PATCH-14~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5b4fcc905f32ee91f9a66c2db7b80b9eea0c445e;p=thirdparty%2Fdhcp.git - Move tests for constants defined in O.S. headers into osdep.h - test for HAVE_whatever in .c files. Define relevant HAVE_whatevers in linux.h, so that versions of linux that define these constants as enums will still work. --- diff --git a/common/dispatch.c b/common/dispatch.c index 775bada37..11a25f57f 100644 --- a/common/dispatch.c +++ b/common/dispatch.c @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: dispatch.c,v 1.47.2.10 1999/02/13 19:17:03 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: dispatch.c,v 1.47.2.11 1999/02/19 18:17:33 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -140,7 +140,7 @@ void discover_interfaces (state) except don't skip down interfaces if we're trying to get a list of configurable interfaces. */ if ((ifr.ifr_flags & IFF_LOOPBACK) || -#ifdef IFF_POINTOPOINT +#ifdef HAVE_IFF_POINTOPOINT (ifr.ifr_flags & IFF_POINTOPOINT) || #endif (!(ifr.ifr_flags & IFF_UP) && @@ -168,7 +168,7 @@ void discover_interfaces (state) /* If we have the capability, extract link information and record it in a linked list. */ -#ifdef AF_LINK +#ifdef HAVE_AF_LINK if (ifp -> ifr_addr.sa_family == AF_LINK) { struct sockaddr_dl *foo = ((struct sockaddr_dl *) (&ifp -> ifr_addr)); @@ -328,7 +328,7 @@ void discover_interfaces (state) /* Now cycle through all the interfaces we found, looking for hardware addresses. */ -#if defined (SIOCGIFHWADDR) && !defined (AF_LINK) +#if defined (HAVE_SIOCGIFHWADDR) && !defined (HAVE_AF_LINK) for (tmp = interfaces; tmp; tmp = tmp -> next) { struct ifreq ifr; struct sockaddr sa; @@ -352,7 +352,11 @@ void discover_interfaces (state) sa = *(struct sockaddr *)&ifr.ifr_hwaddr; switch (sa.sa_family) { -#ifdef ARPHRD_LOOPBACK +#ifdef HAVE_ARPHRD_TUNNEL + case ARPHRD_TUNNEL: + /* ignore tunnel interfaces. */ +#endif +#ifdef HAVE_ARPHRD_LOOPBACK case ARPHRD_LOOPBACK: /* ignore loopback interface */ break; @@ -382,7 +386,7 @@ void discover_interfaces (state) memcpy (tmp -> hw_address.haddr, sa.sa_data, 16); break; -#ifdef ARPHRD_METRICOM +#ifdef HAVE_ARPHRD_METRICOM case ARPHRD_METRICOM: tmp -> hw_address.hlen = 6; tmp -> hw_address.htype = ARPHRD_METRICOM; @@ -395,7 +399,7 @@ void discover_interfaces (state) ifr.ifr_name, sa.sa_family); } } -#endif /* defined (SIOCGIFHWADDR) && !defined (AF_LINK) */ +#endif /* defined (HAVE_SIOCGIFHWADDR) && !defined (HAVE_AF_LINK) */ /* If we're just trying to get a list of interfaces that we might be able to configure, we can quit now. */ diff --git a/common/socket.c b/common/socket.c index 62d61d63a..f1c3dc4af 100644 --- a/common/socket.c +++ b/common/socket.c @@ -50,7 +50,7 @@ #ifndef lint static char copyright[] = -"$Id: socket.c,v 1.26.2.7 1999/02/13 19:20:07 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: socket.c,v 1.26.2.8 1999/02/19 18:17:34 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -102,7 +102,7 @@ int if_register_socket (info) int sock; int flag; -#if !defined (SO_BINDTODEVICE) && !defined (USE_FALLBACK) +#if !defined (HAVE_SO_BINDTODEVICE) && !defined (USE_FALLBACK) /* Make sure only one interface is registered. */ if (once) error ("The standard socket API can only support %s", @@ -136,7 +136,7 @@ int if_register_socket (info) if (bind (sock, (struct sockaddr *)&name, sizeof name) < 0) error ("Can't bind to dhcp address: %m"); -#if defined (SO_BINDTODEVICE) +#if defined (HAVE_SO_BINDTODEVICE) /* Bind this socket to this interface. */ if (info -> ifp && setsockopt (sock, SOL_SOCKET, SO_BINDTODEVICE, diff --git a/includes/cf/linux.h b/includes/cf/linux.h index 13523b93d..84bcd3f30 100644 --- a/includes/cf/linux.h +++ b/includes/cf/linux.h @@ -111,6 +111,7 @@ extern int h_errno; # define USE_LPF # define LINUX_SLASHPROC_DISCOVERY # define PROCDEV_DEVICE "/proc/net/dev" +# define HAVE_ARPHRD_TUNNEL # else # define USE_SOCKETS # define IGNORE_HOSTUNREACH @@ -119,3 +120,8 @@ extern int h_errno; #define ALIAS_NAMES_PERMUTED #define SKIP_DUMMY_INTERFACES +#define HAVE_ARPHRD_METRICOM +#define HAVE_ARPHRD_IEEE802 +#define HAVE_ARPHRD_LOOPBACK +#define HAVE_SO_BINDTODEVICE +#define HAVE_SIOCGIFHWADDR diff --git a/includes/osdep.h b/includes/osdep.h index 858399924..5c7025d30 100644 --- a/includes/osdep.h +++ b/includes/osdep.h @@ -230,3 +230,36 @@ #ifndef BPF_FORMAT # define BPF_FORMAT "/dev/bpf%d" #endif + +#if defined (IFF_POINTOPOINT) && !defined (HAVE_IFF_POINTOPOINT) +# define HAVE_IFF_POINTOPOINT +#endif + +#if defined (AF_LINK) && !defined (HAVE_AF_LINK) +# define HAVE_AF_LINK +#endif + +#if defined (ARPHRD_TUNNEL) && !defined (HAVE_ARPHRD_TUNNEL) +# define HAVE_ARPHRD_TUNNEL +#endif + +#if defined (ARPHRD_LOOPBACK) && !defined (HAVE_ARPHRD_LOOPBACK) +# define HAVE_ARPHRD_LOOPBACK +#endif + +#if defined (ARPHRD_METRICOM) && !defined (HAVE_ARPHRD_METRICOM) +# define HAVE_ARPHRD_METRICOM +#endif + +#if defined (SO_BINDTODEVICE) && !defined (HAVE_SO_BINDTODEVICE) +# define HAVE_SO_BINDTODEVICE +#endif + +#if defined (SIOCGIFHWADDR) && !defined (HAVE_SIOCGIFHWADDR) +# define HAVE_SIOCGIFHWADDR +#endif + +#if defined (AF_LINK) && !defined (HAVE_AF_LINK) +# define HAVE_AF_LINK +#endif +