summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorDavid Hankins <dhankins@isc.org>2007-06-08 14:58:20 +0000
committerDavid Hankins <dhankins@isc.org>2007-06-08 14:58:20 +0000
commit8da06bb1f533a76424324434b180c086f45a9cdb (patch)
tree2a3dd6b10aebba40457f86867c7d2bae4d8278e0 /common
parent627ad6d620ccd6317b2c0fa9e080c66e4de091e4 (diff)
downloadisc-dhcp-8da06bb1f533a76424324434b180c086f45a9cdb.tar.gz
- Compilation on HP/UX has been repaired. The changes should generally
apply to any architecture that supplies SIOCGLIFCONF but does not use 'struct lifconf' structures to pass values. [ISC-Bugs #16928]
Diffstat (limited to 'common')
-rw-r--r--common/conflex.c6
-rw-r--r--common/discover.c68
2 files changed, 64 insertions, 10 deletions
diff --git a/common/conflex.c b/common/conflex.c
index 4df35e24..b0620c7f 100644
--- a/common/conflex.c
+++ b/common/conflex.c
@@ -34,7 +34,7 @@
#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"
@@ -919,7 +919,7 @@ static enum dhcp_token intern (atom, dfv)
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"))
@@ -1071,7 +1071,7 @@ static enum dhcp_token intern (atom, dfv)
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"))
diff --git a/common/discover.c b/common/discover.c
index 1fc46b4b..feea4fa8 100644
--- a/common/discover.c
+++ b/common/discover.c
@@ -34,7 +34,7 @@
#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"
@@ -43,6 +43,10 @@ static char copyright[] =
#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;
@@ -154,7 +158,44 @@ isc_result_t interface_initialize (omapi_object_t *ipo,
* 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
* ---------------
@@ -171,7 +212,7 @@ isc_result_t interface_initialize (omapi_object_t *ipo,
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 */
};
@@ -179,7 +220,7 @@ struct iface_conf_list {
* 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 */
};
@@ -191,7 +232,11 @@ struct iface_info {
*/
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) {
@@ -200,7 +245,9 @@ begin_iface_scan(struct iface_conf_list *ifaces) {
}
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);
@@ -208,10 +255,17 @@ begin_iface_scan(struct iface_conf_list *ifaces) {
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.");
@@ -238,8 +292,8 @@ begin_iface_scan(struct iface_conf_list *ifaces) {
*/
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 {