]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Add a compat syslog function if the libc syslog does not support LOG_PERROR.
authorRoy Marples <roy@marples.name>
Sat, 24 May 2014 13:08:29 +0000 (13:08 +0000)
committerRoy Marples <roy@marples.name>
Sat, 24 May 2014 13:08:29 +0000 (13:08 +0000)
Add a non working if-sun.c stub.
Define IN6_IFF_TENTATIVE and friends to zero so IPv6 at least compiles on Solaris.
Warn that Solaris support presently does not work.

configure
dhcpcd.c
if-sun.c [new file with mode: 0644]
ipv6.c

index 9e9c25ccc5b901d94ecea5217a56705157635322..c048c5faf33ed0c37264ebcaec9475c1572db533 100755 (executable)
--- a/configure
+++ b/configure
@@ -372,9 +372,16 @@ kfreebsd*)
        echo "COMPAT_SRCS+=     compat/linkaddr.c" >>$CONFIG_MK
        ;;
 sunos*)
-#      echo "CSTD=             gnu99" >>$CONFIG_MK
+       echo "WARNING!!! Solaris support is at early development stage!" >&2
+       echo "so don't expect it to work just yet, patches welcome" >&2
        echo "CPPFLAGS+=        -D_XPG4_2 -D__EXTENSIONS__ -DBSD_COMP" \
            >>$CONFIG_MK
+       echo "DHCPCD_SRCS+=     if-sun.c" >>$CONFIG_MK
+
+       # IPv6 won't work, but it will at least compile.
+       echo "CPPFLAGS+=        -DIN6_IFF_DETACHED=0" >>$CONFIG_MK
+       echo "CPPFLAGS+=        -DIN6_IFF_TENTATIVE=0" >>$CONFIG_MK
+       echo "CPPFLAGS+=        -DIN6_IFF_DUPLICATED=0" >>$CONFIG_MK
        ;;
 *)
        echo "DHCPCD_SRCS+=     if-bsd.c" >>$CONFIG_MK
@@ -719,6 +726,29 @@ pselect)
        ;;
 esac
 
+if [ -z "$LOG_PERROR" ]; then
+       printf "Testing for LOG_PERROR ... "
+       cat <<EOF >_log_perror.c
+#include <syslog.h>
+int main(void) {
+       openlog("test", LOG_PERROR, LOG_DAEMON);
+       return 0;
+}
+EOF
+       if $XCC _log_perror.c -o _log_perror 2>/dev/null; then
+               LOG_PERROR=yes
+       else
+               LOG_PERROR=no
+       fi
+       echo "$LOG_PERROR"
+       rm -f _log_perror.c _log_perror
+fi
+if [ "$LOG_PERROR" = no ]; then
+       echo "COMPAT_SRCS+=     compat/psyslog.c" >>$CONFIG_MK
+       echo "#include          \"compat/psyslog.h\"" >>$CONFIG_H
+       echo "#define syslog    psyslog" >>$CONFIG_H
+fi
+
 if [ -z "$MD5" ]; then
        MD5_LIB=
        printf "Testing for MD5Init ... "
index ac09d276de53828b589d73248749115114c36b8f..5ec6b8f0ee20e99ea0a0ec0d7f76efa30fb6ad9e 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -1145,6 +1145,9 @@ main(int argc, char **argv)
        openlog(PACKAGE, LOG_PID, LOG_DAEMON);
 #endif
        setlogmask(LOG_UPTO(LOG_INFO));
+#ifndef LOG_PERROR
+       psyslog_prio = LOG_UPTO(LOG_INFO);
+#endif
 
        /* Test for --help and --version */
        if (argc > 1) {
@@ -1255,8 +1258,12 @@ main(int argc, char **argv)
        ctx.options &= ~DHCPCD_DAEMONISE;
 #endif
 
-       if (ctx.options & DHCPCD_DEBUG)
+       if (ctx.options & DHCPCD_DEBUG) {
                setlogmask(LOG_UPTO(LOG_DEBUG));
+#ifndef LOG_PERROR
+               psyslog_prio = LOG_UPTO(LOG_DEBUG);
+#endif
+       }
        if (ctx.options & DHCPCD_QUIET) {
                i = open(_PATH_DEVNULL, O_RDWR);
                if (i == -1)
diff --git a/if-sun.c b/if-sun.c
new file mode 100644 (file)
index 0000000..a6a8323
--- /dev/null
+++ b/if-sun.c
@@ -0,0 +1,191 @@
+/*
+ * dhcpcd - DHCP client daemon
+ * Copyright (c) 2006-2014 Roy Marples <roy@marples.name>
+ * All rights reserved
+
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/utsname.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "config.h"
+#include "common.h"
+#include "dhcp.h"
+#include "if.h"
+#include "if-options.h"
+#include "ipv4.h"
+#include "ipv6.h"
+#include "ipv6nd.h"
+
+int
+if_init(__unused struct interface *iface)
+{
+
+       return 0;
+}
+
+int
+if_conf(__unused struct interface *iface)
+{
+
+       return 0;
+}
+
+int
+if_openlinksocket(void)
+{
+
+       errno = ENOTSUP;
+       return -1;
+}
+
+int
+if_getssid(const char *ifname, char *ssid)
+{
+
+       errno = ENOTSUP;
+       return -1;
+}
+
+int
+if_vimaster(const char *ifname)
+{
+
+       return 0;
+}
+
+#ifdef INET
+int
+if_openrawsocket(struct interface *ifp, int protocol)
+{
+
+       errno = ENOTSUP;
+       return -1;
+}
+
+ssize_t
+if_sendrawpacket(const struct interface *ifp, int protocol,
+    const void *data, size_t len)
+{
+
+       errno = ENOTSUP;
+       return -1;
+}
+
+ssize_t
+if_readrawpacket(struct interface *ifp, int protocol,
+    void *data, size_t len, int *flags)
+{
+
+       errno = ENOTSUP;
+       return -1;
+}
+
+int
+if_address(const struct interface *iface, const struct in_addr *address,
+    const struct in_addr *netmask, const struct in_addr *broadcast,
+    int action)
+{
+
+       errno = ENOTSUP;
+       return -1;
+}
+
+int
+if_route(const struct rt *rt, int action)
+{
+
+       errno = ENOTSUP;
+       return -1;
+}
+#endif
+
+#ifdef INET6
+int
+if_address6(const struct ipv6_addr *a, int action)
+{
+
+       errno = ENOTSUP;
+       return -1;
+}
+
+int
+if_route6(const struct rt6 *rt, int action)
+{
+
+       errno = ENOTSUP;
+       return -1;
+}
+#endif
+
+#ifdef INET6
+int
+if_addrflags6(const char *ifname, const struct in6_addr *addr)
+{
+
+       errno = ENOTSUP;
+       return -1;
+}
+#endif
+
+int
+if_managelink(struct dhcpcd_ctx *ctx)
+{
+
+       errno = ENOTSUP;
+       return -1;
+}
+
+if_machinearch(char *str, size_t len)
+{
+
+       errno = ENOTSUP;
+       return -1;
+}
+
+#ifdef INET6
+int
+if_nd6reachable(const char *ifname, struct in6_addr *addr)
+{
+
+       errno = ENOTSUP;
+       return -1;
+}
+
+void
+if_rarestore(struct dhcpcd_ctx *ctx)
+{
+
+}
+
+int
+if_checkipv6(struct dhcpcd_ctx *ctx, const char *ifname, int own)
+{
+
+       errno = ENOTSUP;
+       return -1;
+}
+#endif
diff --git a/ipv6.c b/ipv6.c
index 7d04f4a01e5b282db9a1047590add472f0f35341..191e263bf8831e60e837ec3084da87d064a1f9bb 100644 (file)
--- a/ipv6.c
+++ b/ipv6.c
 #ifdef __FreeBSD__ /* Needed so that including netinet6/in6_var.h works */
 #  include <net/if_var.h>
 #endif
+#ifndef __sun
 #  include <netinet6/in6_var.h>
 #endif
+#endif
 
 #include <errno.h>
 #include <ifaddrs.h>
 
 /* Hackery at it's finest. */
 #ifndef s6_addr32
-#  define s6_addr32 __u6_addr.__u6_addr32
+#  ifdef __sun
+#    define s6_addr32  _S6_un._S6_u32
+#  else
+#    define s6_addr32  __u6_addr.__u6_addr32
+#  endif
 #endif
 
 struct ipv6_ctx *