summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2003-12-11 18:28:55 +0000
committerLennart Poettering <lennart@poettering.net>2003-12-11 18:28:55 +0000
commit8421b14ba340b6615c2b12bad2a87c177fab5de5 (patch)
treef3590da302c8f2fd5e9c4ef22edae81416c16d79
parent86f7689a0cc7bd0509ac63f2b1d065ab45e312b6 (diff)
some changes
git-svn-id: file:///home/lennart/svn/public/waproamd/trunk@53 022f378f-78c4-0310-b860-d162c87e6274
-rwxr-xr-xconf/default.in4
-rw-r--r--configure.ac9
-rw-r--r--src/Makefile.am6
-rw-r--r--src/iwapi.c22
-rw-r--r--src/waproamd.c39
-rw-r--r--src/waproamd.h4
-rw-r--r--src/wireless.h5
7 files changed, 55 insertions, 34 deletions
diff --git a/conf/default.in b/conf/default.in
index b1888b9..6a326fe 100755
--- a/conf/default.in
+++ b/conf/default.in
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
# $Id$
@@ -20,7 +20,7 @@
KEYDIR="@sysconfdir@/waproamd/keys"
-if [ -z "$AP" -o -z "$IFACE" -o -z "$ESSID" -o -z "$ESSID_ESCAPED" ] ; then
+if [ -z "$AP" -o -z "$IFACE" ] ; then
echo "Corrupt environment" > /dev/stderr
exit 1
fi
diff --git a/configure.ac b/configure.ac
index 759df33..3c6ab78 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,7 +20,7 @@
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
AC_PREREQ(2.57)
-AC_INIT([waproamd], [0.4], [mzjncebnzq (at) 0pointer (dot) de])
+AC_INIT([waproamd], [0.5], [mzjncebnzq (at) 0pointer (dot) de])
AC_CONFIG_SRCDIR([src/waproamd.c])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([foreign -Wall])
@@ -39,7 +39,7 @@ fi
if type -p stow > /dev/null && test -d /usr/local/stow ; then
AC_MSG_NOTICE([*** Found /usr/local/stow: default install prefix set to /usr/local/stow/${PACKAGE_NAME}-${PACKAGE_VERSION} ***])
- AC_PREFIX_DEFAULT([/usr/local/stow/${PACKAGE_NAME}-${PACKAGE_VERSION}])
+ ac_default_prefix="/usr/local/stow/${PACKAGE_NAME}-${PACKAGE_VERSION}"
fi
# Set SysV init script directory
@@ -51,8 +51,9 @@ AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([fcntl.h limits.h stdint.h stdlib.h string.h sys/ioctl.h sys/socket.h unistd.h])
-AC_CHECK_LIB([daemon], [daemon_fork],, [AC_MSG_ERROR([*** Sorry, you have to install libdaemon ***])])
-AC_CHECK_LIB([daemon], [daemon_pid_file_kill_wait],, [AC_MSG_WARN([*** libdaemon too old, --wait-on-kill is not going to be supported. Consider updating to libdaemon 0.3. ***])])
+PKG_CHECK_MODULES(LIBDAEMON, [libdaemon >= 0.4])
+AC_SUBST(LIBDAEMON_CFLAGS)
+AC_SUBST(LIBDAEMON_LIBS)
AC_C_CONST
AC_TYPE_MODE_T
diff --git a/src/Makefile.am b/src/Makefile.am
index 9176e15..16ed2c2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -16,7 +16,7 @@
# along with waproamd; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-AM_CFLAGS = -DSYSCONFDIR="\"$(sysconfdir)\""
+AM_CFLAGS = -DSYSCONFDIR="\"$(sysconfdir)\""
sbin_PROGRAMS = waproamd
@@ -24,7 +24,6 @@ waproamd_SOURCES = waproamd.c waproamd.h \
interface.c interface.h \
iwapi.c iwapi.h \
util.c util.h \
- exec.c exec.h \
nlapi.c nlapi.h \
assocwatch.c assocwatch.h \
ifmonitor.c ifmonitor.h \
@@ -32,6 +31,9 @@ waproamd_SOURCES = waproamd.c waproamd.h \
netlink.h rtnetlink.h \
iwhostroam.h iwhostroam.c
+waproamd_CFLAGS = $(AM_CFLAGS) $(LIBDAEMON_CFLAGS)
+waproamd_LDADD = $(LIBDAEMON_LIBS)
+
svnkeywords:
svn propset svn:keywords Id *.c *.h Makefile.am
diff --git a/src/iwapi.c b/src/iwapi.c
index 3202f9e..f5338f6 100644
--- a/src/iwapi.c
+++ b/src/iwapi.c
@@ -314,6 +314,7 @@ int iw_assoc(struct interface *i, struct ap_info *ap) {
struct hw_addr hw;
struct iwreq req;
struct iw_statistics q;
+ static struct iw_range range;
int m;
assert(i);
@@ -342,7 +343,22 @@ int iw_assoc(struct interface *i, struct ap_info *ap) {
return -1;
}
- if (q.qual.qual <= 0)
+ memset(&req, 0, sizeof(req));
+ strncpy(req.ifr_ifrn.ifrn_name, i->name, IFNAMSIZ);
+
+ memset(&range, 0, sizeof(struct iw_range));
+ req.u.data.pointer = (caddr_t) &range;
+ req.u.data.length = sizeof(struct iw_range);
+ req.u.data.flags = 0;
+
+ if (ioctl(i->fd, SIOCGIWRANGE, &req) < 0) {
+ fprintf(stderr, "SIOCGIWRANGE failed: %s\n", strerror(errno));
+ return -1;
+ }
+
+ /* Test if both qual and level are on their lowest level */
+ if (q.qual.qual <= 0 &&
+ (q.qual.level > range.max_qual.level ? q.qual.level <= 156 : q.qual.level <= 0))
return 0;
if (ap) {
@@ -352,9 +368,9 @@ int iw_assoc(struct interface *i, struct ap_info *ap) {
if (iw_get_essid(i, ap->essid) < 0)
return -1;
-
+
if (iw_get_freq(i, &ap->freq) < 0)
- return -1;
+ memset(&ap->freq, 0, sizeof(ap->freq)); /* hostap 0.1.2 fails to report the freq sometimes */
}
return 1;
diff --git a/src/waproamd.c b/src/waproamd.c
index 91dd26b..3dba456 100644
--- a/src/waproamd.c
+++ b/src/waproamd.c
@@ -20,6 +20,10 @@
#define _GNU_SOURCE
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include <assert.h>
#include <string.h>
#include <time.h>
@@ -33,20 +37,16 @@
#include <libdaemon/dlog.h>
#include <libdaemon/dfork.h>
#include <libdaemon/dsignal.h>
+#include <libdaemon/dexec.h>
#include "iwapi.h"
#include "interface.h"
-#include "exec.h"
#include "nlapi.h"
#include "ifmonitor.h"
#include "assocwatch.h"
#include "waproamd.h"
#include "iwhostroam.h"
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
char *interface_name = NULL;
int interface_index = -1;
@@ -63,9 +63,7 @@ int use_assocwatch = 1,
use_ifmonitor = 0,
daemonize = 1,
wait_on_fork = 0,
-#ifdef DAEMON_PID_FILE_KILL_WAIT_AVAILABLE
wait_on_kill = 0,
-#endif
use_syslog = 1,
use_userspace_roaming = 1;
@@ -174,6 +172,7 @@ int read_scan(struct interface *i, struct ap_info **ap) {
int run_script(struct ap_info *ai, const char *arg) {
char t[32];
char path[PATH_MAX];
+ int ret = 0;
if (get_script_path(path, sizeof(path), ai) < 0)
get_script_path(path, sizeof(path), NULL);
@@ -184,7 +183,15 @@ int run_script(struct ap_info *ai, const char *arg) {
setenv("ESSID", ai->essid, 1);
setenv("ESSID_ESCAPED", escape_essid(ai->essid), 1);
- return log_exec(SCRIPTDIR, path, arg);
+ if (daemon_exec(SCRIPTDIR, &ret, path, path, arg, (char*) 0) < 0)
+ daemon_log(LOG_WARNING, "Script execution failed abnormously.");
+ else if (ret != 0)
+ daemon_log(LOG_WARNING, "Script returned %i as return value.", ret);
+ else
+ daemon_log(LOG_INFO, "Script successfully executed.");
+
+ return 0;
+
};
@@ -544,9 +551,7 @@ void usage(char *p) {
" -s --no-syslog Do not use syslog, use stderr instead (for debugging) (%s)\n"
" -i --iface=IFACE Specify network interface (%s)\n"
" -w --wait-on-fork Wait until daemon fork finished (%s)\n"
-#ifdef DAEMON_PID_FILE_KILL_WAIT_AVAILABLE
" -W --wait-on-kill When run with -k, wait until the daemon died (%s)\n"
-#endif
" -M --monitor Use interface monitoring (%s)\n"
" -e --no-event Don't use wireless event API (%s)\n"
" -U --no-userspace-roaming Don't enable user space roaming via private ioctl (%s)\n"
@@ -564,9 +569,7 @@ void usage(char *p) {
!use_syslog ? "on" : "off",
interface_name,
wait_on_fork ? "on" : "off",
-#ifdef DAEMON_PID_FILE_KILL_WAIT_AVAILABLE
- wait_on_kill ? "on" : "off",
-#endif
+ wait_on_kill ? "on" : "off",
use_ifmonitor ? "on" : "off",
use_assocwatch ? "off" : "on",
use_userspace_roaming ? "off" : "on",
@@ -580,9 +583,7 @@ void parse_args(int argc, char *argv[]) {
{"no-syslog", no_argument, 0, 's'},
{"iface", required_argument, 0, 'i'},
{"wait-on-fork", no_argument, 0, 'w'},
-#ifdef DAEMON_PID_FILE_KILL_WAIT_AVAILABLE
{"wait-on-kill", no_argument, 0, 'W'},
-#endif
{"monitor", no_argument, 0, 'M'},
{"no-event", no_argument, 0, 'e'},
{"no-userspace-roaming", no_argument, 0, 'U'},
@@ -625,11 +626,9 @@ void parse_args(int argc, char *argv[]) {
wait_on_fork = !wait_on_fork;
break;
-#ifdef DAEMON_PID_FILE_KILL_WAIT_AVAILABLE
case 'W':
wait_on_kill = !wait_on_kill;
break;
-#endif
case 'S':
_suspend = 1;
break;
@@ -659,12 +658,14 @@ void parse_args(int argc, char *argv[]) {
daemon_log(LOG_ERR, "Scan interval must be a positive, nonzero integer.");
exit(1);
}
-
+ break;
+
case 'p':
if ((poll_interval = atoi(optarg)) < 0) {
daemon_log(LOG_ERR, "Poll interval must be a positive, nonzero integer.");
exit(1);
}
+ break;
case 'h':
_help = 1;
@@ -705,11 +706,9 @@ void parse_args(int argc, char *argv[]) {
if (_kill || _resume || _suspend || _issuescan) {
int rv;
-#ifdef DAEMON_PID_FILE_KILL_WAIT_AVAILABLE
if (_kill && wait_on_kill)
rv = daemon_pid_file_kill_wait(SIGINT, 5);
else
-#endif
rv = daemon_pid_file_kill(_kill ? SIGINT : (_resume ? SIGUSR2 : (_issuescan ? SIGHUP : SIGUSR1)));
if (rv < 0) {
diff --git a/src/waproamd.h b/src/waproamd.h
index a6faefb..6d2a627 100644
--- a/src/waproamd.h
+++ b/src/waproamd.h
@@ -21,9 +21,9 @@
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#ifndef SYSCONFDIR
+/*#ifndef SYSCONFDIR
#define SYSCONFDIR "/etc"
-#endif
+#endif*/
#ifndef SCRIPTDIR
#define SCRIPTDIR SYSCONFDIR"/waproamd/scripts"
diff --git a/src/wireless.h b/src/wireless.h
index f654dff..5f3842b 100644
--- a/src/wireless.h
+++ b/src/wireless.h
@@ -21,8 +21,11 @@
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
+#include <sys/types.h>
+#include <sys/socket.h>
#include <linux/if.h>
#include <net/if_arp.h>
-#include "wireless.15.h"
+
+#include "wireless.16.h"
#endif