2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-08-22 01:49:35 +00:00

- 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]
This commit is contained in:
David Hankins 2007-06-08 14:58:20 +00:00
parent 627ad6d620
commit 8da06bb1f5
8 changed files with 118 additions and 18 deletions

View File

@ -54,6 +54,10 @@ suggested fixes to <dhcp-users@isc.org>.
Changes since 4.0.0a1
- 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.
- Two new operators, ~= and ~~, have been integrated to implement
boolean matches by regular expression (such as may be used in
class matching statements). Thanks to a patch by Alexandr S.

View File

@ -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"))

View File

@ -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 {

View File

@ -85,8 +85,50 @@ else
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])

View File

@ -34,7 +34,7 @@
#ifndef lint
static char copyright[] =
"$Id: omshell.c,v 1.15 2007/05/19 19:16:24 dhankins Exp $ Copyright (c) 2004-2007 Internet Systems Consortium. All rights reserved.\n";
"$Id: omshell.c,v 1.16 2007/06/08 14:58:20 dhankins Exp $ Copyright (c) 2004-2007 Internet Systems Consortium. All rights reserved.\n";
#endif /* not lint */
#include <time.h>
@ -240,7 +240,7 @@ main(int argc, char **argv) {
}
break;
case SERVER:
case TOKEN_SERVER:
token = next_token (&val, (unsigned *)0, cfile);
if (token == NUMBER) {
int alen = (sizeof buf) - 1;

View File

@ -224,7 +224,7 @@ enum dhcp_token {
MCLT = 428,
SPLIT = 429,
AT = 430,
NO = 431,
TOKEN_NO = 431,
TOKEN_DELETE = 432,
NS_UPDATE = 433,
UPDATE = 434,
@ -303,7 +303,7 @@ enum dhcp_token {
TOKEN_HELP = 606,
END_OF_FILE = 607,
RECOVER_WAIT = 608,
SERVER = 609,
TOKEN_SERVER = 609,
CONNECT = 610,
REMOVE = 611,
REFRESH = 612,

View File

@ -43,7 +43,7 @@
/* XXX: now that we have a nice autoconf, we should sense this in
* ./configure.
*/
#ifdef __sun__
#if defined(__sun__) || defined(__hpux__)
typedef uint8_t u_int8_t;
typedef uint16_t u_int16_t;
typedef uint32_t u_int32_t;

View File

@ -34,7 +34,7 @@
#ifndef lint
static char copyright[] =
"$Id: confpars.c,v 1.166 2007/05/30 10:10:12 shane Exp $ Copyright (c) 2004-2007 Internet Systems Consortium. All rights reserved.\n";
"$Id: confpars.c,v 1.167 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"
@ -1392,7 +1392,7 @@ void parse_pool_statement (cfile, group, type)
do {
token = peek_token (&val, (unsigned *)0, cfile);
switch (token) {
case NO:
case TOKEN_NO:
next_token (&val, (unsigned *)0, cfile);
token = next_token (&val, (unsigned *)0, cfile);
if (token != FAILOVER ||