summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2003-11-15 10:30:30 +0000
committerLennart Poettering <lennart@poettering.net>2003-11-15 10:30:30 +0000
commit909f82a22883e3f45ec64d8206802bbce5bad9bf (patch)
tree61293c94ee5c063a485a7c493c64d8f185d13cc0
parent1049edd1d1cacb85e8b4fc9daa91a434f2372f0b (diff)
some support for ah-hoc networks
essid-based configuration git-svn-id: file:///home/lennart/svn/public/waproamd/trunk@45 022f378f-78c4-0310-b860-d162c87e6274
-rwxr-xr-xbootstrap.sh2
-rwxr-xr-xconf/default.in27
-rw-r--r--src/iwapi.c2
-rw-r--r--src/util.c7
-rw-r--r--src/waproamd.c24
5 files changed, 33 insertions, 29 deletions
diff --git a/bootstrap.sh b/bootstrap.sh
index 497134f..f36a742 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
# $Id$
# This file is part of waproamd.
diff --git a/conf/default.in b/conf/default.in
index cad1268..77f6b6b 100755
--- a/conf/default.in
+++ b/conf/default.in
@@ -20,25 +20,30 @@
KEYDIR="@sysconfdir@/waproamd/keys"
-if [ -z "$AP" -o -z "$IFACE" ] ; then
+if [ -z "$AP" -o -z "$IFACE" -o -z "$ESSID" -o -z "$ESSID_ESCAPED" -o -z "$ADHOC" ] ; 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
+AP_UC="$(echo $AP | tr [a-f] [A-F])"
+METHOD=open
+for M in aes wep ; do
+ for F in "$AP" "$AP_UC" "essid:$ESSID_ESCAPED" ; do
+ if test -r "$KEYDIR/$F.$M" ; then
+ METHOD="$M"
+ FILE="$F"
+ break
+ fi
+ done
+ [ "x$METHOD" != "xopen" ] && break
+done
-echo "Settings policy '$METHOD' for AP $AP"
+[ "x$1" = "xstart" ] && echo "Setting policy '$METHOD'"
case "$1.$METHOD" in
start.aes)
+ aeswepd -i $IFACE -w -F "$KEYDIR/$FILE.aes"
iwconfig $IFACE key on
- aeswepd -i $IFACE -w -F "$KEYDIR/$AP.aes"
;;
stop.aes)
@@ -47,7 +52,7 @@ case "$1.$METHOD" in
;;
start.wep)
- KEY="$(cat $KEYDIR/$AP.wep)"
+ KEY="$(cat $KEYDIR/$FILE.wep )"
iwconfig $IFACE key [1] restricted $KEY
iwconfig $IFACE key on
;;
diff --git a/src/iwapi.c b/src/iwapi.c
index 2640b06..5fbb305 100644
--- a/src/iwapi.c
+++ b/src/iwapi.c
@@ -30,7 +30,7 @@
int iw_set_essid(struct interface *i, const char* essid) {
struct iwreq req;
char e[IW_ESSID_MAX_SIZE + 1];
- assert(i && essid);
+ assert(i);
memset(&req, 0, sizeof(req));
strncpy(req.ifr_ifrn.ifrn_name, i->name, IFNAMSIZ);
diff --git a/src/util.c b/src/util.c
index b6d4e14..caedd89 100644
--- a/src/util.c
+++ b/src/util.c
@@ -164,12 +164,13 @@ const char* escape_essid(const char *s) {
for (i = s, o = output; i-s < IW_ESSID_MAX_SIZE && *i; i++) {
- if (*i >= 32 && *i < 126 && *i != '/' && *i != '%') {
+ if (*i >= 32 && *i < 126 && *i != '/' && *i != '%')
+ *(o++) = *i;
+ else {
*(o++) = '%';
*(o++) = hextab[*i >> 4];
*(o++) = hextab[*i & 0xF];
- } else
- *(o++) = *i;
+ }
}
*(o++) = 0;
diff --git a/src/waproamd.c b/src/waproamd.c
index 23884bf..98cec2c 100644
--- a/src/waproamd.c
+++ b/src/waproamd.c
@@ -75,7 +75,7 @@ char log_ident[32], pid_ident[32];
int issue_scan(struct interface *i) {
static int count = 0;
- daemon_log(LOG_ERR, "Scanning... %i\n", count++);
+ daemon_log(LOG_ERR, "Scanning... %i", count++);
/* Due to driver issues, the return codes of these function calls are no longer evaluated */
iw_set_mode(i, IW_MODE_INFRA);
@@ -96,7 +96,7 @@ int get_script_path(char *path, int l, struct ap_info *ai) {
return 0;
}
- snprintf(path, l, "%s/%02X:%02X:%02X:%02X:%02X:%02X",
+ snprintf(path, l, "%s/%02x:%02x:%02x:%02x:%02x:%02x",
SCRIPTDIR,
ai->ap.addr[0], ai->ap.addr[1], ai->ap.addr[2],
ai->ap.addr[3], ai->ap.addr[4], ai->ap.addr[5]);
@@ -104,7 +104,7 @@ int get_script_path(char *path, int l, struct ap_info *ai) {
if (!access(path, X_OK))
return 0;
- snprintf(path, l, "%s/%02x:%02x:%02x:%02x:%02x:%02x",
+ snprintf(path, l, "%s/%02X:%02X:%02X:%02X:%02X:%02X",
SCRIPTDIR,
ai->ap.addr[0], ai->ap.addr[1], ai->ap.addr[2],
ai->ap.addr[3], ai->ap.addr[4], ai->ap.addr[5]);
@@ -206,7 +206,7 @@ int set_current_ap(struct ap_info *a) {
else {
char t[20];
snprint_hw_addr(t, sizeof(t), &current_ap.ap);
- daemon_log(LOG_INFO, "Selected new AP %s with ESSID", t, escape_essid(a->essid));
+ daemon_log(LOG_INFO, "Selected new AP %s with ESSID '%s'", t, escape_essid(a->essid));
}
if (run_script(&current_ap, "start") < 0)
@@ -358,7 +358,7 @@ int go(struct interface *i) {
if (errno == EINTR)
continue;
- daemon_log(LOG_ERR, "select() failed: %s\n", strerror(errno));
+ daemon_log(LOG_ERR, "select() failed: %s", strerror(errno));
goto finish;
}
@@ -371,8 +371,6 @@ int go(struct interface *i) {
if (do_status_check || (!use_assocwatch && !disabled && !paused)) {
- daemon_log(LOG_INFO, "Querying association status");
-
if ((associated = iw_assoc(i, &associated_ap)) < 0) {
if (!use_ifmonitor)
goto finish;
@@ -394,7 +392,7 @@ int go(struct interface *i) {
/* Changed: enabled -> disabled */
if (!d && disabled) {
- daemon_log(LOG_INFO, "Interface disabled\n");
+ daemon_log(LOG_INFO, "Interface disabled");
if (associated)
if (set_current_ap(NULL) < 0)
@@ -405,14 +403,14 @@ int go(struct interface *i) {
/* Changed: disabled -> enabled */
if (d && !disabled) {
- daemon_log(LOG_INFO, "Interface enabled\n");
+ daemon_log(LOG_INFO, "Interface enabled");
associated = scanning = 0;
}
if (!disabled) {
/* Changed: associated -> not associated */
if (a && !associated) {
- daemon_log(LOG_INFO, "No longer associated.\n");
+ daemon_log(LOG_INFO, "No longer associated.");
scanning = 0;
}
@@ -421,7 +419,7 @@ int go(struct interface *i) {
if (set_current_ap(&associated_ap) < 0)
goto finish;
- daemon_log(LOG_INFO, "Associated.\n");
+ daemon_log(LOG_INFO, "Associated.");
scanning = 0;
}
@@ -439,9 +437,9 @@ int go(struct interface *i) {
scanning = 0;
- if (!associated) {
+ if (!associated && ai) {
- if (ai && iw_tune(i, ai) < 0)
+ if (iw_tune(i, ai) < 0)
goto finish;
if (set_current_ap(ai) < 0)