]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Build fixes for Solaris 9.
authorShane Kerr <shane@isc.org>
Wed, 9 Jan 2008 23:02:42 +0000 (23:02 +0000)
committerShane Kerr <shane@isc.org>
Wed, 9 Jan 2008 23:02:42 +0000 (23:02 +0000)
See RT ticket #17444 for more.

RELNOTES
common/socket.c
configure.ac
omapip/inet_addr.c

index f60f5fa3605f6a99cdb13c6addd00ef684b38b59..bac9425a72312e076466659b492abca241520856 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -108,6 +108,8 @@ suggested fixes to <dhcp-users@isc.org>.
   initialization state may have been used to signal the relay agent
   information options sub-option code for the 'END' of the option space.
 
+- Fixes to allow code to compile and run on Solaris 9.
+
                        Changes since 4.0.0b3
 
 - The reverse dns name for PTR updates on IPv6 addresses has been fixed to
index 8058c286ab22f1df69826b3a2e25b20921ea97e3..482a9f799eb7ca393d1cebcfe54648670b5a0dd4 100644 (file)
@@ -410,6 +410,56 @@ ssize_t send_packet (interface, packet, raw, len, from, to, hto)
 
 #endif /* USE_SOCKET_SEND || USE_SOCKET_FALLBACK */
 
+#ifdef DHCPv6
+/*
+ * Solaris 9 is missing the CMSG_LEN and CMSG_SPACE macros, so we will 
+ * synthesize them (based on the BIND 9 technique).
+ */
+
+#ifndef CMSG_LEN
+static size_t CMSG_LEN(size_t len) {
+       size_t hdrlen;
+       /*
+        * Cast NULL so that any pointer arithmetic performed by CMSG_DATA
+        * is correct.
+        */
+       hdrlen = (size_t)CMSG_DATA(((struct cmsghdr *)NULL));
+       return hdrlen + len;
+}
+#endif /* !CMSG_LEN */
+
+#ifndef CMSG_SPACE
+static size_t CMSG_SPACE(size_t len) {
+       struct msghdr msg;
+       struct cmsghdr *cmsgp;
+
+       /*
+        * XXX: The buffer length is an ad-hoc value, but should be enough
+        * in a practical sense.
+        */
+       union {
+               struct cmsghdr cmsg_sizer;
+               u_int8_t pktinfo_sizer[sizeof(struct cmsghdr) + 1024];
+       } dummybuf;
+
+       memset(&msg, 0, sizeof(msg));
+       msg.msg_control = &dummybuf;
+       msg.msg_controllen = sizeof(dummybuf);
+
+       cmsgp = (struct cmsghdr *)&dummybuf;
+       cmsgp->cmsg_len = CMSG_LEN(len);
+
+       cmsgp = CMSG_NXTHDR(&msg, cmsgp);
+       if (cmsgp != NULL) {
+               return (char *)cmsgp - (char *)msg.msg_control;
+       } else {
+               return 0;
+       }
+}
+#endif /* !CMSG_SPACE */
+
+#endif /* DHCPv6 */
+
 #ifdef DHCPv6
 /* 
  * For both send_packet6() and receive_packet6() we need to use the 
index da9c4aedd1335fbc8aa66cd35ccfda0933ecebef..09723db8fcba894dcda4781d07f58717b3588fd9 100644 (file)
@@ -180,6 +180,7 @@ fi
 AC_MSG_CHECKING([for struct lifnum])
 AC_TRY_COMPILE(
 [ #include <sys/types.h>
+  #include <sys/socket.h>
   #include <net/if.h>
 ],
 [ struct lifnum a;
@@ -214,7 +215,7 @@ AC_TRY_LINK(
        [AC_MSG_RESULT(no)])
 
 # Look for optional headers.
-AC_CHECK_HEADERS(net/if_dl.h net/if6.h regex.h)
+AC_CHECK_HEADERS(sys/socket.h net/if_dl.h net/if6.h regex.h)
 
 # find an MD5 library
 AC_SEARCH_LIBS(MD5_Init, [crypto])
index 752b359e4cf396637345e92e4b22869e16a1a7b6..c5ccc79f7f573a53cda0f7f1d721216a73f3e2db 100644 (file)
@@ -78,14 +78,14 @@ inet_aton(cp, addr)
                                base = 8;
                }
                while ((c = *cp) != '\0') {
-                       if (isascii(c) && isdigit(c)) {
+                       if (isascii(c) && isdigit((int)c)) {
                                val = (val * base) + (c - '0');
                                cp++;
                                continue;
                        }
-                       if (base == 16 && isascii(c) && isxdigit(c)) {
+                       if (base == 16 && isascii(c) && isxdigit((int)c)) {
                                val = (val << 4) + 
-                                       (c + 10 - (islower(c) ? 'a' : 'A'));
+                                     (c + 10 - (islower((int)c) ? 'a' : 'A'));
                                cp++;
                                continue;
                        }
@@ -107,7 +107,7 @@ inet_aton(cp, addr)
        /*
         * Check for trailing characters.
         */
-       if (*cp && (!isascii(*cp) || !isspace(*cp)))
+       if (*cp && (!isascii(*cp) || !isspace((int)*cp)))
                return (0);
        /*
         * Concoct the address according to