Bring over configure imporvements from dhcpcd.
authorRoy Marples <roy@marples.name>
Mon, 5 May 2014 21:46:52 +0000 (21:46 +0000)
committerRoy Marples <roy@marples.name>
Mon, 5 May 2014 21:46:52 +0000 (21:46 +0000)
Remove .gitignore files.
Clean up -Wconversion errors.
Don't report RA without a prefix.
Support DHCPv6.

38 files changed:
.gitignore [deleted file]
GNUmakefile [new file with mode: 0644]
Makefile
config-null.mk [new file with mode: 0644]
configure
iconfig.mk [new file with mode: 0644]
icons/.gitignore [deleted file]
icons/16x16/Makefile
icons/16x16/Makefile.inc
icons/22x22/Makefile
icons/22x22/Makefile.inc
icons/24x24/Makefile
icons/24x24/Makefile.inc
icons/32x32/Makefile
icons/32x32/Makefile.inc
icons/48x48/Makefile
icons/48x48/Makefile.inc
icons/scalable/Makefile
icons/scalable/Makefile.inc
mk/lib.mk
mk/prog.mk
mk/subdir.mk
src/.gitignore [deleted file]
src/Makefile
src/dhcpcd-gtk/.gitignore [deleted file]
src/dhcpcd-gtk/Makefile
src/dhcpcd-gtk/main.c
src/dhcpcd-gtk/menu.c
src/dhcpcd-gtk/prefs.c
src/dhcpcd-gtk/wpa.c
src/libdhcpcd/.gitignore [deleted file]
src/libdhcpcd/Makefile
src/libdhcpcd/config.c
src/libdhcpcd/dispatch.c
src/libdhcpcd/libdhcpcd.h
src/libdhcpcd/main.c
src/libdhcpcd/misc.c
src/libdhcpcd/wpa.c

diff --git a/.gitignore b/.gitignore
deleted file mode 100644 (file)
index 50f50fa..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-config.h
-config.mk
-dhcpcd-ui-*.tar.bz2
diff --git a/GNUmakefile b/GNUmakefile
new file mode 100644 (file)
index 0000000..4bc845a
--- /dev/null
@@ -0,0 +1,4 @@
+# Nasty hack so that make clean works without configure being run
+CONFIG_MK?=$(shell test -e config.mk && echo config.mk || echo config-null.mk)
+
+include Makefile
index 7cd4953fad4988403c76eb437532de971b7483fc..e1682bbd3b92b2ebb9c8b35a8d9b52062505d5f2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@ VERSION=        0.6.0
 SUBDIR=                src icons
 
 TOPDIR=                .
-include ${TOPDIR}/config.mk
+include ${TOPDIR}/iconfig.mk
 include ${MKDIR}/subdir.mk
 
 GITREF?=       HEAD
@@ -21,6 +21,9 @@ SNAP=         ${_SNAP}$(shell ${_SNAP_SH})
 SNAPDIR=       ${DISTPREFIX}-${SNAP}
 SNAPFILE=      ${SNAPDIR}.tar.bz2
 
+proginstall:
+       cd src && make $@
+
 dist:
        mkdir /tmp/${DISTPREFIX}
        cp -RPp * /tmp/${DISTPREFIX}
diff --git a/config-null.mk b/config-null.mk
new file mode 100644 (file)
index 0000000..2d5d3b1
--- /dev/null
@@ -0,0 +1,2 @@
+# This space left intentionally blank
+MKDIR=         ${TOPDIR}/mk
index 487e71512eb6f216e51564ed8ce60e3802870a3f..6be180d62798ac25087a8c30e78ebd790c7dffcf 100755 (executable)
--- a/configure
+++ b/configure
@@ -86,52 +86,40 @@ CONFIG_H=config.h
 CONFIG_MK=config.mk
 
 if [ -z "$BUILD" ]; then
-       BUILD=`uname -m`-unknown-`uname -s | tr '[:upper:]' '[:lower:]'`
-fi
-if [ -z "$HOST" ]; then
-       [ -z "$TARGET" ] && TARGET=$BUILD
-       HOST=$TARGET
-fi
-if [ -z "$TARGET" ]; then
-       [ -z "$HOST" ] && HOST=$BUILD
-       TARGET=$HOST
-fi
-
-# Debian and Slackware have linux in different places when dealing with
-# autoconf, so we deal with that here.
-if [ -z "$OS" ]; then
-       case "$TARGET" in
-       *-linux-*|linux-*|*-linux|linux) OS=linux;;
-       esac
+       # autoconf target triplet: cpu-vendor-os
+       BUILD=$(uname -m)-unknown-$(uname -s | tr '[:upper:]' '[:lower:]')
 fi
+: ${HOST:=$BUILD}
 
 if [ -z "$OS" ]; then
-       # Derive OS from cpu-manufacturer-os-kernel
-       CPU=${TARGET%%-*}
-       REST=${TARGET#*-}
+       echo "Deriving operating system from ... $HOST"
+       # Derive OS from cpu-vendor-[kernel-]os
+       CPU=${HOST%%-*}
+       REST=${HOST#*-}
        if [ "$CPU" != "$REST" ]; then
-               MANU=${REST%%-*}
+               VENDOR=${REST%%-*}
                REST=${REST#*-}
-               if [ "$MANU" != "$REST" ]; then
+               if [ "$VENDOR" != "$REST" ]; then
+                       # Use kernel if given, otherwise os
                        OS=${REST%%-*}
-                       REST=${REST#*-}
-                       if [ "$OS" != "$REST" ]; then
-                               KERNEL=${REST%%-*}
-                       else
-                               # 3 tupple
-                               KERNEL=$OS
-                               OS=$MANU
-                               MANU=
-                       fi
                else
                        # 2 tupple
-                       OS=$MANU
-                       MANU=
+                       OS=$VENDOR
+                       VENDOR=
                fi
        fi
+
+        # Work with cpu-kernel-os, ie Debian
+       case "$VENDOR" in
+       linux*|kfreebsd*) OS=$VENDOR; VENDOR= ;;
+       esac
+       # Special case
+       case "$OS" in
+       gnu*) OS=hurd;; # No HURD support as yet
+       esac
 fi
 
-echo "Configuring dhcpcd-ui for ... $OS"
+echo "Configuring dhcpcd for ... $OS"
 rm -f $CONFIG_H $CONFIG_MK
 echo "# $OS" >$CONFIG_MK
 echo "/* $OS */" >$CONFIG_H
@@ -152,61 +140,84 @@ for x in PREFIX SYSCONFDIR BINDIR ICONDIR; do
 done
 echo "MANDIR=          ${MANDIR}" >>$CONFIG_MK
 
-if [ -z "$CC" ]; then
-       printf "Looking for compiler ... "
-       for b in $TARGET- ""; do
-               for cc in gcc clang pcc icc cc; do
-                       if type $b$cc >/dev/null 2>&1; then
-                               CC=$b$cc
-                               echo "$CC"
-                               break
-                       fi
-               done
-               [ -n "$CC" ] && break
-       done
-       if [ -z "$CC" ]; then
-               echo
-               echo "no suitable compiler found - aborting" >&2
-               exit 1
-       fi
+# Always obey CC.
+# However, if CC is not specified and we are given GNU style
+# --host or --build targets the expectation is we try and match that
+# to a compiler.
+if [ -n "$CC" ]; then
+       HOSTCC=
 else
-       echo "Using compiler $CC"
+       CC=cc
+       _COMPILERS="cc clang gcc pcc icc"
+fi
+if [ -n "$HOSTCC" ]; then
+       for _CC in $_COMPILERS; do
+               _CC=$(_which "$HOSTCC$_CC")
+               if [ -x "$_CC" ]; then
+                       CC=$_CC
+                       break
+               fi
+       done
+fi
+if ! type "$CC" >/dev/null 2>&1; then
+       for _CC in $_COMPILERS; do
+               _CC=$(_which "$_CC")
+               if [ -x "$_CC" ]; then
+                       CC=$_CC
+                       break
+               fi
+       done
 fi
-echo "CC=              $CC" >>$CONFIG_MK
 
-if [ -z "$CFLAGS" ]; then
-       CFLAGS="-O2"
+echo "Using compiler .. $CC"
+if ! type "$CC" >/dev/null 2>&1; then
+       echo "$CC is not an executable"
+       exit 1
+fi
+[ "$CC" != cc ] && echo "CC=   $CC" >>$CONFIG_MK
+$CC --version | $SED -e '1!d'
+
+# Set to blank, then append user config
+# We do this so our SED call to append to XCC remains portable
+if [ -n "$CFLAGS" ]; then
+       echo "CFLAGS=" >>$CONFIG_MK
+       echo "CFLAGS+=  $CFLAGS" >>$CONFIG_MK
 fi
-echo "CFLAGS=          $CFLAGS" >>$CONFIG_MK
-if [ -n "$CPPLAGS" ]; then
-       echo "CPPLAGS=          $CPPLAGS" >>$CONFIG_MK
+if [ -n "$CPPFLAGS" ]; then
+       echo "CPPFLAGS=" >>$CONFIG_MK
+       echo "CPPFLAGS+=        $CPPFLAGS" >>$CONFIG_MK
 fi
+if [ -n "$LDFLAGS" ]; then
+       echo "LDFLAGS=" >>$CONFIG_MK
+       echo "LDFLAGS+= $LDFLAGS" >>$CONFIG_MK
+fi
+
 for x in $INCLUDEDIR; do
        echo "CPPFLAGS+=        -I$x" >>$CONFIG_MK
 done
 
-if [ -n "$DEBUG" -a "$DEBUG" != no -a "$DEBUG" != false ]; then
-       echo "Enabling memory debugging"
-       echo "CPPFLAGS+=        -DDEBUG_MEMORY" >>$CONFIG_MK
-elif [ -z "$DEBUG" -a -d .git ]; then
-       printf "Found git ... "
+if [ -z "$DEBUG" -a -f .fslckout ]; then
+       printf "Found fossil checkout ... "
        DEBUG=yes
-       echo "LDADD+=           -Wl,-rpath=../libdhcpcd" >>$CONFIG_MK
 else
        DEBUG=no
 fi
 if [ "$DEBUG" != no -a "$DEBUG" != false ]; then
        echo "Adding debugging CFLAGS"
        cat <<EOF >>$CONFIG_MK
-CFLAGS+=       -Wall -Wextra -Wimplicit -Wshadow -Wformat=2
+CFLAGS+=       -g -Wall -Wextra -Wshadow -Wformat=2
 CFLAGS+=       -Wmissing-prototypes -Wmissing-declarations
 CFLAGS+=       -Wmissing-noreturn -Wmissing-format-attribute
-CFLAGS+=       -Wredundant-decls  -Wnested-externs
+CFLAGS+=       -Wnested-externs
 CFLAGS+=       -Winline -Wwrite-strings -Wcast-align -Wcast-qual
-CFLAGS+=       -Wpointer-arith
-CFLAGS+=       -Wdeclaration-after-statement -Wsequence-point
-CFLAGS+=       -fno-common
+CFLAGS+=       -Wpointer-arith -Wstrict-overflow
+CFLAGS+=       -Wdeclaration-after-statement
+CFLAGS+=       -Wconversion
 EOF
+       case "$OS" in
+       mirbsd*|openbsd*);; # OpenBSD has many redundant decs in system headers
+       *)              echo "CFLAGS+=  -Wredundant-decls" >>$CONFIG_MK;;
+       esac
 fi
 
 # Add CPPFLAGS and CFLAGS to CC for testing features
diff --git a/iconfig.mk b/iconfig.mk
new file mode 100644 (file)
index 0000000..b7b42f9
--- /dev/null
@@ -0,0 +1,6 @@
+# Nasty hack so that make clean works without configure being run
+# Requires gmake4
+_CONFIG_MK!=   test -e ${TOPDIR}/config.mk && echo config.mk || echo config-null.mk
+CONFIG_MK?=    ${_CONFIG_MK}
+TOP?=          .
+include                ${TOPDIR}/${CONFIG_MK}
diff --git a/icons/.gitignore b/icons/.gitignore
deleted file mode 100644 (file)
index e33609d..0000000
+++ /dev/null
@@ -1 +0,0 @@
-*.png
index 7c5539326ddc7423dabe5f4a2196153c9b5cae9e..61a626da7f463d863f7cd6ad18d2c4fe192c05fe 100644 (file)
@@ -1,5 +1,5 @@
 SUBDIR=        actions devices status
 
 TOPDIR=                ../..
-include ${TOPDIR}/config.mk
+include ${TOPDIR}/iconfig.mk
 include ${MKDIR}/subdir.mk
index 7f57c00abc33b40786f4b70c26d596d059e4af8c..b85b45f5016129ded28f63ba369f0c0654f3464e 100644 (file)
@@ -7,5 +7,5 @@ VPATH+=         ${SRCDIR}/${CATEGORY}
 SIZE=          16
 
 TOPDIR=                ../../..
-include ${TOPDIR}/config.mk
+include ${TOPDIR}/iconfig.mk
 include ${MKDIR}/icon.mk
index 7c5539326ddc7423dabe5f4a2196153c9b5cae9e..61a626da7f463d863f7cd6ad18d2c4fe192c05fe 100644 (file)
@@ -1,5 +1,5 @@
 SUBDIR=        actions devices status
 
 TOPDIR=                ../..
-include ${TOPDIR}/config.mk
+include ${TOPDIR}/iconfig.mk
 include ${MKDIR}/subdir.mk
index 5a975b459d21d2f043c6d6503d6f97073e1b73cc..1282fd53f5dc1b1c6df172e70625f969d1b568aa 100644 (file)
@@ -7,5 +7,5 @@ VPATH+=         ${SRCDIR}/${CATEGORY}
 SIZE=          22
 
 TOPDIR=         ../../..
-include ${TOPDIR}/config.mk
+include ${TOPDIR}/iconfig.mk
 include ${MKDIR}/icon.mk
index 7c5539326ddc7423dabe5f4a2196153c9b5cae9e..61a626da7f463d863f7cd6ad18d2c4fe192c05fe 100644 (file)
@@ -1,5 +1,5 @@
 SUBDIR=        actions devices status
 
 TOPDIR=                ../..
-include ${TOPDIR}/config.mk
+include ${TOPDIR}/iconfig.mk
 include ${MKDIR}/subdir.mk
index 2089aa104b41e5d074c94b190314994a7d0740e7..7cb819a7644d7b63843f8f3abd8803c8a32a6e58 100644 (file)
@@ -7,5 +7,5 @@ VPATH+=         ${SRCDIR}/${CATEGORY}
 SIZE=          24
 
 TOPDIR=         ../../..
-include ${TOPDIR}/config.mk
+include ${TOPDIR}/iconfig.mk
 include ${MKDIR}/icon.mk
index 7c5539326ddc7423dabe5f4a2196153c9b5cae9e..61a626da7f463d863f7cd6ad18d2c4fe192c05fe 100644 (file)
@@ -1,5 +1,5 @@
 SUBDIR=        actions devices status
 
 TOPDIR=                ../..
-include ${TOPDIR}/config.mk
+include ${TOPDIR}/iconfig.mk
 include ${MKDIR}/subdir.mk
index cfd884766f0758ff1a4503dad563ec2b36c697e4..51311c9c5990fbaafa9dda010dac385f8c123835 100644 (file)
@@ -7,5 +7,5 @@ VPATH+=         ${SRCDIR}/${CATEGORY}
 SIZE=          32
 
 TOPDIR=         ../../..
-include ${TOPDIR}/config.mk
+include ${TOPDIR}/iconfig.mk
 include ${MKDIR}/icon.mk
index 7c5539326ddc7423dabe5f4a2196153c9b5cae9e..61a626da7f463d863f7cd6ad18d2c4fe192c05fe 100644 (file)
@@ -1,5 +1,5 @@
 SUBDIR=        actions devices status
 
 TOPDIR=                ../..
-include ${TOPDIR}/config.mk
+include ${TOPDIR}/iconfig.mk
 include ${MKDIR}/subdir.mk
index fd1c9a29b25d408570dd68d3d4d093ad3c398d8f..87fb3121684cfcb79b79ac5f685c59d26d143791 100644 (file)
@@ -7,5 +7,5 @@ VPATH+=         ${SRCDIR}/${CATEGORY}
 SIZE=          48
 
 TOPDIR=         ../../..
-include ${TOPDIR}/config.mk
+include ${TOPDIR}/iconfig.mk
 include ${MKDIR}/icon.mk
index 7c5539326ddc7423dabe5f4a2196153c9b5cae9e..61a626da7f463d863f7cd6ad18d2c4fe192c05fe 100644 (file)
@@ -1,5 +1,5 @@
 SUBDIR=        actions devices status
 
 TOPDIR=                ../..
-include ${TOPDIR}/config.mk
+include ${TOPDIR}/iconfig.mk
 include ${MKDIR}/subdir.mk
index 78ffc47c7768bb1af683b7ab3add10ce655930c3..dee02aca7f284db27b56737c76821cb0643db89c 100644 (file)
@@ -2,5 +2,5 @@ SIZE=           scalable
 SIZEDIR=       scalable
 
 TOPDIR=                ../../..
-include ${TOPDIR}/config.mk
+include ${TOPDIR}/iconfig.mk
 include ${MKDIR}/icon.mk
index 6ed2b5aa61162348d38cef92bee01c22fa0493d9..81a859856a4ed4056bca73bcb70c83c7bff06d04 100644 (file)
--- a/mk/lib.mk
+++ b/mk/lib.mk
@@ -1,6 +1,6 @@
 # rules to build a library
 
-include ${TOPDIR}/config.mk
+include ${TOPDIR}/iconfig.mk
 
 SHLIB=                 lib${LIB}.so.${SHLIB_MAJOR}
 SHLIB_LINK=            lib${LIB}.so
@@ -48,6 +48,8 @@ _libinstall:  all
 
 install: ${LIBINSTALL}
 
+proginstall: install
+
 clean:
        rm -f ${OBJS} ${SOBJS} ${LIBS} ${SHLIB_LINK} ${CLEANFILES}
 
index 7844bfa2d33b6e28173c2b60ac22d0a844439e64..38d91b189c2b114313e8c4f971b515d218cc75d1 100644 (file)
@@ -14,7 +14,7 @@ all: ${PROG} ${SCRIPTS}
 ${PROG}: .depend ${OBJS}
        ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LDADD}
 
-_proginstall: ${PROG}
+proginstall: ${PROG}
        ${INSTALL} -d ${DESTDIR}${BINDIR}
        ${INSTALL} -m ${BINMODE} ${PROG} ${DESTDIR}${BINDIR}
 
@@ -23,7 +23,7 @@ include ${MKDIR}/depend.mk
 include ${MKDIR}/files.mk
 include ${MKDIR}/man.mk
 
-install: _proginstall _filesinstall _maninstall
+install: proginstall _filesinstall _maninstall
 
 clean:
        rm -f ${OBJS} ${PROG} ${PROG}.core ${CLEANFILES}
index cf9628db76aeb6f4ee40d1f85ce34f41071e01e0..79848f678ac45cc2c38f602b17f45cfa21efca8a 100644 (file)
@@ -22,6 +22,8 @@ clean:
        ${_SUBDIR}
 realinstall:
        ${_SUBDIR}
+proginstall:
+       ${_SUBDIR}
 install: realinstall ${INSTALLAFTER}
 check test::
        ${_SUBDIR}
diff --git a/src/.gitignore b/src/.gitignore
deleted file mode 100644 (file)
index 1de497b..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-*.o
-.depend
index ce054e311c703d3d8ed527dd7ddb6267a5f6ea82..cf96e6292ee2238685eb469e5a226a7d49f035ba 100644 (file)
@@ -1,5 +1,5 @@
 TOPDIR=                ..
-include ${TOPDIR}/config.mk
+include ${TOPDIR}/iconfig.mk
 
 SUBDIR=                libdhcpcd ${UI}
 
diff --git a/src/dhcpcd-gtk/.gitignore b/src/dhcpcd-gtk/.gitignore
deleted file mode 100644 (file)
index 8a3cebd..0000000
+++ /dev/null
@@ -1 +0,0 @@
-dhcpcd-gtk
index 95b2fdce5a86ca55d7fdfefa48d7b30d512a057b..75eec7d3341755e7943706443886a14d81bad4cd 100644 (file)
@@ -2,7 +2,7 @@ PROG=           dhcpcd-gtk
 SRCS=          main.c menu.c prefs.c wpa.c
 
 TOPDIR=                ../..
-include ${TOPDIR}/config.mk
+include ${TOPDIR}/iconfig.mk
 
 ICONDIR?=      ${PREFIX}/share/dhcpcd/icons
 AUTOSTARTDIR?= ${PREFIX}/share/gnome/autostart
index 1a349e9af20cf217ab6efc310ac06698cc5a7b78..62066d72f038443948c305621d862a0e41f41beb 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * dhcpcd-gtk
- * Copyright 2009-2012 Roy Marples <roy@marples.name>
+ * Copyright 2009-2014 Roy Marples <roy@marples.name>
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -41,14 +41,14 @@ static NotifyNotification *nn;
 #include "dhcpcd-gtk.h"
 
 static GtkStatusIcon *status_icon;
-static int ani_timer;
+static guint ani_timer;
 static int ani_counter;
 static bool online;
 static bool carrier;
 
 struct watch {
        struct pollfd pollfd;
-       int eventid;
+       guint eventid;
        GIOChannel *gio;
        struct watch *next;
 };
@@ -76,7 +76,7 @@ static gboolean
 animate_carrier(_unused gpointer data)
 {
        const char *icon;
-       
+
        if (ani_timer == 0)
                return false;
 
@@ -100,7 +100,7 @@ static gboolean
 animate_online(_unused gpointer data)
 {
        const char *icon;
-       
+
        if (ani_timer == 0)
                return false;
 
@@ -152,13 +152,15 @@ update_online(DHCPCD_CONNECTION *con, bool showif)
                if (!iscarrier && g_strcmp0(i->reason, "CARRIER") == 0)
                        iscarrier = true;
                msg = dhcpcd_if_message(i);
-               if (msgs) {
-                       tmp = g_strconcat(msgs, "\n", msg, NULL);
-                       g_free(msgs);
-                       g_free(msg);
-                       msgs = tmp;
-               } else
-                       msgs = msg;
+               if (msg) {
+                       if (msgs) {
+                               tmp = g_strconcat(msgs, "\n", msg, NULL);
+                               g_free(msgs);
+                               g_free(msg);
+                               msgs = tmp;
+                       } else
+                                   msgs = msg;
+               }
        }
 
        if (online != ison || carrier != iscarrier) {
@@ -206,9 +208,12 @@ notify(const char *title, const char *msg, const char *icon)
 {
        char **msgs, **m;
 
+       if (msg == NULL)
+               return;
        /* Don't spam the same message */
        if (notify_last_msg) {
-               if (strcmp(msg, notify_last_msg) == 0)
+                       return;
+               if (notify_last_msg && strcmp(msg, notify_last_msg) == 0)
                        return;
                g_free(notify_last_msg);
        }
@@ -250,7 +255,7 @@ event_cb(DHCPCD_CONNECTION *con, DHCPCD_IF *i, _unused void *data)
 
        g_message("%s: %s", i->ifname, i->reason);
        update_online(con, false);
-       
+
        /* We should ignore renew and stop so we don't annoy the user */
        if (g_strcmp0(i->reason, "RENEW") == 0 ||
            g_strcmp0(i->reason, "STOP") == 0)
@@ -398,11 +403,12 @@ add_watch_cb(DHCPCD_CONNECTION *con, const struct pollfd *fd,
 {
        struct watch *w;
        GIOChannel *gio;
-       int flags, eventid;
+       int flags;
+       guint eventid;
 
        /* Remove any existing watch */
        delete_watch_cb(con, fd, data);
-       
+
        gio = g_io_channel_unix_new(fd->fd);
        if (gio == NULL) {
                g_warning(_("Error creating new GIO Channel\n"));
@@ -436,7 +442,7 @@ main(int argc, char *argv[])
        char *error = NULL;
        char *version = NULL;
        DHCPCD_CONNECTION *con;
-               
+
        setlocale(LC_ALL, "");
        bindtextdomain(PACKAGE, NULL);
        bind_textdomain_codeset(PACKAGE, "UTF-8");
index 16c1d5995570af9ce77fd6adc27ecb0607213e36..0f410aca0bc0d9a021f5664a40232ceaa5c6956c 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * dhcpcd-gtk
- * Copyright 2009-2012 Roy Marples <roy@marples.name>
+ * Copyright 2009-2014 Roy Marples <roy@marples.name>
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #include "config.h"
 #include "dhcpcd-gtk.h"
 
-static const char *copyright = "Copyright (c) 2009-2012 Roy Marples";
+static const char *copyright = "Copyright (c) 2009-2013 Roy Marples";
 static const char *authors[] = { "Roy Marples <roy@marples.name>", NULL };
 
 static void
 on_pref(_unused GObject *o, gpointer data)
 {
+
        dhcpcd_prefs_show((DHCPCD_CONNECTION *)data);
 }
 
 static void
 on_quit(void)
 {
+
        gtk_main_quit();
 }
 
@@ -85,6 +87,7 @@ ssid_hook(_unused GtkMenuItem *item, gpointer data)
 static void
 on_about(_unused GtkMenuItem *item)
 {
+
        gtk_window_set_default_icon_name("network-transmit-receive");
 #if GTK_MAJOR_VERSION == 2
        gtk_about_dialog_set_email_hook(email_hook, NULL, NULL);
@@ -244,6 +247,7 @@ on_popup(GtkStatusIcon *icon, guint button, guint32 atime, gpointer data)
 void
 menu_init(GtkStatusIcon *icon, DHCPCD_CONNECTION *con)
 {
+
        g_signal_connect(G_OBJECT(icon), "activate",
            G_CALLBACK(on_activate), con);
        g_signal_connect(G_OBJECT(icon), "popup_menu",
index 45148f846e4f560a81662478eb2b0cd6f170d85f..642d5ffa151bc41c4fbeaebedb68968b3646904c 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * dhcpcd-gtk
- * Copyright 2009-2012 Roy Marples <roy@marples.name>
+ * Copyright 2009-2014 Roy Marples <roy@marples.name>
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -115,22 +115,22 @@ make_config(DHCPCD_CONFIG **conf)
                set_option(conf, false, "inform", a ? val : NULL, &ret);
                set_option(conf, true, "ip_address=", a ? NULL : val, &ret);
        }
-       
+
        val = gtk_entry_get_text(GTK_ENTRY(router));
        if (a && *val == '\0')
                val = NULL;
        set_option(conf, true, "routers=", val, &ret);
-       
+
        val = gtk_entry_get_text(GTK_ENTRY(dns_servers));
        if (a && *val == '\0')
                val = NULL;
        set_option(conf, true, "domain_name_servers=", val, &ret);
-       
+
        val = gtk_entry_get_text(GTK_ENTRY(dns_search));
        if (a && *val == '\0')
                val = NULL;
        set_option(conf, true, "domain_search=", val, &ret);
-       
+
        return ret;
 }
 
@@ -227,7 +227,7 @@ blocks_on_change(GtkWidget *widget, gpointer data)
        store = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(names)));
        gtk_list_store_clear(store);
        list = dhcpcd_config_blocks_get(con, block);
-       
+
        if (g_strcmp0(block, "interface") == 0)
                new_names = list_interfaces(con);
        else
@@ -328,13 +328,12 @@ valid_address(const char *val, bool allow_cidr)
                }
        }
        retval = inet_aton(addr, &in) == 0 ? false : true;
-       
+
 out:
        g_free(addr);
        return retval;
 }
 
-       
 static bool
 address_lost_focus(GtkEntry *entry)
 {
@@ -406,6 +405,7 @@ on_rebind(_unused GObject *widget, gpointer data)
 static void
 on_destroy(_unused GObject *o, gpointer data)
 {
+
        if (name != NULL) {
                if (make_config(&config))
                        dhcpcd_config_save((DHCPCD_CONNECTION *)data,
@@ -456,7 +456,7 @@ dhcpcd_prefs_show(DHCPCD_CONNECTION *con)
        GtkTreeIter iter;
        GtkCellRenderer *rend;
        GdkPixbuf *pb;
-       
+
        if (dialog) {
                gtk_window_present(GTK_WINDOW(dialog));
                return;
@@ -520,7 +520,7 @@ dhcpcd_prefs_show(DHCPCD_CONNECTION *con)
            G_CALLBACK(blocks_on_change), con);
        g_signal_connect(G_OBJECT(names), "changed",
            G_CALLBACK(names_on_change), con);
-       
+
        w = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
        gtk_box_pack_start(GTK_BOX(dialog_vbox), w, true, false, 3);
        controls = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
@@ -543,7 +543,7 @@ dhcpcd_prefs_show(DHCPCD_CONNECTION *con)
 #define attach_entry(a, b, c, d, e)                                          \
        gtk_table_attach(GTK_TABLE(table), a, b, c, d, e,                     \
            GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_FILL | GTK_SHRINK, 3, 3);
-       
+
        w = gtk_label_new(_("IP Address:"));
        address = gtk_entry_new();
        gtk_entry_set_max_length(GTK_ENTRY(address), 18);
@@ -591,9 +591,8 @@ dhcpcd_prefs_show(DHCPCD_CONNECTION *con)
        gtk_box_pack_end(GTK_BOX(hbox), w, false, false, 0);
        g_signal_connect(G_OBJECT(w), "clicked",
            G_CALLBACK(dhcpcd_prefs_close), NULL);
-       
+
        blocks_on_change(blocks, con);
        show_config(NULL);
        gtk_widget_show_all(dialog);
 }
-
index 36ee133aeaaeb8a7586d9a5f71b6ba168e88d626..6459709fc3c800fe29a8c02205ded7248f96517b 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * dhcpcd-gtk
- * Copyright 2009 Roy Marples <roy@marples.name>
+ * Copyright 2009-2014 Roy Marples <roy@marples.name>
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -127,7 +127,7 @@ wpa_configure(DHCPCD_CONNECTION *con, DHCPCD_IF *i, DHCPCD_WI_SCAN *s)
        gtk_widget_show_all(dialog);
 again:
        result = gtk_dialog_run(GTK_DIALOG(dialog));
-       
+
        id = -1;
        retval = false;
        if (result == GTK_RESPONSE_ACCEPT) {
diff --git a/src/libdhcpcd/.gitignore b/src/libdhcpcd/.gitignore
deleted file mode 100644 (file)
index 312f1bb..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-*.So
-*.so
-libdhcpcd.a
-libdhcpcd.so.1
index 7115d8559f3b40bb3d20baa2fc733f059112e637..977482479b63b650f9ddda306d518bc172f90f8e 100644 (file)
@@ -4,7 +4,7 @@ SRCS=           main.c config.c dispatch.c misc.c wpa.c
 INCS=          libdhcpcd.h
 
 TOPDIR=                ../..
-include ${TOPDIR}/config.mk
+include ${TOPDIR}/iconfig.mk
 
 CPPFLAGS+=     -I${TOPDIR} ${DBUS_CFLAGS}
 CFLAGS+=       ${DBUS_CFLAGS}
index 4f22464b84965f1a8d9b16f0407609cf2623538e..dcd4bed59cb35eec5c8155d8971e13bb9bbc3d76 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * libdhcpcd
- * Copyright 2009 Roy Marples <roy@marples.name>
+ * Copyright 2009-2014 Roy Marples <roy@marples.name>
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -62,7 +62,7 @@ void
 dhcpcd_config_free(DHCPCD_CONFIG *config)
 {
        DHCPCD_CONFIG *c;
-       
+
        while (config) {
                c = config->next;
                free(config->option);
@@ -70,7 +70,7 @@ dhcpcd_config_free(DHCPCD_CONFIG *config)
                free(config);
                config = c;
        }
-}      
+}
 
 char **
 dhcpcd_config_blocks_get(DHCPCD_CONNECTION *con, const char *block)
@@ -104,7 +104,7 @@ dhcpcd_config_blocks_get(DHCPCD_CONNECTION *con, const char *block)
                dbus_error_free(&error);
        }
        dbus_message_unref(reply);
-       return blocks;  
+       return blocks;
 }
 
 DHCPCD_CONFIG *
index 84ddce64d8110d7590d5ffdca2cd93842148830a..5243059aa374a355b7682ceaa300a7ff7f18cde6 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * libdhcpcd
- * Copyright 2009-2012 Roy Marples <roy@marples.name>
+ * Copyright 2009-2014 Roy Marples <roy@marples.name>
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
index 939f40670d4421c135c622bb9fdcec3b37c60840..ba86b89354702e62491a8feb310222925d33edf0 100644 (file)
@@ -60,14 +60,15 @@ typedef struct dhcpcd_if {
        char ifname[IF_NAMESIZE];
        char type[TYPESIZE];
        unsigned int flags;
+       bool wireless;
+       char ssid[IF_SSIDSIZE];
        bool up;
        char reason[REASONSIZE];
        struct in_addr ip;
        struct in6_addr prefix;
        int prefix_len;
        unsigned char cidr;
-       bool wireless;
-       char ssid[IF_SSIDSIZE];
+       struct in6_addr ip6;
 } DHCPCD_IF;
 
 /* Although we use DBus, we don't have to rely on it for our API */
index 5cba838693ca0e0788d3de9d36242d30c550d095..f1d3c2a82aee841f462fa77a4c58768a4ce390a9 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * libdhcpcd
- * Copyright 2009-2012 Roy Marples <roy@marples.name>
+ * Copyright 2009-2014 Roy Marples <roy@marples.name>
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -55,11 +55,12 @@ static dbus_bool_t
 dhcpcd_add_watch(DBusWatch *watch, void *data)
 {
        DHCPCD_WATCH *w;
-       int flags;
+       int fd;
+       unsigned int flags;
 
-       flags = dbus_watch_get_unix_fd(watch);
+       fd = dbus_watch_get_unix_fd(watch);
        for (w = dhcpcd_watching; w; w = w->next) {
-               if (w->pollfd.fd == flags)
+               if (w->pollfd.fd == fd)
                        break;
        }
        if (w == NULL) {
@@ -72,7 +73,7 @@ dhcpcd_add_watch(DBusWatch *watch, void *data)
 
        w->connection = (DHCPCD_CONNECTION *)data;
        w->watch = watch;
-       w->pollfd.fd = flags;
+       w->pollfd.fd = fd;
        flags = dbus_watch_get_flags(watch);
        w->pollfd.events = POLLHUP | POLLERR;
        if (flags & DBUS_WATCH_READABLE)
@@ -111,6 +112,7 @@ dhcpcd_delete_watch(DBusWatch *watch, void *data)
 static DBusHandlerResult
 dhcpcd_message(_unused DBusConnection *bus, DBusMessage *msg, void *data)
 {
+
        if (dhcpcd_dispatch_message((DHCPCD_CONNECTION *)data, msg))
                return DBUS_HANDLER_RESULT_HANDLED;
        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
@@ -228,6 +230,7 @@ dhcpcd_if_connection(DHCPCD_IF *interface)
 void
 dhcpcd_error_clear(DHCPCD_CONNECTION *con)
 {
+
        free(con->error);
        con->error = NULL;
        con->err = 0;
@@ -236,6 +239,7 @@ dhcpcd_error_clear(DHCPCD_CONNECTION *con)
 void
 dhcpcd_error_set(DHCPCD_CONNECTION *con, const char *error, int err)
 {
+
        dhcpcd_error_clear(con);
        if (error != NULL) {
                con->error = strdup(error);
@@ -250,6 +254,7 @@ dhcpcd_error_set(DHCPCD_CONNECTION *con, const char *error, int err)
 const char *
 dhcpcd_error(DHCPCD_CONNECTION *con)
 {
+
        return con->error;
 }
 
@@ -257,6 +262,7 @@ bool
 dhcpcd_iter_get(DHCPCD_CONNECTION *con, DBusMessageIter *iter,
     int type, void *arg)
 {
+
        if (dbus_message_iter_get_arg_type(iter) == type) {
                dbus_message_iter_get_basic(iter, arg);
                dbus_message_iter_next(iter);
@@ -271,7 +277,7 @@ dhcpcd_message_error(DHCPCD_CONNECTION *con, DHCPCD_MESSAGE *msg)
 {
        DBusMessageIter args;
        char *s;
-       
+
        if (dbus_message_get_type(msg) != DBUS_MESSAGE_TYPE_ERROR)
                return false;
        if (dbus_message_iter_init(msg, &args) &&
@@ -312,7 +318,7 @@ dhcpcd_message_reply(DHCPCD_CONNECTION *con, const char *cmd, const char *arg)
 {
        DBusMessage *msg, *reply;
        DBusMessageIter args;
-       
+
        msg = dbus_message_new_method_call(DHCPCD_SERVICE, DHCPCD_PATH,
            DHCPCD_SERVICE, cmd);
        if (msg == NULL) {
@@ -363,13 +369,12 @@ dhcpcd_dispatch(int fd)
 {
        DHCPCD_WATCH *w;
        struct pollfd fds;
-       int n, flags;
+       unsigned int flags;
 
+       flags = 0;
        fds.fd = fd;
        fds.events = (POLLIN | POLLHUP | POLLOUT | POLLERR);
-       n = poll(&fds, 1, 0);
-       flags = 0;
-       if (n == 1) {
+       if (poll(&fds, 1, 0) == 1) {
                if (fds.revents & POLLIN)
                        flags |= DBUS_WATCH_READABLE;
                if (fds.revents & POLLOUT)
@@ -395,11 +400,12 @@ dhcpcd_dispatch(int fd)
 DHCPCD_IF *
 dhcpcd_if_new(DHCPCD_CONNECTION *con, DBusMessageIter *array, char **order)
 {
-       DBusMessageIter dict, entry, var, a;
+       DBusMessageIter dict, entry, var, a;
        DHCPCD_IF *i;
        char *s, *p;
        uint32_t u32;
        int b, errors;
+       size_t l;
 
        if (dbus_message_iter_get_arg_type(array) != DBUS_TYPE_ARRAY) {
                errno = EINVAL;
@@ -443,7 +449,11 @@ dhcpcd_if_new(DHCPCD_CONNECTION *con, DBusMessageIter *array, char **order)
                } else if (strcmp(s, "Reason") == 0) {
                        if (!dhcpcd_iter_get(con, &var, DBUS_TYPE_STRING, &s))
                                break;
+
                        strlcpy(i->reason, s, sizeof(i->reason));
+                       l = strlen(i->reason);
+                       if (l != 0 && i->reason[l - 1] == '6')
+                               i->reason[l - 1] = '\0';
                } else if (strcmp(s, "Wireless") == 0) {
                        if (!dhcpcd_iter_get(con, &var, DBUS_TYPE_BOOLEAN, &b))
                                break;
@@ -460,7 +470,7 @@ dhcpcd_if_new(DHCPCD_CONNECTION *con, DBusMessageIter *array, char **order)
                        dbus_message_iter_get_basic(&var, &i->cidr);
                else if (strcmp(s, "RA_Prefix") == 0) {
                        /* Don't crash with older dhcpcd versions */
-                       if (dbus_message_iter_get_arg_type(&dict) ==
+                       if (dbus_message_iter_get_arg_type(&dict) ==
                            DBUS_TYPE_STRING)
                        {
                                if (!dhcpcd_iter_get(con, &a,
@@ -470,7 +480,7 @@ dhcpcd_if_new(DHCPCD_CONNECTION *con, DBusMessageIter *array, char **order)
                                continue;
                        }
 
-                       if (dbus_message_iter_get_arg_type(&dict) !=
+                       if (dbus_message_iter_get_arg_type(&dict) !=
                            DBUS_TYPE_DICT_ENTRY)
                                break;
                        dbus_message_iter_recurse(&var, &a);
@@ -487,10 +497,14 @@ dhcpcd_if_new(DHCPCD_CONNECTION *con, DBusMessageIter *array, char **order)
                        } else
                                i->prefix_len = 0;
                        inet_pton(AF_INET6, s, &i->prefix.s6_addr);
-               } else if (strcmp(s, "RA_PrefixLen") == 0) { 
-                       if (!dhcpcd_iter_get(con, &var, DBUS_TYPE_BYTE, &b)) 
-                               break; 
-                       i->prefix_len = b; 
+               } else if (strcmp(s, "RA_PrefixLen") == 0) {
+                       if (!dhcpcd_iter_get(con, &var, DBUS_TYPE_BYTE, &b))
+                               break;
+                       i->prefix_len = b;
+               } else if (strcmp(s, "D6_IPAddress") == 0) {
+                       if (!dhcpcd_iter_get(con, &var, DBUS_TYPE_STRING, &s))
+                               break;
+                       inet_pton(AF_INET6, s, &i->ip6.s6_addr);
                } else if (order != NULL && strcmp(s, "InterfaceOrder") == 0)
                        if (!dhcpcd_iter_get(con, &var, DBUS_TYPE_STRING, order))
                                break;
@@ -512,7 +526,7 @@ dhcpcd_interfaces(DHCPCD_CONNECTION *con)
        DBusMessageIter args, dict, entry;
        DHCPCD_IF *i, *l;
        int errors;
-       
+
        if (con->interfaces != NULL)
                return con->interfaces;
        l = NULL;
@@ -532,7 +546,7 @@ dhcpcd_interfaces(DHCPCD_CONNECTION *con)
        dbus_message_iter_recurse(&args, &dict);
        for (;
             dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY;
-            dbus_message_iter_next(&dict))    
+            dbus_message_iter_next(&dict))
        {
                dbus_message_iter_recurse(&dict, &entry);
                dbus_message_iter_next(&entry);
@@ -584,7 +598,7 @@ dhcpcd_set_watch_functions(DHCPCD_CONNECTION *con,
     void *data)
 {
        DHCPCD_WATCH *w;
-       
+
        con->add_watch = add_watch;
        con->delete_watch = delete_watch;
        con->watch_data = data;
@@ -603,7 +617,7 @@ dhcpcd_set_signal_functions(DHCPCD_CONNECTION *con,
     void *data)
 {
        DHCPCD_IF *i;
-       
+
        con->event = event;
        con->status_changed = status_changed;
        con->wi_scanresults = wi_scanresults;
index 99ec553fe9ed94ab5c43e189207e32f4f73b06f6..325fedc7180f98bf870d34bc2f45fc2d34f99ce4 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * libdhcpcd
- * Copyright 2009-2012 Roy Marples <roy@marples.name>
+ * Copyright 2009-2014 Roy Marples <roy@marples.name>
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -45,7 +45,13 @@ dhcpcd_if_message(const DHCPCD_IF *i)
        size_t len;
        bool showip, showssid;
        char buf[INET6_ADDRSTRLEN];
-    
+
+       /* Don't report non SLAAC configurations */
+       if (strcmp(i->type, "ra") == 0 &&
+           IN6_IS_ADDR_UNSPECIFIED(&i->prefix) &&
+           i->up)
+               return NULL;
+
        showip = true;
        showssid = false;
        if (strcmp(i->reason, "EXPIRE") == 0)
@@ -81,13 +87,15 @@ dhcpcd_if_message(const DHCPCD_IF *i)
                else
                        reason = i->reason;
        }
-       
+
        len = strlen(i->ifname) + 3;
        len += strlen(reason) + 1;
        if (i->ip.s_addr != 0) {
                len += 16; /* 000. * 4 */
                if (i->cidr != 0)
                        len += 3; /* /32 */
+       } else if (!IN6_IS_ADDR_UNSPECIFIED(&i->ip6)) {
+               len += INET6_ADDRSTRLEN;
        } else if (!IN6_IS_ADDR_UNSPECIFIED(&i->prefix)) {
                len += INET6_ADDRSTRLEN;
                if (i->prefix_len != 0)
@@ -96,18 +104,23 @@ dhcpcd_if_message(const DHCPCD_IF *i)
        if (showssid)
                len += strlen(i->ssid) + 1;
        msg = p = malloc(len);
+       if (msg == NULL)
+               return NULL;
        p += snprintf(msg, len, "%s: %s", i->ifname, reason);
        if (showssid)
-               p += snprintf(p, len - (p - msg), " %s", i->ssid);
+               p += snprintf(p, len - (size_t)(p - msg), " %s", i->ssid);
        if (i->ip.s_addr != 0 && showip) {
-               p += snprintf(p, len - (p - msg), " %s", inet_ntoa(i->ip));
+               p += snprintf(p, len - (size_t)(p - msg), " %s", inet_ntoa(i->ip));
                if (i->cidr != 0)
-                       snprintf(p, len - (p - msg), "/%d", i->cidr);
+                       snprintf(p, len - (size_t)(p - msg), "/%d", i->cidr);
+       } else if (!IN6_IS_ADDR_UNSPECIFIED(&i->ip6) && showip) {
+               p += snprintf(p, len - (size_t)(p - msg), " %s",
+                   inet_ntop(AF_INET6, &i->ip6, buf, INET6_ADDRSTRLEN));
        } else if (!IN6_IS_ADDR_UNSPECIFIED(&i->prefix) && showip) {
-               p += snprintf(p, len - (p - msg), " %s",
+               p += snprintf(p, len - (size_t)(p - msg), " %s",
                    inet_ntop(AF_INET6, &i->prefix, buf, INET6_ADDRSTRLEN));
                if (i->prefix_len != 0)
-                       snprintf(p, len - (p - msg), "/%d", i->prefix_len);
+                       snprintf(p, len - (size_t)(p - msg), "/%d", i->prefix_len);
        }
        return msg;
 }
index e4cab32d036d9533954924c3cf47dd75e8d73c76..68c56db7073d31345d492933936ac71d0e8e7312 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * libdhcpcd
- * Copyright 2009 Roy Marples <roy@marples.name>
+ * Copyright 2009-2014 Roy Marples <roy@marples.name>
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -176,7 +176,7 @@ dhcpcd_wi_scans(DHCPCD_CONNECTION *con, DHCPCD_IF *i)
                }
                if (nh != 1) {
                        wis->quality.average /= nh;
-                               wis->noise.average /= nh;
+                       wis->noise.average /= nh;
                        wis->level.average /= nh;
                }
                h = malloc(sizeof(*h));
@@ -224,7 +224,7 @@ dhcpcd_wpa_find_network(DHCPCD_CONNECTION *con, DHCPCD_IF *i, const char *ssid)
        }
 
        errors = con->errors;
-       for(;
+       for(;
            dbus_message_iter_get_arg_type(&args) == DBUS_TYPE_ARRAY;
            dbus_message_iter_next(&args))
        {
@@ -251,7 +251,7 @@ dhcpcd_wpa_find_network(DHCPCD_CONNECTION *con, DHCPCD_IF *i, const char *ssid)
        dbus_message_unref(msg);
        return -1;
 }
-       
+
 static int
 dhcpcd_wpa_add_network(DHCPCD_CONNECTION *con, DHCPCD_IF *i)
 {
@@ -345,7 +345,7 @@ dhcpcd_wpa_command(DHCPCD_CONNECTION *con, DHCPCD_IF *i,
        DBusMessageIter args;
        char *ifname;
        bool retval;
-       
+
        msg = dbus_message_new_method_call(DHCPCD_SERVICE, DHCPCD_PATH,
            DHCPCD_SERVICE, cmd);
        if (msg == NULL) {