#ifndef lint
static char copyright[] =
-"$Id: conflex.c,v 1.109 2007/05/29 18:11:55 each Exp $ Copyright (c) 2004-2007 Internet Systems Consortium. All rights reserved.\n";
+"$Id: conflex.c,v 1.110 2007/06/08 14:58:20 dhankins Exp $ Copyright (c) 2004-2007 Internet Systems Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
if (!strcasecmp (atom + 1, "ot"))
return TOKEN_NOT;
if (!strcasecmp (atom + 1, "o"))
- return NO;
+ return TOKEN_NO;
if (!strcasecmp (atom + 1, "s-update"))
return NS_UPDATE;
if (!strcasecmp (atom + 1, "oerror"))
if (!strncasecmp(atom + 2, "rv", 2)) {
if (!strncasecmp(atom + 4, "er", 2)) {
if (atom[6] == '\0')
- return SERVER;
+ return TOKEN_SERVER;
if (atom[6] == '-') {
if (!strcasecmp(atom + 7,
"duid"))
#ifndef lint
static char copyright[] =
-"$Id: discover.c,v 1.59 2007/06/01 22:11:49 dhankins Exp $ Copyright (c) 2004-2007 Internet Systems Consortium. All rights reserved.\n";
+"$Id: discover.c,v 1.60 2007/06/08 14:58:20 dhankins Exp $ Copyright (c) 2004-2007 Internet Systems Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
#include <sys/ioctl.h>
#include <errno.h>
+#ifdef HAVE_NET_IF6_H
+# include <net/if6.h>
+#endif
+
struct interface_info *interfaces, *dummy_interfaces, *fallback_interface;
int interfaces_invalidated;
int quiet_interface_discovery;
* NOTE: the long-term goal is to use the interface code from BIND 9.
*/
-#if defined(SIOCGLIFNUM)
+#if defined(SIOCGLIFCONF) && defined(SIOCGLIFNUM) && defined(SIOCGLIFFLAGS)
+
+/* HP/UX doesn't define struct lifconf, instead they define struct
+ * if_laddrconf. Similarly, 'struct lifreq' and 'struct lifaddrreq'.
+ */
+#ifdef ISC_PLATFORM_HAVEIF_LADDRCONF
+# define lifc_len iflc_len
+# define lifc_buf iflc_buf
+# define lifc_req iflc_req
+# define LIFCONF if_laddrconf
+#else
+# define ISC_HAVE_LIFC_FAMILY 1
+# define ISC_HAVE_LIFC_FLAGS 1
+# define LIFCONF lifconf
+#endif
+
+#ifdef ISC_PLATFORM_HAVEIF_LADDRREQ
+# define lifr_addr iflr_addr
+# define lifr_name iflr_name
+# define lifr_dstaddr iflr_dstaddr
+# define lifr_flags iflr_flags
+# define sockaddr_storage sockaddr_ext
+# define ss_family sa_family
+# define LIFREQ if_laddrreq
+#else
+# define LIFREQ lifreq
+#endif
+
+#ifndef IF_NAMESIZE
+# if defined(LIFNAMSIZ)
+# define IF_NAMESIZE LIFNAMSIZ
+# elseif defined(IFNAMSIZ)
+# define IF_NAMESIZE IFNAMSIZ
+# else
+# define IF_NAMESIZE 16
+# endif
+#endif
+
/*
* Solaris support
* ---------------
struct iface_conf_list {
int sock; /* file descriptor used to get information */
int num; /* total number of interfaces */
- struct lifconf conf; /* structure used to get information */
+ struct LIFCONF conf; /* structure used to get information */
int next; /* next interface to retrieve when iterating */
};
* Structure used to return information about a specific interface.
*/
struct iface_info {
- char name[LIFNAMSIZ]; /* name of the interface, e.g. "bge0" */
+ char name[IF_NAMESIZE+1]; /* name of the interface, e.g. "bge0" */
struct sockaddr_storage addr; /* address information */
isc_uint64_t flags; /* interface flags, e.g. IFF_LOOPBACK */
};
*/
int
begin_iface_scan(struct iface_conf_list *ifaces) {
+#ifdef ISC_PLATFORM_HAVELIFNUM
struct lifnum lifnum;
+#else
+ int lifnum;
+#endif
ifaces->sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (ifaces->sock < 0) {
}
memset(&lifnum, 0, sizeof(lifnum));
+#ifdef ISC_PLATFORM_HAVELIFNUM
lifnum.lifn_family = AF_UNSPEC;
+#endif
if (ioctl(ifaces->sock, SIOCGLIFNUM, &lifnum) < 0) {
log_error("Error finding total number of interfaces; %m");
close(ifaces->sock);
return 0;
}
+#ifdef ISC_PLATFORM_HAVELIFNUM
ifaces->num = lifnum.lifn_count;
+#else
+ ifaces->num = lifnum;
+#endif
+
memset(&ifaces->conf, 0, sizeof(ifaces->conf));
+#ifdef ISC_HAVE_LIFC_FAMILY
ifaces->conf.lifc_family = AF_UNSPEC;
- ifaces->conf.lifc_len = ifaces->num * sizeof(struct lifreq);
+#endif
+ ifaces->conf.lifc_len = ifaces->num * sizeof(struct LIFREQ);
ifaces->conf.lifc_buf = dmalloc(ifaces->conf.lifc_len, MDL);
if (ifaces->conf.lifc_buf == NULL) {
log_fatal("Out of memory getting interface list.");
*/
int
next_iface(struct iface_info *info, int *err, struct iface_conf_list *ifaces) {
- struct lifreq *p;
- struct lifreq tmp;
+ struct LIFREQ *p;
+ struct LIFREQ tmp;
char *s;
do {
fi
+# SIOCGLIFCONF uses some transport structures. Trick is not all platforms
+# use the same structures. We like to use 'struct lifconf' and 'struct
+# lifreq', but we'll use these other structures if they're present. HPUX
+# does not define 'struct lifnum', but does use SIOCGLIFNUM - they use an
+# int value.
+#
+AC_MSG_CHECKING([for struct lifnum])
+AC_TRY_COMPILE(
+[ #include <sys/types.h>
+ #include <net/if.h>
+],
+[ struct lifnum a;
+],
+ [AC_MSG_RESULT(yes)
+ AC_DEFINE([ISC_PLATFORM_HAVELIFNUM], [1],
+ [Define to 1 if the system has 'struct lifnum'.])],
+ [AC_MSG_RESULT(no)])
+
+AC_MSG_CHECKING([for struct if_laddrconf])
+AC_TRY_COMPILE(
+[ #include <sys/types.h>
+ #include <net/if6.h>
+],
+[ struct if_laddrconf a;
+],
+ [AC_MSG_RESULT(yes)
+ AC_DEFINE([ISC_PLATFORM_HAVEIF_LADDRCONF], [1],
+ [Define to 1 if the system has 'struct if_laddrconf'.])],
+ [AC_MSG_RESULT(no)])
+
+AC_MSG_CHECKING([for struct if_laddrreq])
+AC_TRY_LINK(
+[#include <sys/types.h>
+ #include <net/if6.h>
+],
+[ struct if_laddrreq a;
+],
+ [AC_MSG_RESULT(yes)
+ AC_DEFINE([ISC_PLATFORM_HAVEIF_LADDRREQ], [1],
+ [Define to 1 if the system has 'struct if_laddrreq'.])],
+ [AC_MSG_RESULT(no)])
+
# Look for optional headers.
-AC_CHECK_HEADERS(net/if_dl.h regex.h)
+AC_CHECK_HEADERS(net/if_dl.h net/if6.h regex.h)
# find an MD5 library
AC_SEARCH_LIBS(MD5_Init, [crypto])