]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
- Compilation on HP/UX has been repaired. The changes should generally
authorDavid Hankins <dhankins@isc.org>
Fri, 8 Jun 2007 14:58:20 +0000 (14:58 +0000)
committerDavid Hankins <dhankins@isc.org>
Fri, 8 Jun 2007 14:58:20 +0000 (14:58 +0000)
  apply to any architecture that supplies SIOCGLIFCONF but does not
  use 'struct lifconf' structures to pass values. [ISC-Bugs #16928]

RELNOTES
common/conflex.c
common/discover.c
configure.ac
dhcpctl/omshell.c
includes/dhctoken.h
includes/osdep.h
server/confpars.c

index 441e5456ddb02d3d47df76384cb43e08de6a433a..5b5e8b7c0485daf0b78a7beaedc17aeb63c82de5 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -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.
index 4df35e248bf82cbd96ac7706b421010f7ad0c3a1..b0620c7f06316808478a0e0c8f1ae4c4dfc0971a 100644 (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")) 
index 1fc46b4b5dad2d3e38b154383a110ce28dd125af..feea4fa8344f0e81d41a9920eafa4a8f1e0848ca 100644 (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 {
index 333c39f18a90cd252005f2037f26bf170822b634..1c6f25f44b84d3bc7b8890c448ac46a06909bc56 100644 (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])
index 7fab688109dccd65556b655330deac8298b1e89b..63286eb5217ed59acd7aaac1324806ef850897e5 100644 (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;
index 8bbd06ef7973d189a779d7d5d51c5482841a1401..7d7ee9cf40476af5f76cff1092ded7af9edc291b 100644 (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,
index c4c301c9f1f4340c91b10b3f10c3f63c9f38548a..6e1db70e586fc4ba43dd175a964e433829efc7be 100644 (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;
index 97e7803dbe4bbca37a2f481a3c74d97f6a7a1e6b..c4fb0134e7d013e876730418f68c69931044780d 100644 (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 ||