diff options
author | Lennart Poettering <lennart@poettering.net> | 2003-11-15 10:30:30 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2003-11-15 10:30:30 +0000 |
commit | 909f82a22883e3f45ec64d8206802bbce5bad9bf (patch) | |
tree | 61293c94ee5c063a485a7c493c64d8f185d13cc0 /src | |
parent | 1049edd1d1cacb85e8b4fc9daa91a434f2372f0b (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
Diffstat (limited to 'src')
-rw-r--r-- | src/iwapi.c | 2 | ||||
-rw-r--r-- | src/util.c | 7 | ||||
-rw-r--r-- | src/waproamd.c | 24 |
3 files changed, 16 insertions, 17 deletions
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); @@ -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), ¤t_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(¤t_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) |