summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2003-10-12 21:18:36 +0000
committerLennart Poettering <lennart@poettering.net>2003-10-12 21:18:36 +0000
commit866bc8fd59b7134b800faad565ed00b2e3b09b36 (patch)
treeecd3d882242fb575865c01541d06981dc8ca965d /src
parent293ce53b6d56818bf5544bd62c99c029a4708a47 (diff)
remove waproamd legacy from tree
git-svn-id: file:///home/lennart/svn/public/aeswepd/trunk@19 022f378f-78c4-0310-b860-d162c87e6274
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am31
-rw-r--r--src/aes.c8
-rw-r--r--src/aes.h8
-rw-r--r--src/aeswepd.c8
-rw-r--r--src/aeswepd.h8
-rw-r--r--src/assocwatch.c111
-rw-r--r--src/assocwatch.h28
-rw-r--r--src/exec.c158
-rw-r--r--src/exec.h26
-rw-r--r--src/ifmonitor.c76
-rw-r--r--src/ifmonitor.h26
-rw-r--r--src/interface.c8
-rw-r--r--src/interface.h8
-rw-r--r--src/iwapi.c241
-rw-r--r--src/iwapi.h42
-rw-r--r--src/iwkey.c8
-rw-r--r--src/iwkey.h8
-rw-r--r--src/nlapi.c130
-rw-r--r--src/nlapi.h39
-rw-r--r--src/util.c8
-rw-r--r--src/util.h8
-rw-r--r--src/waproamd.c675
-rw-r--r--src/waproamd.h36
-rw-r--r--src/wireless.h8
24 files changed, 49 insertions, 1658 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 3c059ec..ce00817 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,42 +1,22 @@
# $Id$
-# This file is part of waproamd.
+# This file is part of aeswepd.
#
-# waproamd is free software; you can redistribute it and/or modify it
+# aeswepd 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
+# aeswepd 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,
+# along with aeswepd; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-AM_CFLAGS = -DSYSCONFDIR="\"$(sysconfdir)\""
-
-sbin_PROGRAMS =
-
-if BUILD_WAPROAMD
-sbin_PROGRAMS += waproamd
-
-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 \
- wireless.h wireless.15.h \
- netlink.h rtnetlink.h
-endif
-
-if BUILD_AESWEPD
-sbin_PROGRAMS += aeswepd
+sbin_PROGRAMS = aeswepd
aeswepd_SOURCES = aeswepd.c aeswepd.h \
aes.c aes.h \
@@ -50,7 +30,6 @@ aeswepd_LDADD = -lmcrypt
install-exec-hook:
cd $(DESTDIR)/$(sbindir) && ln -sf aeswepd aeswepls
-endif
svnkeywords:
svn propset svn:keywords Id *.c *.h Makefile.am
diff --git a/src/aes.c b/src/aes.c
index 80d7cd5..5356e66 100644
--- a/src/aes.c
+++ b/src/aes.c
@@ -1,20 +1,20 @@
/* $Id$ */
/*
- * This file is part of waproamd.
+ * This file is part of aeswepd.
*
- * waproamd is free software; you can redistribute it and/or modify it
+ * aeswepd 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
+ * aeswepd 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,
+ * along with aeswepd; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
diff --git a/src/aes.h b/src/aes.h
index 8d0f25a..3a011fd 100644
--- a/src/aes.h
+++ b/src/aes.h
@@ -4,20 +4,20 @@
/* $Id$ */
/*
- * This file is part of waproamd.
+ * This file is part of aeswepd.
*
- * waproamd is free software; you can redistribute it and/or modify it
+ * aeswepd 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
+ * aeswepd 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,
+ * along with aeswepd; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
diff --git a/src/aeswepd.c b/src/aeswepd.c
index d144977..11e77c8 100644
--- a/src/aeswepd.c
+++ b/src/aeswepd.c
@@ -1,20 +1,20 @@
/* $Id$ */
/*
- * This file is part of waproamd.
+ * This file is part of aeswepd.
*
- * waproamd is free software; you can redistribute it and/or modify it
+ * aeswepd 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
+ * aeswepd 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,
+ * along with aeswepd; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
diff --git a/src/aeswepd.h b/src/aeswepd.h
index 0313ed6..8b22995 100644
--- a/src/aeswepd.h
+++ b/src/aeswepd.h
@@ -4,20 +4,20 @@
/* $Id$ */
/*
- * This file is part of waproamd.
+ * This file is part of aeswepd.
*
- * waproamd is free software; you can redistribute it and/or modify it
+ * aeswepd 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
+ * aeswepd 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,
+ * along with aeswepd; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
diff --git a/src/assocwatch.c b/src/assocwatch.c
deleted file mode 100644
index 300b3fc..0000000
--- a/src/assocwatch.c
+++ /dev/null
@@ -1,111 +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.
- */
-
-#include <sys/types.h>
-#include <sys/socket.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <assert.h>
-
-#include <linux/types.h>
-#include "netlink.h"
-#include "rtnetlink.h"
-#include <linux/if.h>
-#include "wireless.h"
-
-#include <libdaemon/dlog.h>
-
-#include "util.h"
-#include "assocwatch.h"
-#include "nlapi.h"
-
-static int handle_wireless_event(int idx, uint8_t *data, int l, int (*cb) (int idx, struct hw_addr *a)) {
- struct iw_event *e;
- int hs;
- struct hw_addr ap;
-
- e = (struct iw_event*) data;
- hs = sizeof(struct iw_event)-sizeof(union iwreq_data);
- while (l >= sizeof(struct iw_event)) {
-
- if (e->len < hs) {
- daemon_log(LOG_ERR, "ASSOCWATCH: Recieved corrupt wireless event\n");
- return -1;
- }
-
- switch (e->cmd) {
-
- case SIOCGIWAP:
- if (e->len < hs + sizeof(struct sockaddr)) {
- daemon_log(LOG_ERR, "ASSOCWATCH: Recieved corrupt AP wireless event\n");
- return -1;
- }
-
- memcpy(ap.addr, e->u.ap_addr.sa_data, ETH_ALEN);
-
- if (cb(idx, is_assoc_ap(&ap) ? &ap : NULL) < 0)
- return -1;
-
- return 0;
- }
-
- l -= e->len;
- e = (struct iw_event*) (((uint8_t*) e) + e->len);
- }
-
- return 0;
-}
-
-static int callback(struct nlmsghdr *n, void *u) {
- int (*cb) (int idx, struct hw_addr *a) = u;
-
- if (n->nlmsg_type == RTM_NEWLINK) {
- struct ifinfomsg* ifi;
- struct rtattr *a;
- int la;
-
- if (n->nlmsg_len < NLMSG_LENGTH(sizeof(struct ifinfomsg))) {
- daemon_log(LOG_ERR, "ASSOCWATCH: Corrupt NETLINK message\n");
- return -1;
- }
-
- ifi = NLMSG_DATA(n);
- a = (void*) ifi + NLMSG_ALIGN(sizeof(struct ifinfomsg));
- la = NLMSG_PAYLOAD(n, sizeof(struct ifinfomsg));
-
- while (RTA_OK(a, la)) {
- if(a->rta_type == IFLA_WIRELESS)
- handle_wireless_event(ifi->ifi_index, RTA_DATA(a), RTA_PAYLOAD(a), cb);
-
- a = RTA_NEXT(a, la);
- }
- }
-
- return 0;
-}
-
-
-int assocwatch_init(int (*cb) (int idx, struct hw_addr *a)) {
- return nlapi_register(callback, cb);
-}
diff --git a/src/assocwatch.h b/src/assocwatch.h
deleted file mode 100644
index 77fd732..0000000
--- a/src/assocwatch.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef fooassocwatchfoo
-#define fooassocwatchfoo
-
-/* $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.
- */
-
-#include "util.h"
-
-int assocwatch_init(int (*cb) (int idx, struct hw_addr *a));
-
-#endif
diff --git a/src/exec.c b/src/exec.c
deleted file mode 100644
index f2a37ef..0000000
--- a/src/exec.c
+++ /dev/null
@@ -1,158 +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.
- */
-
-#include <sys/types.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <sys/wait.h>
-#include <limits.h>
-#include <fcntl.h>
-#include <stdio.h>
-
-#include <libdaemon/dlog.h>
-#include <libdaemon/dsignal.h>
-
-#include "exec.h"
-
-int log_exec(const char *dir, const char *prog, const char *arg) {
- pid_t pid;
- int p[2];
- unsigned n = 0;
- static char buf[256];
- int sigfd, r;
- fd_set fds;
-
- daemon_log(LOG_INFO, "Running '%s %s'", prog, arg);
-
- if (pipe(p) < 0) {
- daemon_log(LOG_ERR, "pipe() failed: %s", strerror(errno));
- return -1;
- }
-
- if ((pid = fork()) < 0) {
- daemon_log(LOG_ERR, "fork() failed: %s", strerror(errno));
- return -1;
-
- } else if (pid == 0) {
- dup2(p[1], 1);
- dup2(p[1], 2);
-
- if (p[0] > 2)
- close(p[0]);
-
- if (p[1] > 2)
- close(p[1]);
-
- close(0);
- open("/dev/null", O_RDONLY);
-
- umask(0022); // Set up a sane umask
-
- if (dir && chdir(dir) < 0) {
- daemon_log(LOG_WARNING, "Failed to change to directory '%s'", dir);
- chdir("/");
- }
-
- execl(prog, prog, arg, 0);
-
- daemon_log(LOG_ERR, "execl(%s) failed: %s\n", prog, strerror(errno));
-
- _exit(EXIT_FAILURE);
- }
-
- close(p[1]);
-
- FD_ZERO(&fds);
- FD_SET(p[0], &fds);
- FD_SET(sigfd = daemon_signal_fd(), &fds);
-
- n = 0;
-
- for (;;) {
- fd_set qfds = fds;
-
- if (select(FD_SETSIZE, &qfds, NULL, NULL, NULL) < 0) {
-
- if (errno == EINTR)
- continue;
-
- daemon_log(LOG_ERR, "select() failed: %s", strerror(errno));
- return -1;
- }
-
-
- if (FD_ISSET(p[0], &qfds)) {
- char c;
-
- if (read(p[0], &c, 1) != 1)
- break;
-
- buf[n] = c;
-
- if (c == '\n' || n >= sizeof(buf) - 2) {
- if (c != '\n') n++;
- buf[n] = 0;
-
- if (buf[0])
- daemon_log(LOG_INFO, "client: %s", buf);
-
- n = 0;
- } else
- n++;
- }
-
- if (FD_ISSET(sigfd, &qfds)) {
- int sig;
-
- if ((sig = daemon_signal_next()) < 0) {
- daemon_log(LOG_ERR, "daemon_signal_next(): %s", strerror(errno));
- break;
- }
-
- if (sig != SIGCHLD) {
- daemon_log(LOG_WARNING, "Killing child.");
- kill(pid, SIGTERM);
- }
-
- break;
- }
- }
-
- if (n > 0) {
- buf[n] = 0;
- daemon_log(LOG_WARNING, "client: %s", buf);
- }
-
- waitpid(pid, &r, 0);
-
- close(p[0]);
-
- if (!WIFEXITED(r) || WEXITSTATUS(r) != 0) {
- daemon_log(LOG_ERR, "Program execution failed, return value is %i.", WEXITSTATUS(r));
- return -1;
- } else {
- daemon_log(LOG_INFO, "Program executed successfully.");
- return 0;
- }
-}
diff --git a/src/exec.h b/src/exec.h
deleted file mode 100644
index 081e214..0000000
--- a/src/exec.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef fooexehfoo
-#define fooexehfoo
-
-/* $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.
- */
-
-int log_exec(const char *dir, const char *prog, const char *arg);
-
-#endif
diff --git a/src/ifmonitor.c b/src/ifmonitor.c
deleted file mode 100644
index fea78ca..0000000
--- a/src/ifmonitor.c
+++ /dev/null
@@ -1,76 +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.
- */
-
-#include <stdio.h>
-#include <sys/socket.h>
-#include <linux/if.h>
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-#include <linux/types.h>
-#include "netlink.h"
-#include "rtnetlink.h"
-
-#include <libdaemon/dlog.h>
-
-#include "util.h"
-#include "nlapi.h"
-
-static int callback(struct nlmsghdr *n, void *u) {
- int (*cb)(int b, int index, unsigned short type, const char *name) = u;
-
- if (n->nlmsg_type == RTM_NEWLINK || n->nlmsg_type == RTM_DELLINK) {
- struct rtattr *a;
- struct ifinfomsg *i;
- char ifname[IFNAMSIZ+1];
- int la;
-
- i = NLMSG_DATA(n);
-
- if (n->nlmsg_len < NLMSG_LENGTH(sizeof(struct ifinfomsg))) {
- daemon_log(LOG_ERR, "NETLINK: Packet too small or truncated! (2)\n");
- return -1;
- }
-
- memset(&ifname, 0, sizeof(ifname));
-
- a = (void*) i + NLMSG_ALIGN(sizeof(struct ifinfomsg));
- la = NLMSG_PAYLOAD(n, sizeof(struct ifinfomsg));
-
- while (RTA_OK(a, la)) {
-
- if(a->rta_type == IFLA_IFNAME)
- strncpy(ifname, RTA_DATA(a), MIN(RTA_PAYLOAD(a), IFNAMSIZ));
-
- a = RTA_NEXT(a, la);
- }
-
- if (cb(n->nlmsg_type == RTM_NEWLINK, i->ifi_index, i->ifi_type, ifname[0] ? ifname : NULL) < 0)
- return -1;
- }
-
-
- return 0;
-}
-
-
-int ifmonitor_init(int (*cb) (int b, int index, unsigned short type, const char *name)) {
- return nlapi_register(callback, cb);
-}
diff --git a/src/ifmonitor.h b/src/ifmonitor.h
deleted file mode 100644
index f860dc2..0000000
--- a/src/ifmonitor.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef fooifmonitorhfoo
-#define fooifmonitorhfoo
-
-/* $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.
- */
-
-int ifmonitor_init(int (*cb) (int b, int index, unsigned short type, const char *name));
-
-#endif
diff --git a/src/interface.c b/src/interface.c
index e835ab3..4f1605a 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -1,20 +1,20 @@
/* $Id$ */
/*
- * This file is part of waproamd.
+ * This file is part of aeswepd.
*
- * waproamd is free software; you can redistribute it and/or modify it
+ * aeswepd 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
+ * aeswepd 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,
+ * along with aeswepd; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
diff --git a/src/interface.h b/src/interface.h
index c05c5b3..b0667a8 100644
--- a/src/interface.h
+++ b/src/interface.h
@@ -4,20 +4,20 @@
/* $Id$ */
/*
- * This file is part of waproamd.
+ * This file is part of aeswepd.
*
- * waproamd is free software; you can redistribute it and/or modify it
+ * aeswepd 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
+ * aeswepd 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,
+ * along with aeswepd; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
diff --git a/src/iwapi.c b/src/iwapi.c
deleted file mode 100644
index 98b1dec..0000000
--- a/src/iwapi.c
+++ /dev/null
@@ -1,241 +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.
- */
-
-#include <net/if_arp.h>
-#include <errno.h>
-#include <assert.h>
-#include <string.h>
-#include <sys/ioctl.h>
-
-#include <libdaemon/dlog.h>
-#include "iwapi.h"
-
-int iw_set_essid(struct interface *i, const char* essid) {
- struct iwreq req;
- char e[IW_ESSID_MAX_SIZE + 1];
-
- memset(&req, 0, sizeof(req));
- strncpy(req.ifr_ifrn.ifrn_name, i->name, IFNAMSIZ);
-
- if (essid && *essid) {
- memset(&e, 0, sizeof(e));
- strncpy(e, essid, IW_ESSID_MAX_SIZE);
-
- req.u.essid.pointer = e;
- req.u.essid.length = strlen(essid) + 1;
- req.u.essid.flags = 1;
- }
-
- if (ioctl(i->fd, SIOCSIWESSID, &req) < 0) {
- daemon_log(LOG_ERR, "ioctl(SIOCSIWESSID): %s\n", strerror(errno));
- return -1;
- }
-
- return 0;
-}
-
-int iw_set_mode(struct interface *i, int m) {
- struct iwreq req;
-
- memset(&req, 0, sizeof(req));
- strncpy(req.ifr_ifrn.ifrn_name, i->name, IFNAMSIZ);
- req.u.mode = m;
-
- if (ioctl(i->fd, SIOCSIWMODE, &req) < 0) {
- daemon_log(LOG_ERR, "ioctl(SIOCSIWMODE): %s\n", strerror(errno));
- return -1;
- }
-
- return 0;
-}
-
-int iw_set_freq(struct interface *i, struct iw_freq *f) {
- struct iwreq req;
-
- memset(&req, 0, sizeof(req));
- strncpy(req.ifr_ifrn.ifrn_name, i->name, IFNAMSIZ);
- req.u.freq = *f;
-
- if (ioctl(i->fd, SIOCSIWFREQ, &req) < 0) {
- daemon_log(LOG_ERR, "ioctl(SIOCSIWFREQ): %s\n", strerror(errno));
- return -1;
- }
-
- return 0;
-}
-
-int iw_set_ap(struct interface *i, struct hw_addr *ap) {
- struct iwreq req;
-
- memset(&req, 0, sizeof(req));
- strncpy(req.ifr_ifrn.ifrn_name, i->name, IFNAMSIZ);
-
- req.u.ap_addr.sa_family = ARPHRD_ETHER;
- memcpy(req.u.ap_addr.sa_data, ap->addr, ETH_ALEN);
-
- if (ioctl(i->fd, SIOCSIWAP, &req) < 0) {
- daemon_log(LOG_ERR, "ioctl(SIOCSIWAP): %s\n", strerror(errno));
- return -1;
- }
-
- return 0;
-}
-
-int iw_scan(struct interface *i) {
- struct iwreq req;
-
- memset(&req, 0, sizeof(req));
- strncpy(req.ifr_ifrn.ifrn_name, i->name, IFNAMSIZ);
-
- req.u.param.flags = IW_SCAN_DEFAULT;
- req.u.param.value = 0;
-
- if (ioctl(i->fd, SIOCSIWSCAN, &req) < 0) {
- daemon_log(LOG_ERR, "ioctl(SIOCSIWSCAN): %s\n", strerror(errno));
- return -1;
- }
-
- return 0;
-}
-
-
-int iw_scan_result(struct interface *i, int (*callback)(struct ap_info* ap)) {
- struct ap_info ap;
- int f, l, hs;
- struct iwreq req;
- struct iw_event *e;
- uint8_t buffer[IW_SCAN_MAX_DATA];
-
- assert(i && callback);
-
- memset(&req, 0, sizeof(req));
- strncpy(req.ifr_ifrn.ifrn_name, i->name, IFNAMSIZ);
-
- req.u.data.pointer = buffer;
- req.u.data.flags = 0;
- req.u.data.length = sizeof(buffer);
-
- if (ioctl(i->fd, SIOCGIWSCAN, &req) < 0) {
- if (errno == EAGAIN)
- return 1;
-
- daemon_log(LOG_ERR, "ioctl(SIOCGIWSCAN): %s\n", strerror(errno));
- return -1;
- }
-
- 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) {
- daemon_log(LOG_ERR, "Recieved bogus wireless event\n");
- return -1;
- }
-
- if (!f)
- memset(&ap, 0, sizeof(ap));
-
- switch (e->cmd) {
-
- case SIOCGIWAP:
-
- f = 1;
-
- if (e->len < hs + sizeof(struct sockaddr)) {
- daemon_log(LOG_ERR, "Corrupt scan result (1)\n");
- return -1;
- }
-
- memcpy(&ap.ap, e->u.ap_addr.sa_data, ETH_ALEN);
- break;
-
-
- case SIOCGIWESSID:
-
- if (e->len < hs + sizeof(struct iw_point)) {
- daemon_log(LOG_ERR, "Corrupt scan result (2)\n");
- return -1;
- }
-
- memset(&ap.essid, 0, sizeof(ap.essid));
- memcpy(&ap.essid, ((uint8_t*) e)+hs+sizeof(struct iw_point), MIN(sizeof(ap.essid)-1, e->len-hs-sizeof(struct iw_point)));
-
- f |= 2;
-
- break;
-
- case SIOCGIWMODE:
-
- if (e->len < hs + sizeof(__u32)) {
- daemon_log(LOG_ERR, "Corrupt scan result (3)\n");
- return -1;
- }
-
- if ((e->u.mode != IW_MODE_INFRA) && (e->u.mode != IW_MODE_MASTER))
- f = 0; // Ignore non-APs
- else
- f |= 4;
-
- break;
-
- case SIOCGIWFREQ:
- if (e->len < hs + sizeof(struct iw_freq)) {
- daemon_log(LOG_ERR, "Corrupt scan result (4)\n");
- return -1;
- }
-
- memcpy(&ap.freq, &e->u.freq, sizeof(struct iw_freq));
- f |= 8;
- break;
- }
-
- if (f == 15) {
-
- if (callback(&ap) < 0)
- return -1;
-
- f = 0;
- }
-
-
- l -= e->len;
- e = (struct iw_event*) (((uint8_t*) e) + e->len);
- }
- return 0;
-}
-
-int iw_tune(struct interface *i, struct ap_info *ap) {
- assert(i && ap);
-
- if (iw_set_mode(i, IW_MODE_INFRA) < 0)
- return -1;
-
- if (iw_set_essid(i, ap->essid) < 0)
- return -1;
-
- if (iw_set_freq(i, &ap->freq) < 0)
- return -1;
-
- if (iw_set_ap(i, &ap->ap) < 0)
- return -1;
-
- return 0;
-}
diff --git a/src/iwapi.h b/src/iwapi.h
deleted file mode 100644
index 9a15387..0000000
--- a/src/iwapi.h
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef fooiwapihfoo
-#define fooiwapihfoo
-
-/* $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.
- */
-
-#include "interface.h"
-#include "wireless.h"
-#include "util.h"
-
-struct ap_info {
- struct hw_addr ap;
- struct iw_freq freq;
- char essid[IW_ESSID_MAX_SIZE + 1];
-};
-
-int iw_set_essid(struct interface *i, const char* essid);
-int iw_set_mode(struct interface *i, int m);
-int iw_set_freq(struct interface *i, struct iw_freq *f);
-int iw_set_ap(struct interface *i, struct hw_addr *ap);
-int iw_scan(struct interface *i);
-int iw_tune(struct interface *i, struct ap_info *ap);
-int iw_scan_result(struct interface *i, int (*callback)(struct ap_info*));
-
-#endif
diff --git a/src/iwkey.c b/src/iwkey.c
index a3403a8..719c31a 100644
--- a/src/iwkey.c
+++ b/src/iwkey.c
@@ -1,20 +1,20 @@
/* $Id$ */
/*
- * This file is part of waproamd.
+ * This file is part of aeswepd.
*
- * waproamd is free software; you can redistribute it and/or modify it
+ * aeswepd 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
+ * aeswepd 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,
+ * along with aeswepd; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
diff --git a/src/iwkey.h b/src/iwkey.h
index 3b39f7e..4e853c0 100644
--- a/src/iwkey.h
+++ b/src/iwkey.h
@@ -4,20 +4,20 @@
/* $Id$ */
/*
- * This file is part of waproamd.
+ * This file is part of aeswepd.
*
- * waproamd is free software; you can redistribute it and/or modify it
+ * aeswepd 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
+ * aeswepd 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,
+ * along with aeswepd; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
diff --git a/src/nlapi.c b/src/nlapi.c
deleted file mode 100644
index 318199f..0000000
--- a/src/nlapi.c
+++ /dev/null
@@ -1,130 +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.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-#include <assert.h>
-#include <stdlib.h>
-
-#include <libdaemon/dlog.h>
-
-#include "nlapi.h"
-
-int nlapi_fd = -1;
-
-struct callback_info {
- nlapi_callback_t callback;
- void *userdata;
- struct callback_info * next;
-};
-
-struct callback_info *callbacks = NULL;
-
-int nlapi_open(uint32_t groups) {
- struct sockaddr_nl addr;
-
- if ((nlapi_fd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE)) < 0) {
- daemon_log(LOG_ERR, "socket(PF_NETLINK): %s\n", strerror(errno));
- return -1;
- }
-
- memset(&addr, 0, sizeof(addr));
- addr.nl_family = AF_NETLINK;
- addr.nl_groups = groups;
- addr.nl_pid = getpid();
-
- if (bind(nlapi_fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
- close(nlapi_fd);
- daemon_log(LOG_ERR, "bind(): %s\n", strerror(errno));
- return -1;
- }
-
- return 0;
-}
-
-int nlapi_work(int block) {
-
- assert(nlapi_fd >= 0);
-
- for (;;) {
- int bytes;
- char replybuf[1024];
- struct nlmsghdr *p = (struct nlmsghdr *) replybuf;
-
- if ((bytes = recv(nlapi_fd, &replybuf, sizeof(replybuf), block ? 0 : MSG_DONTWAIT)) < 0) {
-
- if (errno == EAGAIN || errno == EINTR)
- return 0;
-
- daemon_log(LOG_ERR, "NLAPI: recv(): %s\n", strerror(errno));
- return -1;
- }
-
- for (; bytes > 0; p = NLMSG_NEXT(p, bytes)) {
- struct callback_info *c;
-
- if (!NLMSG_OK(p, bytes) || bytes < sizeof(struct nlmsghdr) || bytes < p->nlmsg_len) {
- daemon_log(LOG_ERR, "NLAPI: Packet too small or truncated!\n");
- return -1;
- }
-
- for (c = callbacks; c; c = c->next)
- if (c->callback(p, c->userdata) < 0)
- return -1;
- }
-
- if (block)
- break;
- }
-
- return 0;
-}
-
-void nlapi_close(void) {
- if (nlapi_fd >= 0)
- close(nlapi_fd);
- nlapi_fd = -1;
-
- while (callbacks) {
- struct callback_info *c = callbacks;
- callbacks = callbacks->next;
- free(c);
- }
-}
-
-int nlapi_register(int (*callback) (struct nlmsghdr *n, void *u), void *u) {
- struct callback_info *c;
-
- assert(callback);
-
- if (!(c = malloc(sizeof(struct callback_info)))) {
- daemon_log(LOG_ERR, "NLAPI: Not enough memory.\n");
- return -1;
- }
-
- c->callback = callback;
- c->userdata = u;
-
- c->next = callbacks;
- callbacks = c;
- return 0;
-}
diff --git a/src/nlapi.h b/src/nlapi.h
deleted file mode 100644
index b00a425..0000000
--- a/src/nlapi.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef foonlapihfoo
-#define foonlapihfoo
-
-/* $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.
- */
-
-#include <stdint.h>
-#include <sys/socket.h>
-#include <linux/types.h>
-#include "netlink.h"
-#include "rtnetlink.h"
-
-typedef int (*nlapi_callback_t) (struct nlmsghdr *n, void *u);
-
-extern int nlapi_fd;
-
-int nlapi_open(uint32_t groups);
-void nlapi_close(void);
-int nlapi_work(int block);
-int nlapi_register(nlapi_callback_t cb, void *u);
-
-#endif
diff --git a/src/util.c b/src/util.c
index 9b6061f..be35f94 100644
--- a/src/util.c
+++ b/src/util.c
@@ -1,20 +1,20 @@
/* $Id$ */
/*
- * This file is part of waproamd.
+ * This file is part of aeswepd.
*
- * waproamd is free software; you can redistribute it and/or modify it
+ * aeswepd 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
+ * aeswepd 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,
+ * along with aeswepd; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
diff --git a/src/util.h b/src/util.h
index fc7805b..956079f 100644
--- a/src/util.h
+++ b/src/util.h
@@ -4,20 +4,20 @@
/* $Id$ */
/*
- * This file is part of waproamd.
+ * This file is part of aeswepd.
*
- * waproamd is free software; you can redistribute it and/or modify it
+ * aeswepd 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
+ * aeswepd 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,
+ * along with aeswepd; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
diff --git a/src/waproamd.c b/src/waproamd.c
deleted file mode 100644
index f96288a..0000000
--- a/src/waproamd.c
+++ /dev/null
@@ -1,675 +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.
- */
-
-#define _GNU_SOURCE
-
-#include <assert.h>
-#include <string.h>
-#include <time.h>
-#include <errno.h>
-#include <unistd.h>
-#include <signal.h>
-#include <stdlib.h>
-#include <getopt.h>
-
-#include <libdaemon/dpid.h>
-#include <libdaemon/dlog.h>
-#include <libdaemon/dfork.h>
-#include <libdaemon/dsignal.h>
-
-#include "iwapi.h"
-#include "interface.h"
-#include "exec.h"
-#include "nlapi.h"
-#include "ifmonitor.h"
-#include "assocwatch.h"
-#include "waproamd.h"
-
-char *interface_name = NULL;
-int interface_index = -1;
-
-int disabled = 0,
- associated = 0;
-
-struct hw_addr associated_ap;
-struct hw_addr current_ap;
-
-int use_assocwatch = 1,
- use_ifmonitor = 0,
- daemonize = 1,
- wait_on_fork = 0,
- use_syslog = 1;
-
-int poll_interval = 5,
- scan_interval = 10;
-
-char log_ident[32], pid_ident[32];
-
-int issue_scan(struct interface *i) {
-
- //daemon_log(LOG_ERR, "Scanning...\n");
-
- if (iw_set_mode(i, IW_MODE_INFRA) < 0)
- return -1;
-
-/* if (iw_set_ap(i, &null_ap) < 0) */
-/* return -1; */
-
- if (iw_set_essid(i, NULL) < 0)
- return -1;
-
- if (iw_scan(i) < 0)
- return -1;
-
- return 0;
-}
-
-void get_script_path(char *path, int l, struct hw_addr *ap) {
- assert(path && l);
-
- if (!ap) {
- snprintf(path, l, "%s/default", SCRIPTDIR);
- return;
- }
-
- snprintf(path, l, "%s/%02x:%02x:%02x:%02x:%02x:%02x",
- SCRIPTDIR,
- ap->addr[0], ap->addr[1], ap->addr[2],
- ap->addr[3], ap->addr[4], ap->addr[5]);
-}
-
-struct ap_info selected_ap;
-int selected_ap_has_script;
-int selected_ap_valid;
-
-static int scan_result_cb(struct ap_info*ap) {
- int b;
- char path[PATH_MAX];
-
- assert(ap);
- get_script_path(path, sizeof(path), &ap->ap);
- b = access(path, X_OK) == 0;
-
- if (selected_ap_valid) {
-
- if (!b || selected_ap_has_script)
- return 0;
- }
-
- memcpy(&selected_ap, ap, sizeof(struct ap_info));
- selected_ap_valid = 1;
- selected_ap_has_script = 1;
- return 0;
-}
-
-int read_scan(struct interface *i, struct ap_info **ap) {
- int r;
- selected_ap_valid = 0;
- selected_ap_has_script = 0;
-
- if ((r = iw_scan_result(i, scan_result_cb)) < 0)
- return -1;
-
- if (r == 1)
- return 1;
-
- *ap = selected_ap_valid ? &selected_ap : NULL;
-
- return 0;
-}
-
-int run_script(struct hw_addr *ap, const char *arg) {
- char path[PATH_MAX];
-
- get_script_path(path, sizeof(path), ap);
-
- if (access(path, X_OK) < 0)
- get_script_path(path, sizeof(path), NULL);
-
- return log_exec(SCRIPTDIR, path, arg);
-};
-
-
-int set_current_ap(struct hw_addr *a) {
- char t[32];
-
- if (!a)
- a = &null_ap;
-
- if (!hw_addr_equal(a, &current_ap)) {
-
- if (!hw_addr_equal(&current_ap, &null_ap)) {
- if (run_script(&current_ap, "stop") < 0)
- return -1;
- }
-
- memcpy(&current_ap, a, sizeof(struct hw_addr));
-
- snprint_hw_addr(t, sizeof(t), &current_ap);
- setenv("AP", t, 1);
- setenv("IFACE", interface_name, 1);
-
- if (!hw_addr_equal(&current_ap, &null_ap)) {
- daemon_log(LOG_INFO, "Selected new AP %s", t);
-
- if (run_script(&current_ap, "start") < 0)
- return -1;
- }
- }
-
- return 0;
-}
-
-int ifmonitor_cb(int b, int index, unsigned short type, const char *name) {
- if (!name)
- return 0;
-
- if (!strcmp(name, interface_name)) {
- interface_index = index;
- disabled = !b;
- }
- return 0;
-}
-
-int assocwatch_cb(int index, struct hw_addr *a) {
- char name[IFNAMSIZ+1];
-
- if (get_ifname(index, name, sizeof(name)) < 0)
- return -1;
-
- if (!strcmp(name, interface_name)) {
- interface_index = index;
- disabled = 0;
- if ((associated = !!a))
- memcpy(&associated_ap, a, sizeof(struct hw_addr));
- }
-
- return 0;
-}
-
-int go(struct interface *i) {
- time_t next_scan;
- int scanning = 0;
- int send_retval = 1;
- int r = -1, sigfd;
- fd_set fds;
-
- daemon_log(LOG_INFO, "waproamd "VERSION" initializing%s%s.", use_ifmonitor ? ", using NETLINK device monitoring" : "", use_assocwatch ? ", using wireless event notifications" : "");
-
- if (daemon_pid_file_create() < 0) {
- daemon_log(LOG_ERR, "Could not create PID file %s.", daemon_pid_file_proc());
- goto finish;
- }
-
- if (daemon_signal_init(SIGINT, SIGTERM, SIGQUIT, SIGHUP, -1) < 0) {
- daemon_log(LOG_ERR, "Could not register signal handler: %s", strerror(errno));
- goto finish;
- }
-
- if (nlapi_open(RTMGRP_LINK) < 0)
- goto finish;
-
- if (use_ifmonitor) {
- int b;
-
- if ((b = is_iface_available(interface_name)) < 0)
- goto finish;
-
- disabled = !b;
- } else
- disabled = 0;
-
- memset(&current_ap, 0, sizeof(current_ap));
-
- if ((associated = interface_is_assoc(i, &associated_ap)) < 0) {
- if (!use_ifmonitor)
- goto finish;
-
- associated = 0;
- }
-
- daemon_log(LOG_INFO, "Currently %sassociated, interface %s.", associated ? "" : "not ", disabled ? "disabled" : "enabled");
-
- if (use_assocwatch)
- if (assocwatch_init(assocwatch_cb) < 0)
- goto finish;
-
- if (use_ifmonitor)
- if (ifmonitor_init(ifmonitor_cb) < 0)
- goto finish;
-
- daemon_log(LOG_INFO, "Initialization complete.");
-
- set_current_ap(&associated_ap);
- next_scan = associated || disabled ? (time_t) -1 : 0;
-
- if (daemonize && wait_on_fork) {
- daemon_retval_send(0);
- send_retval = 0;
- }
-
- FD_ZERO(&fds);
- FD_SET(sigfd = daemon_signal_fd(), &fds);
- FD_SET(nlapi_fd, &fds);
-
- for (;;) {
- fd_set qfds;
- struct timeval tv, *ptv;
- time_t now = time(NULL);
- int a, d;
-
- if (next_scan != (time_t) -1 && next_scan <= now) {
- if (issue_scan(i) < 0) {
- if (!use_ifmonitor)
- goto finish;
- } else
- scanning = 1;
-
- next_scan = (time_t) -1;
- }
-
- ptv = NULL;
-
- if (scanning) {
- tv.tv_sec = 0;
- tv.tv_usec = 100000;
- ptv = &tv;
- } else if (!use_assocwatch) {
- tv.tv_sec = poll_interval;
- tv.tv_usec = 0;
- ptv = &tv;
- }
-
- if (next_scan != (time_t) -1) {
- struct timeval tv2;
- now = time(NULL);
- tv2.tv_sec = next_scan > now ? next_scan - now : 0;
- tv2.tv_usec = 0;
-
- if (!ptv || tv2.tv_sec < tv.tv_sec) {
- tv.tv_sec = tv2.tv_sec;
- tv.tv_usec = tv2.tv_usec;
- ptv = &tv;
- }
- }
-
- qfds = fds;
-
- if (select(FD_SETSIZE, &qfds, NULL, NULL, ptv) < 0) {
- if (errno == EINTR)
- continue;
-
- daemon_log(LOG_ERR, "select() failed: %s\n", strerror(errno));
- goto finish;
- }
-
- a = associated;
- d = disabled;
-
- if (FD_ISSET(nlapi_fd, &qfds))
- if (nlapi_work(0) < 0)
- goto finish;
-
- if (!disabled && !use_assocwatch) {
- if ((associated = interface_is_assoc(i, &associated_ap)) < 0) {
- if (!use_ifmonitor)
- goto finish;
-
- associated = 0;
- }
- }
-
- /* Changed: enabled -> disabled */
- if (!d && disabled) {
- daemon_log(LOG_INFO, "Interface disabled\n");
-
- if (associated)
- if (set_current_ap(NULL) < 0)
- goto finish;
-
- associated = scanning = 0;
- }
-
- /* Changed: disabled -> enabled */
- if (d && !disabled) {
- daemon_log(LOG_INFO, "Interface enabled\n");
- associated = scanning = 0;
- }
-
- /* Changed: associated -> not associated */
- if (a && !associated) {
- daemon_log(LOG_INFO, "No longer associated.\n");
- scanning = 0;
- }
-
- /* Changed: not associated -> associated */
- if (!a && associated) {
- if (set_current_ap(&associated_ap) < 0)
- goto finish;
-
- daemon_log(LOG_INFO, "Associated.\n");
- scanning = 0;
- }
-
- if (scanning) {
- int r;
- struct ap_info *ai = NULL;
-
- if ((r = read_scan(i, &ai)) < 0) {
- if (!use_ifmonitor)
- goto finish;
-
- scanning = 0;
-
- } else if (!r) {
-
- scanning = 0;
-
- if (!associated) {
-
- if (set_current_ap(ai ? &ai->ap : NULL) < 0)
- goto finish;
- }
- }
- }
-
- if (FD_ISSET(sigfd, &qfds)) {
- int sig;
-
- if ((sig = daemon_signal_next()) < 0) {
- daemon_log(LOG_ERR, "daemon_signal_next(): %s", strerror(errno));
- goto finish;
- }
-
-
- switch (sig) {
-
- case SIGINT:
- case SIGTERM:
- case SIGQUIT:
- r = 0;
- goto finish;
-
- case SIGHUP:
- next_scan = 0;
- break;
-
- default:
- daemon_log(LOG_INFO, "Ignoring unknown signal %s", strsignal(sig));
- break;
-
- }
- }
-
- if (next_scan == (time_t) -1 && !scanning)
- if (!disabled && !associated)
- next_scan = time(NULL) + scan_interval;
-
- if (disabled || associated) {
- scanning = 0;
- next_scan = (time_t) -1;
- }
- }
-
- r = 0;
-
-finish:
-
- set_current_ap(NULL);
-
- if (send_retval && daemonize && wait_on_fork)
- daemon_retval_send(1);
-
- nlapi_close();
-
- daemon_pid_file_remove();
- daemon_signal_done();
-
- daemon_log(LOG_INFO, "Exiting.");
-
- return r;
-}
-
-void usage(char *p) {
- if (strrchr(p, '/'))
- p = strchr(p, '/')+1;
-
- printf("%s -- Wireless Access Point Roaming Daemon for 802.11b\n\n"
- "Usage: %s [options]\n\n"
- "Options:\n"
- " -n --no-daemon Do not daemonize (for debugging) (%s)\n"
- " -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"
- " -M --monitor Use interface monitoring (%s)\n"
- " -e --no-event Don't use wireless event API (%s)\n"
- " -t --scan-interval Specify scan interval (%i)\n"
- " -p --poll-interval Specify association poll interval, unless using -e (%i)\n"
- " -h --help Show this help\n"
- " -k --kill Kill a running daemon\n"
- " -c --check-running Check if a daemon is currently running\n"
- " -v --version Show version\n",
- p, p,
- !daemonize ? "on" : "off",
- !use_syslog ? "on" : "off",
- interface_name,
- wait_on_fork ? "on" : "off",
- use_ifmonitor ? "on" : "off",
- use_assocwatch ? "off" : "on",
- scan_interval,
- poll_interval);
-}
-
-void parse_args(int argc, char *argv[]) {
- static struct option long_options[] = {
- {"no-daemon", no_argument, 0, 'n'},
- {"no-syslog", no_argument, 0, 's'},
- {"iface", required_argument, 0, 'i'},
- {"wait-on-fork", no_argument, 0, 'w'},
- {"monitor", no_argument, 0, 'M'},
- {"no-event", no_argument, 0, 'e'},
- {"scan-interval", required_argument, 0, 't'},
- {"poll-interval", required_argument, 0, 'p'},
- {"help", no_argument, 0, 'h'},
- {"kill", no_argument, 0, 'k'},
- {"check-running", no_argument, 0, 'c'},
- {"version", no_argument, 0, 'v'},
- {0, 0, 0, 0}
- };
- int option_index = 0;
- int _help = 0, _kill = 0, _check = 0, _version = 0;
-
- for (;;) {
- int c;
-
- if ((c = getopt_long(argc, argv, "nsi:whkcvMet:p:", long_options, &option_index)) < 0)
- break;
-
- switch (c) {
- case 'n' :
- daemonize = !daemonize;
- break;
-
- case 's' :
- use_syslog = !use_syslog;
- break;
-
- case 'i' :
- if (interface_name)
- free(interface_name);
- interface_name = strdup(optarg);
- break;
-
- case 'w':
- wait_on_fork = !wait_on_fork;
- break;
-
- case 'M':
- use_ifmonitor = !use_ifmonitor;
- break;
-
- case 'e':
- use_assocwatch = !use_assocwatch;
- break;
-
- case 't':
- if ((scan_interval = atoi(optarg)) < 0) {
- daemon_log(LOG_ERR, "Scan interval must be a positive, nonzero integer.");
- exit(1);
- }
-
- case 'p':
- if ((poll_interval = atoi(optarg)) < 0) {
- daemon_log(LOG_ERR, "Poll interval must be a positive, nonzero integer.");
- exit(1);
- }
-
- case 'h':
- _help = 1;
- break;
-
- case 'k':
- _kill = 1;
- break;
-
- case 'c':
- _check = 1;
- break;
-
- case 'v':
- _version = 1;
- break;
-
- default:
- daemon_log(LOG_ERR, "Unknown parameter.\n");
- exit(1);
- }
- }
-
- if (!interface_name)
- interface_name = strdup("wlan0");
-
- snprintf(pid_ident, sizeof(pid_ident), "waproamd.%s", interface_name);
- daemon_pid_file_ident = pid_ident;
- snprintf(log_ident, sizeof(log_ident), "waproamd(%s)", interface_name);
- daemon_log_ident = log_ident;
-
-
- if (_help) {
- usage(argv[0]);
- exit(0);
- }
-
- if (_kill) {
- if (daemon_pid_file_kill(SIGINT) < 0) {
- daemon_log(LOG_ERR, "Failed to kill daemon. (%s)", strerror(errno));
- exit(6);
- }
-
- exit(0);
- }
-
- if (_version) {
- printf("waproamd "VERSION"\n");
- exit(0);
- }
-
- if (_check) {
- pid_t pid = daemon_pid_file_is_running();
-
- if (pid == (pid_t) -1)
- printf("waproamd not running.\n");
- else
- printf("waproamd process for device %s running as pid %u.\n", interface_name, pid);
-
- exit(pid == 0 ? 255 : 0);
- }
-
- if (!use_syslog)
- daemon_log_use = DAEMON_LOG_STDERR;
-
-}
-
-int main(int argc, char *argv[]) {
- struct interface *i = NULL;
- int r = 1;
- pid_t pid;
-
- daemon_pid_file_ident = daemon_log_ident = daemon_ident_from_argv0(argv[0]);
-
- parse_args(argc, argv);
-
- if (geteuid() != 0) {
- daemon_log(LOG_ERR, "Sorry, you need to be root to run this binary.");
- goto finish;
- }
-
- if ((pid = daemon_pid_file_is_running()) >= 0) {
- daemon_log(LOG_ERR, "Daemon already running on PID file %u", pid);
- goto finish;
-
- }
-
- if (daemonize) {
- pid_t pid;
-
- if (wait_on_fork)
- if (daemon_retval_init() < 0) {
- daemon_log(LOG_ERR, "Sorry, could not create pipe: %s", strerror(errno));
- goto finish;
- }
-
- if ((pid = daemon_fork()) < 0)
- goto finish;
-
- if (pid) {
- int c = 0;
-
- // Parent process
-
- if (wait_on_fork)
- if ((c = daemon_retval_wait(60)) < 0) {
- daemon_log(LOG_WARNING, "Killing background process.");
- kill(pid, SIGTERM);
- }
-
- r = c;
- goto finish;
- }
- }
-
- if (!(i = interface_open(interface_name)) < 0)
- goto finish;
-
- if (go(i) < 0)
- goto finish;
-
- r = 0;
-
-finish:
-
- if (i)
- interface_close(i);
-
- if (interface_name)
- free(interface_name);
-
- return r;
-}
diff --git a/src/waproamd.h b/src/waproamd.h
deleted file mode 100644
index a6faefb..0000000
--- a/src/waproamd.h
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef foowaproamdhfoo
-#define foowaproamdhfoo
-
-/* $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.
- */
-
-#ifndef SYSCONFDIR
-#define SYSCONFDIR "/etc"
-#endif
-
-#ifndef SCRIPTDIR
-#define SCRIPTDIR SYSCONFDIR"/waproamd/scripts"
-#endif
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#endif
diff --git a/src/wireless.h b/src/wireless.h
index 0a4ef2e..c111ef1 100644
--- a/src/wireless.h
+++ b/src/wireless.h
@@ -4,20 +4,20 @@
/* $Id$ */
/*
- * This file is part of waproamd.
+ * This file is part of aeswepd.
*
- * waproamd is free software; you can redistribute it and/or modify it
+ * aeswepd 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
+ * aeswepd 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,
+ * along with aeswepd; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/