From 385d3e53254fcd390c3596f2ccdcc65cd9310757 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 11 Aug 2003 16:19:06 +0000 Subject: build fixes remove fprintfs git-svn-id: file:///home/lennart/svn/public/aeswepd/trunk@5 022f378f-78c4-0310-b860-d162c87e6274 --- bootstrap.sh | 3 +-- conf/Makefile.am | 18 ++++++++------ conf/default.in | 62 ++++++++++++++++++++++++++++++++++++++++++++++++ conf/scripts/Makefile.am | 37 ----------------------------- conf/scripts/default.in | 62 ------------------------------------------------ conf/waproamd.init.in | 4 +++- configure.ac | 7 +++--- src/Makefile.am | 5 ++++ src/aes.c | 13 +++++----- src/aeswepd.c | 6 ++--- src/ifmonitor.c | 34 +++----------------------- src/interface.c | 9 +++---- src/iwapi.c | 30 ++++++++++------------- src/iwkey.c | 12 ++++++---- src/nlapi.c | 5 ++-- src/waproamd.c | 19 +++++++-------- src/wireless.h | 2 +- 17 files changed, 133 insertions(+), 195 deletions(-) create mode 100755 conf/default.in delete mode 100644 conf/scripts/Makefile.am delete mode 100755 conf/scripts/default.in diff --git a/bootstrap.sh b/bootstrap.sh index c998385..19c60c1 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -34,6 +34,5 @@ else automake -a -c autoconf -Wall - ./configure --enabled-maintainer-mode --sysconfdir=/etc "$@" + ./configure --sysconfdir=/etc "$@" fi - diff --git a/conf/Makefile.am b/conf/Makefile.am index e5b252f..2e6973c 100644 --- a/conf/Makefile.am +++ b/conf/Makefile.am @@ -16,27 +16,31 @@ # along with waproamd; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. -SUBDIRS = scripts - if BUILD_WAPROAMD -noinst_DATA = waproamd.init waproamd.conf +noinst_DATA = waproamd.init waproamd.conf default -EXTRA_DIST = waproamd.init.in waproamd.conf +EXTRA_DIST = waproamd.init.in waproamd.conf default.in -CLEANFILES = waproamd.init +CLEANFILES = waproamd.init default waproamd.init: waproamd.init.in Makefile sed -e 's,@sysconfdir\@,$(sysconfdir),g' -e 's,@sbindir\@,$(sbindir),g' $< > $@ chmod 755 $@ +default: default.in Makefile + sed -e 's,@sysconfdir\@,$(sysconfdir),g' -e 's,@sbindir\@,$(sbindir),g' $< > $@ + chmod 755 $@ + install-data-local: waproamd.init - $(INSTALL) -D -m755 waproamd.init ${DESTDIR}/${sysconfdir}/init.d/waproamd - $(INSTALL) -D -m644 $(srcdir)/waproamd.conf ${DESTDIR}/${sysconfdir}/waproamd/waproamd.conf + $(INSTALL) -b -D -m755 waproamd.init ${DESTDIR}/${sysconfdir}/init.d/waproamd + $(INSTALL) -b -D -m644 $(srcdir)/waproamd.conf ${DESTDIR}/${sysconfdir}/waproamd/waproamd.conf mkdir -p ${DESTDIR}/${sysconfdir}/waproamd/keys + $(INSTALL) -D -m755 default ${DESTDIR}/${sysconfdir}/waproamd/scripts/default uninstall-local: rmdir ${DESTDIR}/${sysconfdir}/waproamd/keys rm -f ${DESTDIR}/${sysconfdir}/init.d/waproamd ${DESTDIR}/${sysconfdir}/waproamd/waproamd.conf + rm -f ${DESTDIR}/${sysconfdir}/waproamd/scripts/default endif diff --git a/conf/default.in b/conf/default.in new file mode 100755 index 0000000..02bdca4 --- /dev/null +++ b/conf/default.in @@ -0,0 +1,62 @@ +#!/bin/sh + +# $Id$ + +# This file is part of waproamd. +# +# waproamd is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# waproamd is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with waproamd; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + +KEYDIR="@sysconfdir@/waproamd/keys" + +if [ -z "$AP" -o -z "$IFACE" ] ; then + echo "Corrupt environment" > /dev/stderr + exit 1 +fi + +if test -r "$KEYDIR/$AP.aes" ; then + METHOD=aes +else if test -r "$KEYDIR/$AP.wep" ; then + METHOD=wep +else + METHOD=open +fi ; fi + +echo "Settings policy '$METHOD' for AP $AP" + +case "$1.$METHOD" in + start.aes) + iwconfig $IFACE key on + aeswepd -i $IFACE -w -F "$KEYDIR/$AP.aes" + ;; + + stop.aes) + aeswepd -i $IFACE -k + iwconfig $IFACE key off + ;; + + start.wep) + iwconfig $IFACE key "`cat $KEYDIR/$AP.wep`" [1] key restricted key [1] key on + ;; + + *.open|stop.wep) + iwconfig $IFACE key off + ;; + *) + echo "Unknown command\n" > /dev/stderr + exit 1 + ;; +esac + +exit 0 diff --git a/conf/scripts/Makefile.am b/conf/scripts/Makefile.am deleted file mode 100644 index 97a94d3..0000000 --- a/conf/scripts/Makefile.am +++ /dev/null @@ -1,37 +0,0 @@ -# $Id$ - -# This file is part of waproamd. -# -# waproamd is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# waproamd is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with waproamd; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - -if BUILD_WAPROAMD - -noinst_DATA = default - -EXTRA_DIST = default.in - -CLEANFILES = default - -default: default.in Makefile - sed -e 's,@sysconfdir\@,$(sysconfdir),g' -e 's,@sbindir\@,$(sbindir),g' $< > $@ - chmod 755 $@ - -install-data-local: default - $(INSTALL) -D -m755 default ${DESTDIR}/${sysconfdir}/waproamd/scripts/default - -uninstall-local: - rm -f ${DESTDIR}/${sysconfdir}/waproamd/scripts/default - -endif diff --git a/conf/scripts/default.in b/conf/scripts/default.in deleted file mode 100755 index 02bdca4..0000000 --- a/conf/scripts/default.in +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/sh - -# $Id$ - -# This file is part of waproamd. -# -# waproamd is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# waproamd is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with waproamd; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - -KEYDIR="@sysconfdir@/waproamd/keys" - -if [ -z "$AP" -o -z "$IFACE" ] ; then - echo "Corrupt environment" > /dev/stderr - exit 1 -fi - -if test -r "$KEYDIR/$AP.aes" ; then - METHOD=aes -else if test -r "$KEYDIR/$AP.wep" ; then - METHOD=wep -else - METHOD=open -fi ; fi - -echo "Settings policy '$METHOD' for AP $AP" - -case "$1.$METHOD" in - start.aes) - iwconfig $IFACE key on - aeswepd -i $IFACE -w -F "$KEYDIR/$AP.aes" - ;; - - stop.aes) - aeswepd -i $IFACE -k - iwconfig $IFACE key off - ;; - - start.wep) - iwconfig $IFACE key "`cat $KEYDIR/$AP.wep`" [1] key restricted key [1] key on - ;; - - *.open|stop.wep) - iwconfig $IFACE key off - ;; - *) - echo "Unknown command\n" > /dev/stderr - exit 1 - ;; -esac - -exit 0 diff --git a/conf/waproamd.init.in b/conf/waproamd.init.in index 891cd24..467ce9a 100755 --- a/conf/waproamd.init.in +++ b/conf/waproamd.init.in @@ -33,7 +33,9 @@ case "$1" in start) echo -n "Starting Wireless Access Point Roaming Daemon:" for IF in $INTERFACES ; do - $WAPROAMD -i $IF $ARGS + A="`eval echo \$\{ARGS_${IF}\}`" + [ -z "$A" ] && A="$ARGS" + $WAPROAMD -i $IF $A echo -n " $IF" done echo "." diff --git a/configure.ac b/configure.ac index 60f7381..652db46 100644 --- a/configure.ac +++ b/configure.ac @@ -24,7 +24,6 @@ AC_INIT([waproamd], [0.1], [mzjrcxrlq@itaparica.org]) AC_CONFIG_SRCDIR([src/waproamd.c]) AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE([foreign -Wall]) -AM_MAINTAINER_MODE # Checks for programs. AC_PROG_CC @@ -37,8 +36,8 @@ if test "x$GCC" = "xyes" ; then fi if test -d /usr/local/stow ; then - AC_MSG_NOTICE([*** Found /usr/local/stow: installing to /usr/local/stow/waproamd-$VERSION *** ]) - AC_PREFIX_DEFAULT([/usr/local/stow/waproamd-$VERSION]) + AC_MSG_NOTICE([*** Found /usr/local/stow: installing to /usr/local/stow/${PACKAGE_NAME}-${PACKAGE_VERSION} ***]) + AC_PREFIX_DEFAULT([/usr/local/stow/${PACKAGE_NAME}-${PACKAGE_VERSION}]) fi # Checks for libraries. @@ -129,7 +128,7 @@ fi AM_CONDITIONAL([BUILD_AESWEPD], [test "x$aeswepd" = xyes]) AM_CONDITIONAL([BUILD_WAPROAMD], [test "x$waproamd" = xyes]) -AC_CONFIG_FILES([src/Makefile Makefile conf/Makefile conf/scripts/Makefile doc/Makefile]) # man/Makefile doc/Makefile doc/README.html]) +AC_CONFIG_FILES([src/Makefile Makefile conf/Makefile doc/Makefile]) # man/Makefile doc/Makefile doc/README.html]) AC_OUTPUT AC_MSG_NOTICE([*** aeswepd is built: $aeswepd ***]) diff --git a/src/Makefile.am b/src/Makefile.am index 1080a15..5a51db3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -49,3 +49,8 @@ aeswepd_LDADD = -lmcrypt install-exec-hook: cd $(DESTDIR)/$(sbindir) && ln -sf aeswepd aeswepls endif + +svnkeywords: + svn propset svn:keywords Id *.c *.h Makefile.am + +.PHONY: svnkeywords diff --git a/src/aes.c b/src/aes.c index 944da03..80d7cd5 100644 --- a/src/aes.c +++ b/src/aes.c @@ -24,6 +24,8 @@ #include #include +#include + #include "aes.h" #include "util.h" #include "aeswepd.h" @@ -50,33 +52,30 @@ int aes_crypt(uint8_t *key, uint8_t *data, uint8_t *result) { for (j = 0; j < n_cache; j++) if (!memcmp(cache[j].key, key, AES_KEY_LEN) && !memcmp(cache[j].data, data, AES_KEY_LEN)) { - //fprintf(stderr, "Cache hit\n"); memcpy(result, cache[j].result, AES_KEY_LEN); return 0; } - //fprintf(stderr, "Cache miss\n"); - if (m == MCRYPT_FAILED) { if ((m = mcrypt_module_open("rijndael-128", NULL, "ecb", NULL)) == MCRYPT_FAILED) { - fprintf(stderr, "Failed to open rijndael mcrypt module\n"); + daemon_log(LOG_ERR, "Failed to open rijndael mcrypt module\n"); return -1; } } if ((r = mcrypt_generic_init(m, key, AES_KEY_LEN, NULL)) != 0) { - fprintf(stderr, "Failed to encrypt: %s\n", mcrypt_strerror(r)); + daemon_log(LOG_ERR, "Failed to encrypt: %s\n", mcrypt_strerror(r)); return -1; } memcpy(result, data, AES_KEY_LEN); if (mcrypt_generic(m, result, AES_KEY_LEN) != 0) { - fprintf(stderr, "mdecrypt_generic() failed.\n"); + daemon_log(LOG_ERR, "mdecrypt_generic() failed.\n"); return -1; } if (mcrypt_generic_deinit(m) != 0) { - fprintf(stderr, "mdecrypt_generic() failed.\n"); + daemon_log(LOG_ERR, "mdecrypt_generic() failed.\n"); return -1; } diff --git a/src/aeswepd.c b/src/aeswepd.c index 684b224..d144977 100644 --- a/src/aeswepd.c +++ b/src/aeswepd.c @@ -376,14 +376,14 @@ void parse_args(int argc, char *argv[]) { break; case 't': if ((rekey_time = atoi(optarg)) <= 0) { - fprintf(stderr, "Rekey time too short.\n"); + daemon_log(LOG_ERR, "Rekey time too short.\n"); exit(1); } break; case 'm': n_max_keys = atoi(optarg); if (n_max_keys <= 0 || n_max_keys > 4) { - fprintf(stderr, "--max-keys has to be between 1 and 4\n"); + daemon_log(LOG_ERR, "--max-keys has to be between 1 and 4\n"); exit(1); } break; @@ -454,7 +454,7 @@ void parse_args(int argc, char *argv[]) { } default: - fprintf(stderr, "Unknown parameter.\n"); + daemon_log(LOG_ERR, "Unknown parameter.\n"); exit(1); } } diff --git a/src/ifmonitor.c b/src/ifmonitor.c index c1e05ec..9991893 100644 --- a/src/ifmonitor.c +++ b/src/ifmonitor.c @@ -28,6 +28,8 @@ #include #include +#include + #include "util.h" #include "nlapi.h" @@ -43,7 +45,7 @@ static int callback(struct nlmsghdr *n, void *u) { i = NLMSG_DATA(n); if (n->nlmsg_len < NLMSG_LENGTH(sizeof(struct ifinfomsg))) { - fprintf(stderr, "NETLINK: Packet too small or truncated! (2)\n"); + daemon_log(LOG_ERR, "NETLINK: Packet too small or truncated! (2)\n"); return -1; } @@ -72,33 +74,3 @@ static int callback(struct nlmsghdr *n, void *u) { int ifmonitor_init(int (*cb) (int b, int index, unsigned short type, const char *name)) { return nlapi_register(callback, cb); } - -#if 0 - -int test(int b, int index, unsigned short type, const char * name) { - printf("CALLBACK %s %s %i %i\n", b ? "new" : "del", name, index, type); - return 0; -} - -int main(int argc, char *argv[]) { - int r = 1; - - if (nlapi_open(RTMGRP_LINK) < 0) - goto finish; - - if (ifmonitor_init(test) < 0) - goto finish; - - for (;;) - if (nlapi_work() < 0) - goto finish; - - r = 0; - -finish: - nlapi_close(); - - return r; -} - -#endif diff --git a/src/interface.c b/src/interface.c index 72030c3..e835ab3 100644 --- a/src/interface.c +++ b/src/interface.c @@ -26,6 +26,8 @@ #include #include +#include + #include "interface.h" #include "util.h" #include "wireless.h" @@ -40,7 +42,7 @@ struct interface *interface_open(char *name) { strncpy(i->name, name, IFNAMSIZ); if ((i->fd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) { - fprintf(stderr, "socket(): %s\n", strerror(errno)); + daemon_log(LOG_ERR, "socket(): %s\n", strerror(errno)); goto fail; } @@ -77,7 +79,7 @@ int interface_is_assoc(struct interface *i, struct hw_addr *ap) { strncpy(req.ifr_ifrn.ifrn_name, i->name, IFNAMSIZ); if (ioctl(i->fd, SIOCGIWAP, &req) < 0) { - fprintf(stderr, "Failed to get AP address\n"); + daemon_log(LOG_ERR, "Failed to get AP address\n"); return -1; } @@ -94,11 +96,10 @@ int interface_is_assoc(struct interface *i, struct hw_addr *ap) { req.u.data.flags = 1; if (ioctl(i->fd, SIOCGIWSTATS, &req) < 0) { - fprintf(stderr, "Failed to get interface quality\n"); + daemon_log(LOG_ERR, "Failed to get interface quality\n"); return -1; } - if (q.qual.qual <= 0) return 0; diff --git a/src/iwapi.c b/src/iwapi.c index e9b4177..356f144 100644 --- a/src/iwapi.c +++ b/src/iwapi.c @@ -23,6 +23,8 @@ #include #include #include + +#include #include "iwapi.h" int iw_set_essid(struct interface *i, const char* essid) { @@ -42,7 +44,7 @@ int iw_set_essid(struct interface *i, const char* essid) { } if (ioctl(i->fd, SIOCSIWESSID, &req) < 0) { - fprintf(stderr, "ioctl(SIOCSIWESSID): %s\n", strerror(errno)); + daemon_log(LOG_ERR, "ioctl(SIOCSIWESSID): %s\n", strerror(errno)); return -1; } @@ -57,7 +59,7 @@ int iw_set_mode(struct interface *i, int m) { req.u.mode = m; if (ioctl(i->fd, SIOCSIWMODE, &req) < 0) { - fprintf(stderr, "ioctl(SIOCSIWMODE): %s\n", strerror(errno)); + daemon_log(LOG_ERR, "ioctl(SIOCSIWMODE): %s\n", strerror(errno)); return -1; } @@ -72,7 +74,7 @@ int iw_set_freq(struct interface *i, struct iw_freq *f) { req.u.freq = *f; if (ioctl(i->fd, SIOCSIWFREQ, &req) < 0) { - fprintf(stderr, "ioctl(SIOCSIWFREQ): %s\n", strerror(errno)); + daemon_log(LOG_ERR, "ioctl(SIOCSIWFREQ): %s\n", strerror(errno)); return -1; } @@ -89,7 +91,7 @@ int iw_set_ap(struct interface *i, struct hw_addr *ap) { memcpy(req.u.ap_addr.sa_data, ap->addr, ETH_ALEN); if (ioctl(i->fd, SIOCSIWAP, &req) < 0) { - fprintf(stderr, "ioctl(SIOCSIWAP): %s\n", strerror(errno)); + daemon_log(LOG_ERR, "ioctl(SIOCSIWAP): %s\n", strerror(errno)); return -1; } @@ -106,12 +108,10 @@ int iw_scan(struct interface *i) { req.u.param.value = 0; if (ioctl(i->fd, SIOCSIWSCAN, &req) < 0) { - fprintf(stderr, "ioctl(SIOCSIWSCAN): %s\n", strerror(errno)); + daemon_log(LOG_ERR, "ioctl(SIOCSIWSCAN): %s\n", strerror(errno)); return -1; } -// fprintf(stderr, "scan!\n"); - return 0; } @@ -136,19 +136,17 @@ int iw_scan_result(struct interface *i, int (*callback)(struct ap_info* ap)) { if (errno == EAGAIN) return 1; - fprintf(stderr, "ioctl(SIOCGIWSCAN): %s\n", strerror(errno)); + daemon_log(LOG_ERR, "ioctl(SIOCGIWSCAN): %s\n", strerror(errno)); return -1; } -// fprintf(stderr, "scan response!\n"); - e = (struct iw_event*) req.u.data.pointer; l = req.u.data.length; f = 0; hs = sizeof(struct iw_event)-sizeof(union iwreq_data); while (l >= sizeof(struct iw_event)) { if (e->len < hs) { - fprintf(stderr, "Recieved bogus wireless event\n"); + daemon_log(LOG_ERR, "Recieved bogus wireless event\n"); return -1; } @@ -162,7 +160,7 @@ int iw_scan_result(struct interface *i, int (*callback)(struct ap_info* ap)) { f = 1; if (e->len < hs + sizeof(struct sockaddr)) { - fprintf(stderr, "Corrupt scan result (1)\n"); + daemon_log(LOG_ERR, "Corrupt scan result (1)\n"); return -1; } @@ -173,7 +171,7 @@ int iw_scan_result(struct interface *i, int (*callback)(struct ap_info* ap)) { case SIOCGIWESSID: if (e->len < hs + sizeof(struct iw_point)) { - fprintf(stderr, "Corrupt scan result (2)\n"); + daemon_log(LOG_ERR, "Corrupt scan result (2)\n"); return -1; } @@ -187,7 +185,7 @@ int iw_scan_result(struct interface *i, int (*callback)(struct ap_info* ap)) { case SIOCGIWMODE: if (e->len < hs + sizeof(__u32)) { - fprintf(stderr, "Corrupt scan result (3)\n"); + daemon_log(LOG_ERR, "Corrupt scan result (3)\n"); return -1; } @@ -200,7 +198,7 @@ int iw_scan_result(struct interface *i, int (*callback)(struct ap_info* ap)) { case SIOCGIWFREQ: if (e->len < hs + sizeof(struct iw_freq)) { - fprintf(stderr, "Corrupt scan result (4)\n"); + daemon_log(LOG_ERR, "Corrupt scan result (4)\n"); return -1; } @@ -211,8 +209,6 @@ int iw_scan_result(struct interface *i, int (*callback)(struct ap_info* ap)) { if (f == 15) { - //fprintf(stderr, "Scan successful\n"); - if (callback(&ap) < 0) return -1; diff --git a/src/iwkey.c b/src/iwkey.c index b4b44c5..a3403a8 100644 --- a/src/iwkey.c +++ b/src/iwkey.c @@ -24,6 +24,8 @@ #include #include +#include + #include "iwkey.h" #include "wireless.h" #include "util.h" @@ -35,7 +37,7 @@ int wep_key_add(struct interface *i, uint8_t w[WEP_KEY_LEN]) { assert(i); if (n_used_keys >= n_max_keys) { - fprintf(stderr, "Too many keys added!\n"); + daemon_log(LOG_ERR, "Too many keys added!\n"); return -1; } @@ -47,7 +49,7 @@ int wep_key_add(struct interface *i, uint8_t w[WEP_KEY_LEN]) { req.u.encoding.flags = key_map[n_used_keys++]+1; if (ioctl(i->fd, SIOCSIWENCODE, &req) < 0) { - fprintf(stderr, "ioctl(SIOCSIWENCODE): %s\n", strerror(errno)); + daemon_log(LOG_ERR, "ioctl(SIOCSIWENCODE): %s\n", strerror(errno)); return -1; } @@ -70,7 +72,7 @@ int wep_key_finish(struct interface *i) { req.u.encoding.flags = (key_map[n_used_keys-1]+1); if (ioctl(i->fd, SIOCGIWENCODE, &req) < 0) { - fprintf(stderr, "ioctl(SIOCGIWENCODE): %s\n", strerror(errno)); + daemon_log(LOG_ERR, "ioctl(SIOCGIWENCODE): %s\n", strerror(errno)); return -1; } @@ -83,7 +85,7 @@ int wep_key_finish(struct interface *i) { req.u.encoding.flags = (key_map[j]+1); if (ioctl(i->fd, SIOCSIWENCODE, &req) < 0) { - fprintf(stderr, "ioctl(SIOCSIWENCODE): %s\n", strerror(errno)); + daemon_log(LOG_ERR, "ioctl(SIOCSIWENCODE): %s\n", strerror(errno)); return -1; } } @@ -97,7 +99,7 @@ int wep_key_finish(struct interface *i) { req.u.encoding.flags = IW_ENCODE_RESTRICTED; if (ioctl(i->fd, SIOCSIWENCODE, &req) < 0) { - fprintf(stderr, "ioctl(SIOCSIWENCODE): %s\n", strerror(errno)); + daemon_log(LOG_ERR, "ioctl(SIOCSIWENCODE): %s\n", strerror(errno)); return -1; } diff --git a/src/nlapi.c b/src/nlapi.c index d88a1ed..318199f 100644 --- a/src/nlapi.c +++ b/src/nlapi.c @@ -43,7 +43,7 @@ int nlapi_open(uint32_t groups) { struct sockaddr_nl addr; if ((nlapi_fd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE)) < 0) { - fprintf(stderr, "socket(PF_NETLINK): %s\n", strerror(errno)); + daemon_log(LOG_ERR, "socket(PF_NETLINK): %s\n", strerror(errno)); return -1; } @@ -54,7 +54,7 @@ int nlapi_open(uint32_t groups) { if (bind(nlapi_fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) { close(nlapi_fd); - fprintf(stderr, "bind(): %s\n", strerror(errno)); + daemon_log(LOG_ERR, "bind(): %s\n", strerror(errno)); return -1; } @@ -104,7 +104,6 @@ void nlapi_close(void) { close(nlapi_fd); nlapi_fd = -1; - while (callbacks) { struct callback_info *c = callbacks; callbacks = callbacks->next; diff --git a/src/waproamd.c b/src/waproamd.c index 430c839..7c8d7d8 100644 --- a/src/waproamd.c +++ b/src/waproamd.c @@ -64,7 +64,7 @@ char log_ident[32], pid_ident[32]; int issue_scan(struct interface *i) { - //fprintf(stderr, "Scanning...\n"); + //daemon_log(LOG_ERR, "Scanning...\n"); if (iw_set_mode(i, IW_MODE_INFRA) < 0) return -1; @@ -167,16 +167,13 @@ int set_current_ap(struct hw_addr *a) { setenv("IFACE", interface_name, 1); if (!hw_addr_equal(¤t_ap, &null_ap)) { - fprintf(stderr, "Selected AP "); - print_hw_addr(stderr, ¤t_ap); - fprintf(stderr, "\n"); + daemon_log(LOG_INFO, "Selected new AP %s", t); if (run_script(¤t_ap, "start") < 0) return -1; } } - return 0; } @@ -319,7 +316,7 @@ int go(struct interface *i) { if (errno == EINTR) continue; - fprintf(stderr, "select() failed: %s\n", strerror(errno)); + daemon_log(LOG_ERR, "select() failed: %s\n", strerror(errno)); goto finish; } @@ -341,7 +338,7 @@ int go(struct interface *i) { /* Changed: enabled -> disabled */ if (!d && disabled) { - fprintf(stderr, "Interface disabled\n"); + daemon_log(LOG_INFO, "Interface disabled\n"); if (associated) if (set_current_ap(&null_ap) < 0) @@ -352,21 +349,21 @@ int go(struct interface *i) { /* Changed: disabled -> enabled */ if (d && !disabled) { - fprintf(stderr, "Interface enabled\n"); + daemon_log(LOG_INFO, "Interface enabled\n"); associated = 0; } if (!disabled) { /* Changed: associated -> not associated */ if (a && !associated) - fprintf(stderr, "No longer associated.\n"); + daemon_log(LOG_INFO, "No longer associated.\n"); /* Changed: not associated -> associated */ if (!a && associated) { if (set_current_ap(&associated_ap) < 0) goto finish; - fprintf(stderr, "Associated.\n"); + daemon_log(LOG_INFO, "Associated.\n"); next_scan = (time_t) -1; } @@ -559,7 +556,7 @@ void parse_args(int argc, char *argv[]) { break; default: - fprintf(stderr, "Unknown parameter.\n"); + daemon_log(LOG_ERR, "Unknown parameter.\n"); exit(1); } } diff --git a/src/wireless.h b/src/wireless.h index db302a8..0a4ef2e 100644 --- a/src/wireless.h +++ b/src/wireless.h @@ -1,7 +1,7 @@ #ifndef foowirelesshfoo #define foowirelesshfoo -/* $Id: waproamd.c 1.12 Sat, 01 Feb 2003 03:00:07 +0100 lennart $ */ +/* $Id$ */ /* * This file is part of waproamd. -- cgit