From: Roy Marples Date: Sat, 24 May 2014 13:08:29 +0000 (+0000) Subject: Add a compat syslog function if the libc syslog does not support LOG_PERROR. X-Git-Tag: v6.4.0~44 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=eb33667132656e033e767dd9d4a9a2446607d6eb;p=thirdparty%2Fdhcpcd.git Add a compat syslog function if the libc syslog does not support LOG_PERROR. 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. --- diff --git a/configure b/configure index 9e9c25cc..c048c5fa 100755 --- 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 <_log_perror.c +#include +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 ... " diff --git a/dhcpcd.c b/dhcpcd.c index ac09d276..5ec6b8f0 100644 --- 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 index 00000000..a6a8323c --- /dev/null +++ b/if-sun.c @@ -0,0 +1,191 @@ +/* + * dhcpcd - DHCP client daemon + * Copyright (c) 2006-2014 Roy Marples + * 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 + +#include +#include +#include + +#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 7d04f4a0..191e263b 100644 --- a/ipv6.c +++ b/ipv6.c @@ -52,8 +52,10 @@ #ifdef __FreeBSD__ /* Needed so that including netinet6/in6_var.h works */ # include #endif +#ifndef __sun # include #endif +#endif #include #include @@ -81,7 +83,11 @@ /* 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 *